2 Bacula(R) - The Network Backup Solution
4 Copyright (C) 2000-2017 Kern Sibbald
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.
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.
14 This notice must be preserved when any source code is
15 conveyed and/or propagated.
17 Bacula(R) is a registered trademark of Kern Sibbald.
20 * Director specific configuration and defines
22 * Kern Sibbald, Feb MM
25 /* NOTE: #includes at the end of this file */
28 * Resource codes -- they must be sequential for indexing
43 R_DEVICE, /* This is the real last device class */
45 R_AUTOCHANGER, /* Alias for R_STORAGE after R_LAST */
47 R_LAST = R_DEVICE /* keep this updated */
52 * Some resource attributes
62 /* Options for FileSet keywords */
69 /* Job Level keyword structure */
71 const char *level_name; /* level keyword */
72 int32_t level; /* level */
73 int32_t job_type; /* JobType permitting this level */
76 /* Job Type keyword structure */
78 const char *type_name;
82 /* Definition of the contents of each Resource */
83 /* Needed for forward references */
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 */
134 inline char *DIRRES::name() const { return hdr.name; }
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.
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 */
161 char ChangerName[MAX_NAME_LENGTH];
162 char VolumeName[MAX_NAME_LENGTH];
163 char MediaType[MAX_NAME_LENGTH];
169 inline char *DEVICE::name() const { return hdr.name; }
172 * Console ACL positions
188 Directory_ACL, /* List of directories that can be accessed in the restore tree */
189 Num_ACL /* keep last */
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 */
216 inline char *CONRES::name() const { return hdr.name; }
227 uint32_t db_port; /* Port */
228 char *db_address; /* host name for remote access */
229 char *db_socket; /* Socket for local access */
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 */
244 char *display(POOLMEM *dst); /* Get catalog information */
247 inline char *CAT::name() const { return hdr.name; }
249 class CLIENT_GLOBALS {
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 */
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 */
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 */
292 void create_client_globals();
293 int32_t getNumConcurrentJobs();
294 void setNumConcurrentJobs(int32_t num);
296 void setAddress(char *addr);
298 void setEnabled(bool val);
301 inline char *CLIENT::name() const { return hdr.name; }
304 class STORE_GLOBALS {
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 */
321 STORE_GLOBALS *globals; /* global variables */
322 uint32_t SDport; /* port where Directors connect */
323 uint32_t SDDport; /* data port for File daemon */
325 char *fd_storage_address; /* Storage address to use from FD side */
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 */
350 char *dev_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);
358 void setEnabled(bool val);
361 inline char *STORE::dev_name() const
363 DEVICE *dev = (DEVICE *)device->first();
367 inline char *STORE::name() const { return hdr.name; }
370 * This is a sort of "unified" store that has both the
371 * storage pointer and the text of where the pointer was
377 POOLMEM *store_source;
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);
387 inline void USTORE::destroy()
390 free_pool_memory(store_source);
396 inline void USTORE::set_source(const char *where)
399 store_source = get_pool_memory(PM_MESSAGE);
401 pm_strcpy(store_source, where);
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 */
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;
425 int32_t Priority; /* Job priority */
426 int32_t RescheduleTimes; /* Number of times to reschedule job */
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 */
436 char *WriteBootstrap; /* Where to write bootstrap Job updates */
437 char *WriteVerifyList; /* List of changed files */
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 */
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;
471 JOB *verify_job; /* Job name to verify */
473 JOB *jobdefs; /* Job defaults */
474 alist *run_cmds; /* Run commands */
475 alist *RunScripts; /* Run {client} program {after|before} Job */
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 */
499 alist *base; /* Base jobs */
500 int64_t max_bandwidth; /* Speed limit on this job */
504 void create_job_globals();
505 int32_t getNumConcurrentJobs();
506 void setNumConcurrentJobs(int32_t num);
508 void setEnabled(bool val);
511 inline char *JOB::name() const { return hdr.name; }
513 /* Define FileSet Options keyword values */
526 INC_KW_REPLACE, /* restore options */
527 INC_KW_READFIFO, /* Causes fifo data to be read */
542 INC_KW_MAX /* Keep this last */
549 /* File options structure */
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 */
568 /* This is either an include item or an exclude item */
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 */
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 */
603 inline char *FILESET::name() const { return hdr.name; }
605 class SCHED_GLOBALS {
607 dlink link; /* double link */
608 const char *name; /* resource name */
609 bool enabled; /* Enabled/disabled */
618 SCHED_GLOBALS *globals;
620 bool Enabled; /* set if enabled */
624 void create_sched_globals();
626 void setEnabled(bool val);
629 inline char *SCHED::name() const { return hdr.name; }
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 */
649 inline char *COUNTER::name() const { return hdr.name; }
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 */
695 inline char *POOL::name() const { return hdr.name; }
698 /* Define the Union of all the above
699 * resource structure definitions.
715 RUNSCRIPT res_runscript;
720 /* Run structure contained in Schedule Resource */
723 RUN *next; /* points to next run record */
724 uint32_t level; /* level override */
725 int32_t Priority; /* priority override */
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 */
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 */
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 */
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)))
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);