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_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 */
245 char *display(POOLMEM *dst); /* Get catalog information */
248 inline char *CAT::name() const { return hdr.name; }
250 class CLIENT_GLOBALS {
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 */
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 */
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 */
293 void create_client_globals();
294 int32_t getNumConcurrentJobs();
295 void setNumConcurrentJobs(int32_t num);
297 void setAddress(char *addr);
299 void setEnabled(bool val);
302 inline char *CLIENT::name() const { return hdr.name; }
305 class STORE_GLOBALS {
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 */
322 STORE_GLOBALS *globals; /* global variables */
323 uint32_t SDport; /* port where Directors connect */
324 uint32_t SDDport; /* data port for File daemon */
326 char *fd_storage_address; /* Storage address to use from FD side */
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 */
351 char *dev_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);
359 void setEnabled(bool val);
362 inline char *STORE::dev_name() const
364 DEVICE *dev = (DEVICE *)device->first();
368 inline char *STORE::name() const { return hdr.name; }
371 * This is a sort of "unified" store that has both the
372 * storage pointer and the text of where the pointer was
378 POOLMEM *store_source;
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);
388 inline void USTORE::destroy()
391 free_pool_memory(store_source);
397 inline void USTORE::set_source(const char *where)
400 store_source = get_pool_memory(PM_MESSAGE);
402 pm_strcpy(store_source, where);
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 */
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;
426 int32_t Priority; /* Job priority */
427 int32_t RescheduleTimes; /* Number of times to reschedule job */
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 */
437 char *WriteBootstrap; /* Where to write bootstrap Job updates */
438 char *WriteVerifyList; /* List of changed files */
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 */
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;
472 JOB *verify_job; /* Job name to verify */
474 JOB *jobdefs; /* Job defaults */
475 alist *run_cmds; /* Run commands */
476 alist *RunScripts; /* Run {client} program {after|before} Job */
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 */
500 alist *base; /* Base jobs */
501 int64_t max_bandwidth; /* Speed limit on this job */
505 void create_job_globals();
506 int32_t getNumConcurrentJobs();
507 void setNumConcurrentJobs(int32_t num);
509 void setEnabled(bool val);
512 inline char *JOB::name() const { return hdr.name; }
514 /* Define FileSet Options keyword values */
527 INC_KW_REPLACE, /* restore options */
528 INC_KW_READFIFO, /* Causes fifo data to be read */
543 INC_KW_MAX /* Keep this last */
550 /* File options structure */
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 */
569 /* This is either an include item or an exclude item */
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 */
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 */
604 inline char *FILESET::name() const { return hdr.name; }
606 class SCHED_GLOBALS {
608 dlink link; /* double link */
609 const char *name; /* resource name */
610 bool enabled; /* Enabled/disabled */
619 SCHED_GLOBALS *globals;
621 bool Enabled; /* set if enabled */
625 void create_sched_globals();
627 void setEnabled(bool val);
630 inline char *SCHED::name() const { return hdr.name; }
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 */
650 inline char *COUNTER::name() const { return hdr.name; }
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 */
696 inline char *POOL::name() const { return hdr.name; }
699 /* Define the Union of all the above
700 * resource structure definitions.
716 RUNSCRIPT res_runscript;
721 /* Run structure contained in Schedule Resource */
724 RUN *next; /* points to next run record */
725 uint32_t level; /* level override */
726 int32_t Priority; /* priority override */
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 */
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 */
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 */
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)))
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);