]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
dce2e9abfb347e12896d1982dd2b486caf69fe98
[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_mode;                 /* specifies the security state of the connection to the server */
235    char *db_ssl_key;                  /* the path name to the key file */
236    char *db_ssl_cert;                 /* the path name to the certificate file */
237    char *db_ssl_ca;                   /* the path name to the certificate authority file */
238    char *db_ssl_capath;               /* the path name to a directory that contains trusted SSL CA certificates in PEM format */
239    char *db_ssl_cipher;               /* a list of permissible ciphers to use for SSL encryption */
240    uint32_t mult_db_connections;      /* set for multiple db connections */
241    bool disable_batch_insert;         /* set to disable batch inserts */
242
243    /* Methods */
244    char *name() const;
245    char *display(POOLMEM *dst);       /* Get catalog information */
246 };
247
248 inline char *CAT::name() const { return hdr.name; }
249
250 class CLIENT_GLOBALS {
251 public:
252    dlink link;                        /* double link */
253    const char *name;                  /* resource name */
254    int32_t NumConcurrentJobs;         /* number of concurrent jobs running */
255    char *SetIPaddress;                /* address from SetIP command */
256    bool enabled;                      /* Enabled/disabled */
257 };
258
259 /*
260  *   Client Resource
261  *
262  */
263 class CLIENT {
264 public:
265    RES hdr;
266    CLIENT_GLOBALS *globals;           /* global variables */
267    uint32_t FDport;                   /* Where File daemon listens */
268    utime_t FileRetention;             /* file retention period in seconds */
269    utime_t JobRetention;              /* job retention period in seconds */
270    utime_t SnapRetention;             /* Snapshot retention period in seconds */
271    utime_t heartbeat_interval;        /* Interval to send heartbeats */
272    char *client_address;              /* Client address from .conf file */
273    char *fd_storage_address;          /* Storage address to use from FD side  */
274    char *password;
275    CAT *catalog;                      /* Catalog resource */
276    int32_t MaxConcurrentJobs;         /* Maximum concurrent jobs */
277    char *tls_ca_certfile;             /* TLS CA Certificate File */
278    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
279    char *tls_certfile;                /* TLS Client Certificate File */
280    char *tls_keyfile;                 /* TLS Client Key File */
281    alist *tls_allowed_cns;            /* TLS Allowed Clients */
282    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
283    bool tls_authenticate;             /* Authenticated with TLS */
284    bool tls_enable;                   /* Enable TLS */
285    bool tls_require;                  /* Require TLS */
286    bool Enabled;                      /* Set if client enabled */
287    bool AutoPrune;                    /* Do automatic pruning? */
288    bool sd_calls_client;              /* SD calls the client */
289    int64_t max_bandwidth;             /* Limit speed on this client */
290
291    /* Methods */
292    char *name() const;
293    void create_client_globals();
294    int32_t getNumConcurrentJobs();
295    void setNumConcurrentJobs(int32_t num);
296    char *address();
297    void setAddress(char *addr);
298    bool is_enabled();
299    void setEnabled(bool val);
300 };
301
302 inline char *CLIENT::name() const { return hdr.name; }
303
304
305 class STORE_GLOBALS {
306 public:
307    dlink link;                        /* double link */
308    const char *name;                  /* resource name */
309    int32_t NumConcurrentJobs;         /* number of concurrent jobs running */
310    int32_t NumConcurrentReadJobs;     /* number of concurrent read jobs running */
311    bool enabled;                      /* Enabled/disabled */
312 };
313
314
315 /*
316  *   Store Resource
317  *
318  */
319 class STORE {
320 public:
321    RES   hdr;
322    STORE_GLOBALS *globals;            /* global variables */
323    uint32_t SDport;                   /* port where Directors connect */
324    uint32_t SDDport;                  /* data port for File daemon */
325    char *address;
326    char *fd_storage_address;          /* Storage address to use from FD side  */
327    char *password;
328    char *media_type;
329    alist *device;                     /* Alternate devices for this Storage */
330    int32_t MaxConcurrentJobs;         /* Maximum concurrent jobs */
331    int32_t MaxConcurrentReadJobs;     /* Maximum concurrent jobs reading */
332    char *tls_ca_certfile;             /* TLS CA Certificate File */
333    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
334    char *tls_certfile;                /* TLS Client Certificate File */
335    char *tls_keyfile;                 /* TLS Client Key File */
336    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
337    bool tls_authenticate;             /* Authenticated with TLS */
338    bool tls_enable;                   /* Enable TLS */
339    bool tls_require;                  /* Require TLS */
340    bool Enabled;                      /* Set if device is enabled */
341    bool AllowCompress;                /* set if this Storage should allow jobs to enable compression */
342    bool autochanger;                  /* set if we are part of an autochanger */
343    POOLMEM *ac_group;                 /* Autochanger StorageId group */
344    STORE *changer;                    /* points to autochanger */
345    STORE *shared_storage;             /* points to shared storage */
346    int64_t StorageId;                 /* Set from Storage DB record */
347    utime_t heartbeat_interval;        /* Interval to send heartbeats */
348    uint32_t drives;                   /* number of drives in autochanger */
349
350    /* Methods */
351    char *dev_name() const;
352    char *name() const;
353    void create_store_globals();
354    int32_t getNumConcurrentJobs();
355    int32_t getNumConcurrentReadJobs();
356    void setNumConcurrentJobs(int32_t num);
357    void setNumConcurrentReadJobs(int32_t num);
358    bool is_enabled();
359    void setEnabled(bool val);
360 };
361
362 inline char *STORE::dev_name() const
363 {
364    DEVICE *dev = (DEVICE *)device->first();
365    return dev->name();
366 }
367
368 inline char *STORE::name() const { return hdr.name; }
369
370 /*
371  * This is a sort of "unified" store that has both the
372  *  storage pointer and the text of where the pointer was
373  *  found.
374  */
375 class USTORE {
376 public:
377    STORE *store;
378    POOLMEM *store_source;
379
380    /* Methods */
381    USTORE() { store = NULL; store_source = get_pool_memory(PM_MESSAGE);
382               *store_source = 0; };
383    ~USTORE() { destroy(); }
384    void set_source(const char *where);
385    void destroy();
386 };
387
388 inline void USTORE::destroy()
389 {
390    if (store_source) {
391       free_pool_memory(store_source);
392       store_source = NULL;
393    }
394 }
395
396
397 inline void USTORE::set_source(const char *where)
398 {
399    if (!store_source) {
400       store_source = get_pool_memory(PM_MESSAGE);
401    }
402    pm_strcpy(store_source, where);
403 }
404
405 class JOB_GLOBALS {
406 public:
407    dlink link;                        /* double link */
408    const char *name;                  /* resource name */
409    int32_t NumConcurrentJobs;         /* number of concurrent jobs running */
410    bool enabled;                      /* Enabled/disabled */
411 };
412
413 /*
414  *   Job Resource
415  */
416 class JOB {
417 public:
418    RES   hdr;
419    JOB_GLOBALS *globals;              /* global variables */
420    uint32_t JobType;                  /* job type (backup, verify, restore */
421    uint32_t JobLevel;                 /* default backup/verify level */
422    uint32_t RestoreJobId;             /* What -- JobId to restore */
423    uint32_t replace;                  /* How (overwrite, ..) */
424    uint32_t selection_type;
425
426    int32_t  Priority;                 /* Job priority */
427    int32_t  RescheduleTimes;          /* Number of times to reschedule job */
428
429    char *RestoreWhere;                /* Where on disk to restore -- directory */
430    char *RegexWhere;                  /* RegexWhere option */
431    char *strip_prefix;                /* remove prefix from filename  */
432    char *add_prefix;                  /* add prefix to filename  */
433    char *add_suffix;                  /* add suffix to filename -- .old */
434    char *RestoreBootstrap;            /* Bootstrap file */
435    char *PluginOptions;               /* Options to pass to plugin */
436    union {
437       char *WriteBootstrap;           /* Where to write bootstrap Job updates */
438       char *WriteVerifyList;          /* List of changed files */
439    };
440    utime_t MaxRunTime;                /* max run time in seconds */
441    utime_t MaxWaitTime;               /* max blocking time in seconds */
442    utime_t FullMaxRunTime;            /* Max Full job run time */
443    utime_t DiffMaxRunTime;            /* Max Differential job run time */
444    utime_t IncMaxRunTime;             /* Max Incremental job run time */
445    utime_t MaxStartDelay;             /* max start delay in seconds */
446    utime_t MaxRunSchedTime;           /* max run time in seconds from Scheduled time*/
447    utime_t RescheduleInterval;        /* Reschedule interval */
448    utime_t MaxFullInterval;           /* Maximum time interval between Fulls */
449    utime_t MaxVirtualFullInterval;    /* Maximum time interval between Virtual Fulls */
450    utime_t MaxDiffInterval;           /* Maximum time interval between Diffs */
451    utime_t DuplicateJobProximity;     /* Permitted time between duplicicates */
452    utime_t SnapRetention;             /* Snapshot retention period in seconds */
453    int64_t spool_size;                /* Size of spool file for this job */
454    int32_t MaxConcurrentJobs;         /* Maximum concurrent jobs */
455    uint32_t MaxSpawnedJobs;           /* Max Jobs that can be started by Migration/Copy */
456    uint32_t BackupsToKeep;            /* Number of backups to keep in Virtual Full */
457    bool allow_mixed_priority;         /* Allow jobs with higher priority concurrently with this */
458
459    MSGS      *messages;               /* How and where to send messages */
460    SCHED     *schedule;               /* When -- Automatic schedule */
461    CLIENT    *client;                 /* Who to backup */
462    FILESET   *fileset;                /* What to backup -- Fileset */
463    alist     *storage;                /* Where is device -- list of Storage to be used */
464    POOL      *pool;                   /* Where is media -- Media Pool */
465    POOL      *next_pool;              /* Next Pool for Copy/Migrate/VirtualFull */
466    POOL      *full_pool;              /* Pool for Full backups */
467    POOL      *vfull_pool;             /* Pool for Virtual Full backups */
468    POOL      *inc_pool;               /* Pool for Incremental backups */
469    POOL      *diff_pool;              /* Pool for Differental backups */
470    char      *selection_pattern;
471    union {
472       JOB    *verify_job;             /* Job name to verify */
473    };
474    JOB       *jobdefs;                /* Job defaults */
475    alist     *run_cmds;               /* Run commands */
476    alist *RunScripts;                 /* Run {client} program {after|before} Job */
477
478    bool where_use_regexp;             /* true if RestoreWhere is a BREGEXP */
479    bool RescheduleOnError;            /* Set to reschedule on error */
480    bool RescheduleIncompleteJobs;     /* Set to reschedule incomplete Jobs */
481    bool PrefixLinks;                  /* prefix soft links with Where path */
482    bool PruneJobs;                    /* Force pruning of Jobs */
483    bool PruneFiles;                   /* Force pruning of Files */
484    bool PruneVolumes;                 /* Force pruning of Volumes */
485    bool SpoolAttributes;              /* Set to spool attributes in SD */
486    bool spool_data;                   /* Set to spool data in SD */
487    bool rerun_failed_levels;          /* Upgrade to rerun failed levels */
488    bool PreferMountedVolumes;         /* Prefer vols mounted rather than new one */
489    bool write_part_after_job;         /* Set to write part after job in SD */
490    bool Enabled;                      /* Set if job enabled */
491    bool accurate;                     /* Set if it is an accurate backup job */
492    bool AllowDuplicateJobs;           /* Allow duplicate jobs */
493    bool AllowHigherDuplicates;        /* Permit Higher Level */
494    bool CancelLowerLevelDuplicates;   /* Cancel lower level backup jobs */
495    bool CancelQueuedDuplicates;       /* Cancel queued jobs */
496    bool CancelRunningDuplicates;      /* Cancel Running jobs */
497    bool PurgeMigrateJob;              /* Purges source job on completion */
498    bool DeleteConsolidatedJobs;       /* Delete or not consolidated Virtual Full jobs */
499
500    alist *base;                       /* Base jobs */
501    int64_t max_bandwidth;             /* Speed limit on this job */
502
503    /* Methods */
504    char *name() const;
505    void create_job_globals();
506    int32_t getNumConcurrentJobs();
507    void setNumConcurrentJobs(int32_t num);
508    bool is_enabled();
509    void setEnabled(bool val);
510 };
511
512 inline char *JOB::name() const { return hdr.name; }
513
514 /* Define FileSet Options keyword values */
515 enum {
516    INC_KW_NONE,
517    INC_KW_COMPRESSION,
518    INC_KW_DIGEST,
519    INC_KW_ENCRYPTION,
520    INC_KW_VERIFY,
521    INC_KW_BASEJOB,
522    INC_KW_ACCURATE,
523    INC_KW_ONEFS,
524    INC_KW_RECURSE,
525    INC_KW_SPARSE,
526    INC_KW_HARDLINK,
527    INC_KW_REPLACE,               /* restore options */
528    INC_KW_READFIFO,              /* Causes fifo data to be read */
529    INC_KW_PORTABLE,
530    INC_KW_MTIMEONLY,
531    INC_KW_KEEPATIME,
532    INC_KW_EXCLUDE,
533    INC_KW_ACL,
534    INC_KW_IGNORECASE,
535    INC_KW_HFSPLUS,
536    INC_KW_NOATIME,
537    INC_KW_ENHANCEDWILD,
538    INC_KW_CHKCHANGES,
539    INC_KW_STRIPPATH,
540    INC_KW_HONOR_NODUMP,
541    INC_KW_XATTR,
542    INC_KW_DEDUP,
543    INC_KW_MAX                   /* Keep this last */
544 };
545
546
547 #undef  MAX_FOPTS
548 #define MAX_FOPTS 50
549
550 /* File options structure */
551 struct FOPTS {
552    char opts[MAX_FOPTS];              /* options string */
553    alist regex;                       /* regex string(s) */
554    alist regexdir;                    /* regex string(s) for directories */
555    alist regexfile;                   /* regex string(s) for files */
556    alist wild;                        /* wild card strings */
557    alist wilddir;                     /* wild card strings for directories */
558    alist wildfile;                    /* wild card strings for files */
559    alist wildbase;                    /* wild card strings for files without '/' */
560    alist base;                        /* list of base names */
561    alist fstype;                      /* file system type limitation */
562    alist drivetype;                   /* drive type limitation */
563    char *reader;                      /* reader program */
564    char *writer;                      /* writer program */
565    char *plugin;                      /* plugin program */
566 };
567
568
569 /* This is either an include item or an exclude item */
570 struct INCEXE {
571    char  opt_present[INC_KW_MAX+1]; /* set if option is present in conf file */
572    FOPTS *current_opts;               /* points to current options structure */
573    FOPTS **opts_list;                 /* options list */
574    int32_t num_opts;                  /* number of options items */
575    alist name_list;                   /* filename list -- holds char * */
576    alist plugin_list;                 /* filename list for plugins */
577    char *ignoredir;                   /* ignoredir string */
578 };
579
580 /*
581  *   FileSet Resource
582  *
583  */
584 class FILESET {
585 public:
586    RES   hdr;
587
588    bool new_include;                  /* Set if new include used */
589    INCEXE **include_items;            /* array of incexe structures */
590    int32_t num_includes;              /* number in array */
591    INCEXE **exclude_items;
592    int32_t num_excludes;
593    bool have_MD5;                     /* set if MD5 initialized */
594    struct MD5Context md5c;            /* MD5 of include/exclude */
595    char MD5[30];                      /* base 64 representation of MD5 */
596    bool ignore_fs_changes;            /* Don't force Full if FS changed */
597    bool enable_vss;                   /* Enable Volume Shadow Copy */
598    bool enable_snapshot;              /* Enable Snapshot */
599
600    /* Methods */
601    char *name() const;
602 };
603
604 inline char *FILESET::name() const { return hdr.name; }
605
606 class SCHED_GLOBALS {
607 public:
608    dlink link;                        /* double link */
609    const char *name;                  /* resource name */
610    bool enabled;                      /* Enabled/disabled */
611 };
612
613 /*
614  *   Schedule Resource
615  */
616 class SCHED {
617 public:
618    RES   hdr;
619    SCHED_GLOBALS *globals;
620    RUN *run;
621    bool Enabled;                      /* set if enabled */
622
623    /* Methods */
624    char *name() const;
625    void create_sched_globals();
626    bool is_enabled();
627    void setEnabled(bool val);
628 };
629
630 inline char *SCHED::name() const { return hdr.name; }
631
632 /*
633  *   Counter Resource
634  */
635 class COUNTER {
636 public:
637    RES   hdr;
638
639    int32_t  MinValue;                 /* Minimum value */
640    int32_t  MaxValue;                 /* Maximum value */
641    int32_t  CurrentValue;             /* Current value */
642    COUNTER *WrapCounter;              /* Wrap counter name */
643    CAT     *Catalog;                  /* Where to store */
644    bool     created;                  /* Created in DB */
645
646    /* Methods */
647    char *name() const;
648 };
649
650 inline char *COUNTER::name() const { return hdr.name; }
651
652 /*
653  *   Pool Resource
654  *
655  */
656 class POOL {
657 public:
658    RES   hdr;
659
660    char *pool_type;                   /* Pool type */
661    char *label_format;                /* Label format string */
662    char *cleaning_prefix;             /* Cleaning label prefix */
663    int32_t LabelType;                 /* Bacula/ANSI/IBM label type */
664    uint32_t max_volumes;              /* max number of volumes */
665    utime_t VolRetention;              /* volume retention period in seconds */
666    utime_t CacheRetention;            /* cloud cache retention period in seconds */
667    utime_t VolUseDuration;            /* duration volume can be used */
668    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
669    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
670    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
671    utime_t MigrationTime;             /* Time to migrate to next pool */
672    uint64_t MigrationHighBytes;       /* When migration starts */
673    uint64_t MigrationLowBytes;        /* When migration stops */
674    POOL  *NextPool;                   /* Next pool for migration */
675    alist *storage;                    /* Where is device -- list of Storage to be used */
676    bool  use_catalog;                 /* maintain catalog for media */
677    bool  catalog_files;               /* maintain file entries in catalog */
678    bool  use_volume_once;             /* write on volume only once */
679    bool  purge_oldest_volume;         /* purge oldest volume */
680    bool  recycle_oldest_volume;       /* attempt to recycle oldest volume */
681    bool  recycle_current_volume;      /* attempt recycle of current volume */
682    bool  AutoPrune;                   /* default for pool auto prune */
683    bool  Recycle;                     /* default for media recycle yes/no */
684    uint32_t action_on_purge;          /* action on purge, e.g. truncate the disk volume */
685    POOL  *RecyclePool;                /* RecyclePool destination when media is purged */
686    POOL  *ScratchPool;                /* ScratchPool source when requesting media */
687    alist *CopyPool;                   /* List of copy pools */
688    CAT *catalog;                      /* Catalog to be used */
689    utime_t FileRetention;             /* file retention period in seconds */
690    utime_t JobRetention;              /* job retention period in seconds */
691
692    /* Methods */
693    char *name() const;
694 };
695
696 inline char *POOL::name() const { return hdr.name; }
697
698
699 /* Define the Union of all the above
700  * resource structure definitions.
701  */
702 union URES {
703    DIRRES     res_dir;
704    CONRES     res_con;
705    CLIENT     res_client;
706    STORE      res_store;
707    CAT        res_cat;
708    JOB        res_job;
709    FILESET    res_fs;
710    SCHED      res_sch;
711    POOL       res_pool;
712    MSGS       res_msgs;
713    COUNTER    res_counter;
714    DEVICE     res_dev;
715    RES        hdr;
716    RUNSCRIPT  res_runscript;
717 };
718
719
720
721 /* Run structure contained in Schedule Resource */
722 class RUN {
723 public:
724    RUN *next;                         /* points to next run record */
725    uint32_t level;                    /* level override */
726    int32_t Priority;                  /* priority override */
727    uint32_t job_type;
728    utime_t MaxRunSchedTime;           /* max run time in sec from Sched time */
729    bool MaxRunSchedTime_set;          /* MaxRunSchedTime given */
730    bool spool_data;                   /* Data spooling override */
731    bool spool_data_set;               /* Data spooling override given */
732    bool accurate;                     /* accurate */
733    bool accurate_set;                 /* accurate given */
734    bool write_part_after_job;         /* Write part after job override */
735    bool write_part_after_job_set;     /* Write part after job override given */
736    bool priority_set;                 /* priority override given */
737    bool level_set;                    /* level override given */
738
739    POOL *pool;                        /* Pool override */
740    POOL *next_pool;                   /* Next pool override */
741    POOL *full_pool;                   /* Pool override */
742    POOL *vfull_pool;                  /* Pool override */
743    POOL *inc_pool;                    /* Pool override */
744    POOL *diff_pool;                   /* Pool override */
745    STORE *storage;                    /* Storage override */
746    MSGS *msgs;                        /* Messages override */
747    char *since;
748    uint32_t level_no;
749    uint32_t minute;                   /* minute to run job */
750    time_t last_run;                   /* last time run */
751    time_t next_run;                   /* next time to run */
752    bool last_day_set;                 /* set if last_day is used */
753    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
754    char mday[nbytes_for_bits(32)];    /* bit set for each day of month */
755    char month[nbytes_for_bits(12)];   /* bit set for each month */
756    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
757    char wom[nbytes_for_bits(6)];      /* week of month */
758    char woy[nbytes_for_bits(54)];     /* week of year */
759 };
760
761 #define GetPoolResWithName(x) ((POOL *)GetResWithName(R_POOL, (x)))
762 #define GetStoreResWithName(x) ((STORE *)GetResWithName(R_STORAGE, (x)))
763 #define GetSchedResWithName(x) ((SCHED *)GetResWithName(R_SCHEDULE, (x)))
764 #define GetClientResWithName(x) ((CLIENT *)GetResWithName(R_CLIENT, (x)))
765 #define GetJobResWithName(x) ((JOB *)GetResWithName(R_JOB, (x)))
766 #define GetFileSetResWithName(x) ((FILESET *)GetResWithName(R_FILESET, (x)))
767 #define GetCatalogResWithName(x) ((CAT *)GetResWithName(R_CATALOG, (x)))
768
769 /* Imported subroutines */
770 void store_jobtype(LEX *lc, RES_ITEM *item, int index, int pass);
771 void store_level(LEX *lc, RES_ITEM *item, int index, int pass);
772 void store_replace(LEX *lc, RES_ITEM *item, int index, int pass);
773 void store_migtype(LEX *lc, RES_ITEM *item, int index, int pass);
774 void store_acl(LEX *lc, RES_ITEM *item, int index, int pass);
775 void store_ac_res(LEX *lc, RES_ITEM *item, int index, int pass);
776 void store_device(LEX *lc, RES_ITEM *item, int index, int pass);
777 void store_actiononpurge(LEX *lc, RES_ITEM *item, int index, int pass);
778 void store_inc(LEX *lc, RES_ITEM *item, int index, int pass);
779 void store_regex(LEX *lc, RES_ITEM *item, int index, int pass);
780 void store_wild(LEX *lc, RES_ITEM *item, int index, int pass);
781 void store_fstype(LEX *lc, RES_ITEM *item, int index, int pass);
782 void store_drivetype(LEX *lc, RES_ITEM *item, int index, int pass);
783 void store_opts(LEX *lc, RES_ITEM *item, int index, int pass);
784 void store_lopts(LEX *lc, RES_ITEM *item, int index, int pass);
785 void store_base(LEX *lc, RES_ITEM *item, int index, int pass);
786 void store_plugin(LEX *lc, RES_ITEM *item, int index, int pass);
787 void store_run(LEX *lc, RES_ITEM *item, int index, int pass);
788 void store_runscript(LEX *lc, RES_ITEM *item, int index, int pass);