]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
Big backport from Enterprise
[bacula/bacula] / bacula / src / dird / dird_conf.h
1 /*
2    Bacula(R) - The Network Backup Solution
3
4    Copyright (C) 2000-2017 Kern Sibbald
5
6    The original author of Bacula is Kern Sibbald, with contributions
7    from many others, a complete list can be found in the file AUTHORS.
8
9    You may use this file and others of this release according to the
10    license defined in the LICENSE file, which includes the Affero General
11    Public License, v3.0 ("AGPLv3") and some additional permissions and
12    terms pursuant to its AGPLv3 Section 7.
13
14    This notice must be preserved when any source code is
15    conveyed and/or propagated.
16
17    Bacula(R) is a registered trademark of Kern Sibbald.
18 */
19 /*
20  * Director specific configuration and defines
21  *
22  *     Kern Sibbald, Feb MM
23  */
24
25 /* NOTE:  #includes at the end of this file */
26
27 /*
28  * Resource codes -- they must be sequential for indexing
29  */
30 enum {
31    R_DIRECTOR = 1001,
32    R_CLIENT,
33    R_JOB,
34    R_STORAGE,
35    R_CATALOG,
36    R_SCHEDULE,
37    R_FILESET,
38    R_POOL,
39    R_MSGS,
40    R_COUNTER,
41    R_CONSOLE,
42    R_JOBDEFS,
43    R_DEVICE,       /* This is the real last device class */
44
45    R_AUTOCHANGER,  /* Alias for R_STORAGE after R_LAST */
46    R_FIRST = R_DIRECTOR,
47    R_LAST  = R_DEVICE                 /* keep this updated */
48 };
49
50
51 /*
52  * Some resource attributes
53  */
54 enum {
55    R_NAME = 1020,
56    R_ADDRESS,
57    R_PASSWORD,
58    R_TYPE,
59    R_BACKUP
60 };
61
62 /* Options for FileSet keywords */
63 struct s_fs_opt {
64    const char *name;
65    int keyword;
66    const char *option;
67 };
68
69 /* Job Level keyword structure */
70 struct s_jl {
71    const char *level_name;                 /* level keyword */
72    int32_t  level;                         /* level */
73    int32_t  job_type;                      /* JobType permitting this level */
74 };
75
76 /* Job Type keyword structure */
77 struct s_jt {
78    const char *type_name;
79    int32_t job_type;
80 };
81
82 /* Definition of the contents of each Resource */
83 /* Needed for forward references */
84 class SCHED;
85 class CLIENT;
86 class FILESET;
87 class POOL;
88 class RUN;
89 class DEVICE;
90 class RUNSCRIPT;
91
92 /*
93  *   Director Resource
94  *
95  */
96 class DIRRES {
97 public:
98    RES   hdr;
99    dlist *DIRaddrs;
100    dlist *DIRsrc_addr;                /* address to source connections from */
101    char *password;                    /* Password for UA access */
102    char *query_file;                  /* SQL query file */
103    char *working_directory;           /* WorkingDirectory */
104    const char *scripts_directory;     /* ScriptsDirectory */
105    const char *plugin_directory;      /* Plugin Directory */
106    char *pid_directory;               /* PidDirectory */
107    char *subsys_directory;            /* SubsysDirectory */
108    MSGS *messages;                    /* Daemon message handler */
109    uint32_t MaxConcurrentJobs;        /* Max concurrent jobs for whole director */
110    uint32_t MaxSpawnedJobs;           /* Max Jobs that can be started by Migration/Copy */
111    uint32_t MaxConsoleConnect;        /* Max concurrent console session */
112    uint32_t MaxReload;                /* Maximum reload requests */
113    utime_t FDConnectTimeout;          /* timeout for connect in seconds */
114    utime_t SDConnectTimeout;          /* timeout in seconds */
115    utime_t heartbeat_interval;        /* Interval to send heartbeats */
116    char *tls_ca_certfile;             /* TLS CA Certificate File */
117    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
118    char *tls_certfile;                /* TLS Server Certificate File */
119    char *tls_keyfile;                 /* TLS Server Key File */
120    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
121    alist *tls_allowed_cns;            /* TLS Allowed Clients */
122    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
123    utime_t stats_retention;           /* Stats retention period in seconds */
124    bool comm_compression;             /* Enable comm line compression */
125    bool tls_authenticate;             /* Authenticated with TLS */
126    bool tls_enable;                   /* Enable TLS */
127    bool tls_require;                  /* Require TLS */
128    bool tls_verify_peer;              /* TLS Verify Client Certificate */
129    char *verid;                       /* Custom Id to print in version command */
130    /* Methods */
131    char *name() const;
132 };
133
134 inline char *DIRRES::name() const { return hdr.name; }
135
136 /*
137  * Device Resource
138  *  This resource is a bit different from the other resources
139  *  because it is not defined in the Director
140  *  by DEVICE { ... }, but rather by a "reference" such as
141  *  DEVICE = xxx; Then when the Director connects to the
142  *  SD, it requests the information about the device.
143  */
144 class DEVICE {
145 public:
146    RES hdr;
147
148    bool found;                        /* found with SD */
149    int32_t num_writers;               /* number of writers */
150    int32_t max_writers;               /* = 1 for files */
151    int32_t reserved;                  /* number of reserves */
152    int32_t num_drives;                /* for autochanger */
153    bool autochanger;                  /* set if device is autochanger */
154    bool open;                         /* drive open */
155    bool append;                       /* in append mode */
156    bool read;                         /* in read mode */
157    bool labeled;                      /* Volume name valid */
158    bool offline;                      /* not available */
159    bool autoselect;                   /* can be selected via autochanger */
160    uint32_t PoolId;
161    char ChangerName[MAX_NAME_LENGTH];
162    char VolumeName[MAX_NAME_LENGTH];
163    char MediaType[MAX_NAME_LENGTH];
164
165    /* Methods */
166    char *name() const;
167 };
168
169 inline char *DEVICE::name() const { return hdr.name; }
170
171 /*
172  * Console ACL positions
173  */
174 enum {
175    Job_ACL = 0,
176    Client_ACL,
177    Storage_ACL,
178    Schedule_ACL,
179    Run_ACL,
180    Pool_ACL,
181    Command_ACL,
182    FileSet_ACL,
183    Catalog_ACL,
184    Where_ACL,
185    PluginOptions_ACL,
186    RestoreClient_ACL,
187    BackupClient_ACL,
188    Directory_ACL,               /* List of directories that can be accessed in the restore tree */
189    Num_ACL                      /* keep last */
190 };
191
192 /*
193  *    Console Resource
194  */
195 class CONRES {
196 public:
197    RES   hdr;
198    char *password;                    /* UA server password */
199    alist *ACL_lists[Num_ACL];         /* pointers to ACLs */
200    char *tls_ca_certfile;             /* TLS CA Certificate File */
201    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
202    char *tls_certfile;                /* TLS Server Certificate File */
203    char *tls_keyfile;                 /* TLS Server Key File */
204    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
205    alist *tls_allowed_cns;            /* TLS Allowed Clients */
206    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
207    bool tls_authenticate;             /* Authenticated with TLS */
208    bool tls_enable;                   /* Enable TLS */
209    bool tls_require;                  /* Require TLS */
210    bool tls_verify_peer;              /* TLS Verify Client Certificate */
211
212    /* Methods */
213    char *name() const;
214 };
215
216 inline char *CONRES::name() const { return hdr.name; }
217
218
219 /*
220  *   Catalog Resource
221  *
222  */
223 class CAT {
224 public:
225    RES   hdr;
226
227    uint32_t db_port;                  /* Port */
228    char *db_address;                  /* host name for remote access */
229    char *db_socket;                   /* Socket for local access */
230    char *db_password;
231    char *db_user;
232    char *db_name;
233    char *db_driver;                   /* Select appropriate driver */
234    char *db_ssl_key;                  /* the path name to the key file */
235    char *db_ssl_cert;                 /* the path name to the certificate file */
236    char *db_ssl_ca;                   /* the path name to the certificate authority file */
237    char *db_ssl_capath;               /* the path name to a directory that contains trusted SSL CA certificates in PEM format */
238    char *db_ssl_cipher;               /* a list of permissible ciphers to use for SSL encryption */
239    uint32_t mult_db_connections;      /* set for multiple db connections */
240    bool disable_batch_insert;         /* set to disable batch inserts */
241
242    /* Methods */
243    char *name() const;
244    char *display(POOLMEM *dst);       /* Get catalog information */
245 };
246
247 inline char *CAT::name() const { return hdr.name; }
248
249 class CLIENT_GLOBALS {
250 public:
251    dlink link;                        /* double link */
252    const char *name;                  /* resource name */
253    int32_t NumConcurrentJobs;         /* number of concurrent jobs running */
254    char *SetIPaddress;                /* address from SetIP command */
255    bool enabled;                      /* Enabled/disabled */
256 };
257
258 /*
259  *   Client Resource
260  *
261  */
262 class CLIENT {
263 public:
264    RES hdr;
265    CLIENT_GLOBALS *globals;           /* global variables */
266    uint32_t FDport;                   /* Where File daemon listens */
267    utime_t FileRetention;             /* file retention period in seconds */
268    utime_t JobRetention;              /* job retention period in seconds */
269    utime_t SnapRetention;             /* Snapshot retention period in seconds */
270    utime_t heartbeat_interval;        /* Interval to send heartbeats */
271    char *client_address;              /* Client address from .conf file */
272    char *fd_storage_address;          /* Storage address to use from FD side  */
273    char *password;
274    CAT *catalog;                      /* Catalog resource */
275    int32_t MaxConcurrentJobs;         /* Maximum concurrent jobs */
276    char *tls_ca_certfile;             /* TLS CA Certificate File */
277    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
278    char *tls_certfile;                /* TLS Client Certificate File */
279    char *tls_keyfile;                 /* TLS Client Key File */
280    alist *tls_allowed_cns;            /* TLS Allowed Clients */
281    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
282    bool tls_authenticate;             /* Authenticated with TLS */
283    bool tls_enable;                   /* Enable TLS */
284    bool tls_require;                  /* Require TLS */
285    bool Enabled;                      /* Set if client enabled */
286    bool AutoPrune;                    /* Do automatic pruning? */
287    bool sd_calls_client;              /* SD calls the client */
288    int64_t max_bandwidth;             /* Limit speed on this client */
289
290    /* Methods */
291    char *name() const;
292    void create_client_globals();
293    int32_t getNumConcurrentJobs();
294    void setNumConcurrentJobs(int32_t num);
295    char *address();
296    void setAddress(char *addr);
297    bool is_enabled();
298    void setEnabled(bool val);
299 };
300
301 inline char *CLIENT::name() const { return hdr.name; }
302
303
304 class STORE_GLOBALS {
305 public:
306    dlink link;                        /* double link */
307    const char *name;                  /* resource name */
308    int32_t NumConcurrentJobs;         /* number of concurrent jobs running */
309    int32_t NumConcurrentReadJobs;     /* number of concurrent read jobs running */
310    bool enabled;                      /* Enabled/disabled */
311 };
312
313
314 /*
315  *   Store Resource
316  *
317  */
318 class STORE {
319 public:
320    RES   hdr;
321    STORE_GLOBALS *globals;            /* global variables */
322    uint32_t SDport;                   /* port where Directors connect */
323    uint32_t SDDport;                  /* data port for File daemon */
324    char *address;
325    char *fd_storage_address;          /* Storage address to use from FD side  */
326    char *password;
327    char *media_type;
328    alist *device;                     /* Alternate devices for this Storage */
329    int32_t MaxConcurrentJobs;         /* Maximum concurrent jobs */
330    int32_t MaxConcurrentReadJobs;     /* Maximum concurrent jobs reading */
331    char *tls_ca_certfile;             /* TLS CA Certificate File */
332    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
333    char *tls_certfile;                /* TLS Client Certificate File */
334    char *tls_keyfile;                 /* TLS Client Key File */
335    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
336    bool tls_authenticate;             /* Authenticated with TLS */
337    bool tls_enable;                   /* Enable TLS */
338    bool tls_require;                  /* Require TLS */
339    bool Enabled;                      /* Set if device is enabled */
340    bool AllowCompress;                /* set if this Storage should allow jobs to enable compression */
341    bool autochanger;                  /* set if we are part of an autochanger */
342    POOLMEM *ac_group;                 /* Autochanger StorageId group */
343    STORE *changer;                    /* points to autochanger */
344    STORE *shared_storage;             /* points to shared storage */
345    int64_t StorageId;                 /* Set from Storage DB record */
346    utime_t heartbeat_interval;        /* Interval to send heartbeats */
347    uint32_t drives;                   /* number of drives in autochanger */
348
349    /* Methods */
350    char *dev_name() const;
351    char *name() const;
352    void create_store_globals();
353    int32_t getNumConcurrentJobs();
354    int32_t getNumConcurrentReadJobs();
355    void setNumConcurrentJobs(int32_t num);
356    void setNumConcurrentReadJobs(int32_t num);
357    bool is_enabled();
358    void setEnabled(bool val);
359 };
360
361 inline char *STORE::dev_name() const
362 {
363    DEVICE *dev = (DEVICE *)device->first();
364    return dev->name();
365 }
366
367 inline char *STORE::name() const { return hdr.name; }
368
369 /*
370  * This is a sort of "unified" store that has both the
371  *  storage pointer and the text of where the pointer was
372  *  found.
373  */
374 class USTORE {
375 public:
376    STORE *store;
377    POOLMEM *store_source;
378
379    /* Methods */
380    USTORE() { store = NULL; store_source = get_pool_memory(PM_MESSAGE);
381               *store_source = 0; };
382    ~USTORE() { destroy(); }
383    void set_source(const char *where);
384    void destroy();
385 };
386
387 inline void USTORE::destroy()
388 {
389    if (store_source) {
390       free_pool_memory(store_source);
391       store_source = NULL;
392    }
393 }
394
395
396 inline void USTORE::set_source(const char *where)
397 {
398    if (!store_source) {
399       store_source = get_pool_memory(PM_MESSAGE);
400    }
401    pm_strcpy(store_source, where);
402 }
403
404 class JOB_GLOBALS {
405 public:
406    dlink link;                        /* double link */
407    const char *name;                  /* resource name */
408    int32_t NumConcurrentJobs;         /* number of concurrent jobs running */
409    bool enabled;                      /* Enabled/disabled */
410 };
411
412 /*
413  *   Job Resource
414  */
415 class JOB {
416 public:
417    RES   hdr;
418    JOB_GLOBALS *globals;              /* global variables */
419    uint32_t JobType;                  /* job type (backup, verify, restore */
420    uint32_t JobLevel;                 /* default backup/verify level */
421    uint32_t RestoreJobId;             /* What -- JobId to restore */
422    uint32_t replace;                  /* How (overwrite, ..) */
423    uint32_t selection_type;
424
425    int32_t  Priority;                 /* Job priority */
426    int32_t  RescheduleTimes;          /* Number of times to reschedule job */
427
428    char *RestoreWhere;                /* Where on disk to restore -- directory */
429    char *RegexWhere;                  /* RegexWhere option */
430    char *strip_prefix;                /* remove prefix from filename  */
431    char *add_prefix;                  /* add prefix to filename  */
432    char *add_suffix;                  /* add suffix to filename -- .old */
433    char *RestoreBootstrap;            /* Bootstrap file */
434    char *PluginOptions;               /* Options to pass to plugin */
435    union {
436       char *WriteBootstrap;           /* Where to write bootstrap Job updates */
437       char *WriteVerifyList;          /* List of changed files */
438    };
439    utime_t MaxRunTime;                /* max run time in seconds */
440    utime_t MaxWaitTime;               /* max blocking time in seconds */
441    utime_t FullMaxRunTime;            /* Max Full job run time */
442    utime_t DiffMaxRunTime;            /* Max Differential job run time */
443    utime_t IncMaxRunTime;             /* Max Incremental job run time */
444    utime_t MaxStartDelay;             /* max start delay in seconds */
445    utime_t MaxRunSchedTime;           /* max run time in seconds from Scheduled time*/
446    utime_t RescheduleInterval;        /* Reschedule interval */
447    utime_t MaxFullInterval;           /* Maximum time interval between Fulls */
448    utime_t MaxVirtualFullInterval;    /* Maximum time interval between Virtual Fulls */
449    utime_t MaxDiffInterval;           /* Maximum time interval between Diffs */
450    utime_t DuplicateJobProximity;     /* Permitted time between duplicicates */
451    utime_t SnapRetention;             /* Snapshot retention period in seconds */
452    int64_t spool_size;                /* Size of spool file for this job */
453    int32_t MaxConcurrentJobs;         /* Maximum concurrent jobs */
454    uint32_t MaxSpawnedJobs;           /* Max Jobs that can be started by Migration/Copy */
455    uint32_t BackupsToKeep;            /* Number of backups to keep in Virtual Full */
456    bool allow_mixed_priority;         /* Allow jobs with higher priority concurrently with this */
457
458    MSGS      *messages;               /* How and where to send messages */
459    SCHED     *schedule;               /* When -- Automatic schedule */
460    CLIENT    *client;                 /* Who to backup */
461    FILESET   *fileset;                /* What to backup -- Fileset */
462    alist     *storage;                /* Where is device -- list of Storage to be used */
463    POOL      *pool;                   /* Where is media -- Media Pool */
464    POOL      *next_pool;              /* Next Pool for Copy/Migrate/VirtualFull */
465    POOL      *full_pool;              /* Pool for Full backups */
466    POOL      *vfull_pool;             /* Pool for Virtual Full backups */
467    POOL      *inc_pool;               /* Pool for Incremental backups */
468    POOL      *diff_pool;              /* Pool for Differental backups */
469    char      *selection_pattern;
470    union {
471       JOB    *verify_job;             /* Job name to verify */
472    };
473    JOB       *jobdefs;                /* Job defaults */
474    alist     *run_cmds;               /* Run commands */
475    alist *RunScripts;                 /* Run {client} program {after|before} Job */
476
477    bool where_use_regexp;             /* true if RestoreWhere is a BREGEXP */
478    bool RescheduleOnError;            /* Set to reschedule on error */
479    bool RescheduleIncompleteJobs;     /* Set to reschedule incomplete Jobs */
480    bool PrefixLinks;                  /* prefix soft links with Where path */
481    bool PruneJobs;                    /* Force pruning of Jobs */
482    bool PruneFiles;                   /* Force pruning of Files */
483    bool PruneVolumes;                 /* Force pruning of Volumes */
484    bool SpoolAttributes;              /* Set to spool attributes in SD */
485    bool spool_data;                   /* Set to spool data in SD */
486    bool rerun_failed_levels;          /* Upgrade to rerun failed levels */
487    bool PreferMountedVolumes;         /* Prefer vols mounted rather than new one */
488    bool write_part_after_job;         /* Set to write part after job in SD */
489    bool Enabled;                      /* Set if job enabled */
490    bool accurate;                     /* Set if it is an accurate backup job */
491    bool AllowDuplicateJobs;           /* Allow duplicate jobs */
492    bool AllowHigherDuplicates;        /* Permit Higher Level */
493    bool CancelLowerLevelDuplicates;   /* Cancel lower level backup jobs */
494    bool CancelQueuedDuplicates;       /* Cancel queued jobs */
495    bool CancelRunningDuplicates;      /* Cancel Running jobs */
496    bool PurgeMigrateJob;              /* Purges source job on completion */
497    bool DeleteConsolidatedJobs;       /* Delete or not consolidated Virtual Full jobs */
498
499    alist *base;                       /* Base jobs */
500    int64_t max_bandwidth;             /* Speed limit on this job */
501
502    /* Methods */
503    char *name() const;
504    void create_job_globals();
505    int32_t getNumConcurrentJobs();
506    void setNumConcurrentJobs(int32_t num);
507    bool is_enabled();
508    void setEnabled(bool val);
509 };
510
511 inline char *JOB::name() const { return hdr.name; }
512
513 /* Define FileSet Options keyword values */
514 enum {
515    INC_KW_NONE,
516    INC_KW_COMPRESSION,
517    INC_KW_DIGEST,
518    INC_KW_ENCRYPTION,
519    INC_KW_VERIFY,
520    INC_KW_BASEJOB,
521    INC_KW_ACCURATE,
522    INC_KW_ONEFS,
523    INC_KW_RECURSE,
524    INC_KW_SPARSE,
525    INC_KW_HARDLINK,
526    INC_KW_REPLACE,               /* restore options */
527    INC_KW_READFIFO,              /* Causes fifo data to be read */
528    INC_KW_PORTABLE,
529    INC_KW_MTIMEONLY,
530    INC_KW_KEEPATIME,
531    INC_KW_EXCLUDE,
532    INC_KW_ACL,
533    INC_KW_IGNORECASE,
534    INC_KW_HFSPLUS,
535    INC_KW_NOATIME,
536    INC_KW_ENHANCEDWILD,
537    INC_KW_CHKCHANGES,
538    INC_KW_STRIPPATH,
539    INC_KW_HONOR_NODUMP,
540    INC_KW_XATTR,
541    INC_KW_DEDUP,
542    INC_KW_MAX                   /* Keep this last */
543 };
544
545
546 #undef  MAX_FOPTS
547 #define MAX_FOPTS 50
548
549 /* File options structure */
550 struct FOPTS {
551    char opts[MAX_FOPTS];              /* options string */
552    alist regex;                       /* regex string(s) */
553    alist regexdir;                    /* regex string(s) for directories */
554    alist regexfile;                   /* regex string(s) for files */
555    alist wild;                        /* wild card strings */
556    alist wilddir;                     /* wild card strings for directories */
557    alist wildfile;                    /* wild card strings for files */
558    alist wildbase;                    /* wild card strings for files without '/' */
559    alist base;                        /* list of base names */
560    alist fstype;                      /* file system type limitation */
561    alist drivetype;                   /* drive type limitation */
562    char *reader;                      /* reader program */
563    char *writer;                      /* writer program */
564    char *plugin;                      /* plugin program */
565 };
566
567
568 /* This is either an include item or an exclude item */
569 struct INCEXE {
570    char  opt_present[INC_KW_MAX+1]; /* set if option is present in conf file */
571    FOPTS *current_opts;               /* points to current options structure */
572    FOPTS **opts_list;                 /* options list */
573    int32_t num_opts;                  /* number of options items */
574    alist name_list;                   /* filename list -- holds char * */
575    alist plugin_list;                 /* filename list for plugins */
576    char *ignoredir;                   /* ignoredir string */
577 };
578
579 /*
580  *   FileSet Resource
581  *
582  */
583 class FILESET {
584 public:
585    RES   hdr;
586
587    bool new_include;                  /* Set if new include used */
588    INCEXE **include_items;            /* array of incexe structures */
589    int32_t num_includes;              /* number in array */
590    INCEXE **exclude_items;
591    int32_t num_excludes;
592    bool have_MD5;                     /* set if MD5 initialized */
593    struct MD5Context md5c;            /* MD5 of include/exclude */
594    char MD5[30];                      /* base 64 representation of MD5 */
595    bool ignore_fs_changes;            /* Don't force Full if FS changed */
596    bool enable_vss;                   /* Enable Volume Shadow Copy */
597    bool enable_snapshot;              /* Enable Snapshot */
598
599    /* Methods */
600    char *name() const;
601 };
602
603 inline char *FILESET::name() const { return hdr.name; }
604
605 class SCHED_GLOBALS {
606 public:
607    dlink link;                        /* double link */
608    const char *name;                  /* resource name */
609    bool enabled;                      /* Enabled/disabled */
610 };
611
612 /*
613  *   Schedule Resource
614  */
615 class SCHED {
616 public:
617    RES   hdr;
618    SCHED_GLOBALS *globals;
619    RUN *run;
620    bool Enabled;                      /* set if enabled */
621
622    /* Methods */
623    char *name() const;
624    void create_sched_globals();
625    bool is_enabled();
626    void setEnabled(bool val);
627 };
628
629 inline char *SCHED::name() const { return hdr.name; }
630
631 /*
632  *   Counter Resource
633  */
634 class COUNTER {
635 public:
636    RES   hdr;
637
638    int32_t  MinValue;                 /* Minimum value */
639    int32_t  MaxValue;                 /* Maximum value */
640    int32_t  CurrentValue;             /* Current value */
641    COUNTER *WrapCounter;              /* Wrap counter name */
642    CAT     *Catalog;                  /* Where to store */
643    bool     created;                  /* Created in DB */
644
645    /* Methods */
646    char *name() const;
647 };
648
649 inline char *COUNTER::name() const { return hdr.name; }
650
651 /*
652  *   Pool Resource
653  *
654  */
655 class POOL {
656 public:
657    RES   hdr;
658
659    char *pool_type;                   /* Pool type */
660    char *label_format;                /* Label format string */
661    char *cleaning_prefix;             /* Cleaning label prefix */
662    int32_t LabelType;                 /* Bacula/ANSI/IBM label type */
663    uint32_t max_volumes;              /* max number of volumes */
664    utime_t VolRetention;              /* volume retention period in seconds */
665    utime_t CacheRetention;            /* cloud cache retention period in seconds */
666    utime_t VolUseDuration;            /* duration volume can be used */
667    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
668    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
669    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
670    utime_t MigrationTime;             /* Time to migrate to next pool */
671    uint64_t MigrationHighBytes;       /* When migration starts */
672    uint64_t MigrationLowBytes;        /* When migration stops */
673    POOL  *NextPool;                   /* Next pool for migration */
674    alist *storage;                    /* Where is device -- list of Storage to be used */
675    bool  use_catalog;                 /* maintain catalog for media */
676    bool  catalog_files;               /* maintain file entries in catalog */
677    bool  use_volume_once;             /* write on volume only once */
678    bool  purge_oldest_volume;         /* purge oldest volume */
679    bool  recycle_oldest_volume;       /* attempt to recycle oldest volume */
680    bool  recycle_current_volume;      /* attempt recycle of current volume */
681    bool  AutoPrune;                   /* default for pool auto prune */
682    bool  Recycle;                     /* default for media recycle yes/no */
683    uint32_t action_on_purge;          /* action on purge, e.g. truncate the disk volume */
684    POOL  *RecyclePool;                /* RecyclePool destination when media is purged */
685    POOL  *ScratchPool;                /* ScratchPool source when requesting media */
686    alist *CopyPool;                   /* List of copy pools */
687    CAT *catalog;                      /* Catalog to be used */
688    utime_t FileRetention;             /* file retention period in seconds */
689    utime_t JobRetention;              /* job retention period in seconds */
690
691    /* Methods */
692    char *name() const;
693 };
694
695 inline char *POOL::name() const { return hdr.name; }
696
697
698 /* Define the Union of all the above
699  * resource structure definitions.
700  */
701 union URES {
702    DIRRES     res_dir;
703    CONRES     res_con;
704    CLIENT     res_client;
705    STORE      res_store;
706    CAT        res_cat;
707    JOB        res_job;
708    FILESET    res_fs;
709    SCHED      res_sch;
710    POOL       res_pool;
711    MSGS       res_msgs;
712    COUNTER    res_counter;
713    DEVICE     res_dev;
714    RES        hdr;
715    RUNSCRIPT  res_runscript;
716 };
717
718
719
720 /* Run structure contained in Schedule Resource */
721 class RUN {
722 public:
723    RUN *next;                         /* points to next run record */
724    uint32_t level;                    /* level override */
725    int32_t Priority;                  /* priority override */
726    uint32_t job_type;
727    utime_t MaxRunSchedTime;           /* max run time in sec from Sched time */
728    bool MaxRunSchedTime_set;          /* MaxRunSchedTime given */
729    bool spool_data;                   /* Data spooling override */
730    bool spool_data_set;               /* Data spooling override given */
731    bool accurate;                     /* accurate */
732    bool accurate_set;                 /* accurate given */
733    bool write_part_after_job;         /* Write part after job override */
734    bool write_part_after_job_set;     /* Write part after job override given */
735    bool priority_set;                 /* priority override given */
736    bool level_set;                    /* level override given */
737
738    POOL *pool;                        /* Pool override */
739    POOL *next_pool;                   /* Next pool override */
740    POOL *full_pool;                   /* Pool override */
741    POOL *vfull_pool;                  /* Pool override */
742    POOL *inc_pool;                    /* Pool override */
743    POOL *diff_pool;                   /* Pool override */
744    STORE *storage;                    /* Storage override */
745    MSGS *msgs;                        /* Messages override */
746    char *since;
747    uint32_t level_no;
748    uint32_t minute;                   /* minute to run job */
749    time_t last_run;                   /* last time run */
750    time_t next_run;                   /* next time to run */
751    bool last_day_set;                 /* set if last_day is used */
752    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
753    char mday[nbytes_for_bits(32)];    /* bit set for each day of month */
754    char month[nbytes_for_bits(12)];   /* bit set for each month */
755    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
756    char wom[nbytes_for_bits(6)];      /* week of month */
757    char woy[nbytes_for_bits(54)];     /* week of year */
758 };
759
760 #define GetPoolResWithName(x) ((POOL *)GetResWithName(R_POOL, (x)))
761 #define GetStoreResWithName(x) ((STORE *)GetResWithName(R_STORAGE, (x)))
762 #define GetSchedResWithName(x) ((SCHED *)GetResWithName(R_SCHEDULE, (x)))
763 #define GetClientResWithName(x) ((CLIENT *)GetResWithName(R_CLIENT, (x)))
764 #define GetJobResWithName(x) ((JOB *)GetResWithName(R_JOB, (x)))
765 #define GetFileSetResWithName(x) ((FILESET *)GetResWithName(R_FILESET, (x)))
766 #define GetCatalogResWithName(x) ((CAT *)GetResWithName(R_CATALOG, (x)))
767
768 /* Imported subroutines */
769 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
770 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
771 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
772 void store_migtype(LEX *lc, RES_ITEM *item, int index, int pass);
773 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass);
774 void store_ac_res(LEX *lc, RES_ITEM *item, int index, int pass);
775 void store_device(LEX *lc, RES_ITEM *item, int index, int pass);
776 void store_actiononpurge(LEX *lc, RES_ITEM *item, int index, int pass);
777 void store_inc(LEX *lc, RES_ITEM *item, int index, int pass);
778 void store_regex(LEX *lc, RES_ITEM *item, int index, int pass);
779 void store_wild(LEX *lc, RES_ITEM *item, int index, int pass);
780 void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass);
781 void store_drivetype(LEX *lc, RES_ITEM *item, int index, int pass);
782 void store_opts(LEX *lc, RES_ITEM *item, int index, int pass);
783 void store_lopts(LEX *lc, RES_ITEM *item, int index, int pass);
784 void store_base(LEX *lc, RES_ITEM *item, int index, int pass);
785 void store_plugin(LEX *lc, RES_ITEM *item, int index, int pass);
786 void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
787 void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass);