1 /*
2 BAREOS® - Backup Archiving REcovery Open Sourced
3
4 Copyright (C) 2000-2011 Free Software Foundation Europe e.V.
5 Copyright (C) 2011-2012 Planets Communications B.V.
6 Copyright (C) 2013-2018 Bareos GmbH & Co. KG
7
8 This program is Free Software; you can redistribute it and/or
9 modify it under the terms of version three of the GNU Affero General Public
10 License as published by the Free Software Foundation and included
11 in the file LICENSE.
12
13 This program is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 Affero General Public License for more details.
17
18 You should have received a copy of the GNU Affero General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 02110-1301, USA.
22 */
23 /*
24 * Kern Sibbald, Feb MM
25 */
26 /**
27 * @file
28 * Director specific configuration and defines
29 */
30 #ifndef BAREOS_DIRD_DIRD_CONF_H_
31 #define BAREOS_DIRD_DIRD_CONF_H_
32 /* NOTE: #includes at the end of this file */
33
34 #include "dird/client_connection_handshake_mode.h"
35
36 namespace directordaemon {
37
38 static std::string default_config_filename("bareos-dir.conf");
39
40 /**
41 * Resource codes -- they must be sequential for indexing
42 */
43 enum {
44 R_DIRECTOR = 1001,
45 R_CLIENT,
46 R_JOBDEFS,
47 R_JOB,
48 R_STORAGE,
49 R_CATALOG,
50 R_SCHEDULE,
51 R_FILESET,
52 R_POOL,
53 R_MSGS,
54 R_COUNTER,
55 R_PROFILE,
56 R_CONSOLE,
57 R_DEVICE,
58 R_FIRST = R_DIRECTOR,
59 R_LAST = R_DEVICE /* keep this updated */
60 };
61
62 /**
63 * Some resource attributes
64 */
65 enum {
66 R_NAME = 1020,
67 R_ADDRESS,
68 R_PASSWORD,
69 R_TYPE,
70 R_BACKUP
71 };
72
73 /**
74 * Job Level keyword structure
75 */
76 struct s_jl {
77 const char *level_name; /* level keyword */
78 uint32_t level; /* level */
79 int32_t job_type; /* JobType permitting this level */
80 };
81
82 /**
83 * Job Type keyword structure
84 */
85 struct s_jt {
86 const char *type_name;
87 int32_t job_type;
88 };
89
90 /**
91 * Definition of the contents of each Resource
92 * Needed for forward references
93 */
94 class ScheduleResource;
95 class ClientResource;
96 class FilesetResource;
97 class PoolResource;
98 class RunResource;
99 class DeviceResource;
100 class RunScriptResource;
101
102 /*
103 * Print configuration file schema in json format
104 */
105 bool PrintConfigSchemaJson(PoolMem &buff);
106
107 /*
108 * Director Resource
109 */
110 class DirectorResource: public TlsResource {
111 public:
112 dlist *DIRaddrs;
113 dlist *DIRsrc_addr; /* Address to source connections from */
114 char *query_file; /* SQL query file */
115 char *working_directory; /* WorkingDirectory */
116 char *scripts_directory; /* ScriptsDirectory */
117 char *plugin_directory; /* Plugin Directory */
118 alist *plugin_names; /* Plugin names to load */
119 char *pid_directory; /* PidDirectory */
120 char *subsys_directory; /* SubsysDirectory */
121 alist *backend_directories; /* Backend Directories */
122 MessagesResource *messages; /* Daemon message handler */
123 uint32_t MaxConcurrentJobs; /* Max concurrent jobs for whole director */
124 uint32_t MaxConnections; /* Max concurrent connections */
125 uint32_t MaxConsoleConnections; /* Max concurrent console connections */
126 utime_t FDConnectTimeout; /* Timeout for connect in seconds */
127 utime_t SDConnectTimeout; /* Timeout for connect in seconds */
128 utime_t heartbeat_interval; /* Interval to send heartbeats */
129 utime_t stats_retention; /* Statistics retention period in seconds */
130 bool optimize_for_size; /* Optimize daemon for minimum memory size */
131 bool optimize_for_speed; /* Optimize daemon for speed which may need more memory */
132 bool nokeepalive; /* Don't use SO_KEEPALIVE on sockets */
133 bool omit_defaults; /* Omit config variables with default values when dumping the config */
134 bool ndmp_snooping; /* NDMP Protocol specific snooping enabled */
135 bool auditing; /* Auditing enabled */
136 alist *audit_events; /* Specific audit events to enable */
137 uint32_t ndmp_loglevel; /* NDMP Protocol specific loglevel to use */
138 uint32_t subscriptions; /* Number of subscribtions available */
139 uint32_t subscriptions_used; /* Number of subscribtions used */
140 uint32_t jcr_watchdog_time; /* Absolute time after which a Job gets terminated regardless of its progress */
141 uint32_t stats_collect_interval; /* Statistics collect interval in seconds */
142 char *verid; /* Custom Id to print in version command */
143 char *secure_erase_cmdline; /* Cmdline to execute to perform secure erase of file */
144 char *log_timestamp_format; /* Timestamp format to use in generic logging messages */
145 s_password keyencrkey; /* Key Encryption Key */
146
DirectorResource()147 DirectorResource()
148 : TlsResource()
149 , DIRaddrs(nullptr) {}
150 };
151
152 /*
153 * Device Resource
154 *
155 * This resource is a bit different from the other resources
156 * because it is not defined in the Director
157 * by Device { ... }, but rather by a "reference" such as
158 * Device = xxx; Then when the Director connects to the
159 * SD, it requests the information about the device.
160 */
161 class DeviceResource : public BareosResource {
162 public:
163 bool found; /**< found with SD */
164 int32_t num_writers; /**< number of writers */
165 int32_t max_writers; /**< = 1 for files */
166 int32_t reserved; /**< number of reserves */
167 int32_t num_drives; /**< for autochanger */
168 bool autochanger; /**< set if device is autochanger */
169 bool open; /**< drive open */
170 bool append; /**< in append mode */
171 bool read; /**< in read mode */
172 bool labeled; /**< Volume name valid */
173 bool offline; /**< not available */
174 bool autoselect; /**< can be selected via autochanger */
175 uint32_t PoolId;
176 char ChangerName[MAX_NAME_LENGTH];
177 char VolumeName[MAX_NAME_LENGTH];
178 char MediaType[MAX_NAME_LENGTH];
179
DeviceResource()180 DeviceResource() : BareosResource() {}
181 };
182
183 /**
184 * Console ACL positions
185 */
186 enum {
187 Job_ACL = 0,
188 Client_ACL,
189 Storage_ACL,
190 Schedule_ACL,
191 Run_ACL,
192 Pool_ACL,
193 Command_ACL,
194 FileSet_ACL,
195 Catalog_ACL,
196 Where_ACL,
197 PluginOptions_ACL,
198 Num_ACL /**< keep last */
199 };
200
201 /**
202 * Profile Resource
203 */
204 class ProfileResource : public BareosResource {
205 public:
206 alist *ACL_lists[Num_ACL]; /**< Pointers to ACLs */
207 };
208
209 /**
210 * Console Resource
211 */
212 class ConsoleResource : public TlsResource {
213 public:
214 alist *ACL_lists[Num_ACL]; /**< Pointers to ACLs */
215 alist *profiles; /**< Pointers to profile resources */
216 bool use_pam_authentication_; /**< PAM Console */
217 };
218
219 /**
220 * Catalog Resource
221 */
222 class CatalogResource : public BareosResource {
223 public:
224 uint32_t db_port; /**< Port */
225 char *db_address; /**< Hostname for remote access */
226 char *db_socket; /**< Socket for local access */
227 s_password db_password;
228 char *db_user;
229 char *db_name;
230 char *db_driver; /**< Select appropriate driver */
231 uint32_t mult_db_connections; /**< Set if multiple connections wanted */
232 bool disable_batch_insert; /**< Set if batch inserts should be disabled */
233 bool try_reconnect; /**< Try to reconnect a database connection when its dropped */
234 bool exit_on_fatal; /**< Make any fatal error in the connection to the database exit the program */
235 uint32_t pooling_min_connections; /**< When using sql pooling start with this number of connections to the database */
236 uint32_t pooling_max_connections; /**< When using sql pooling maximum number of connections to the database */
237 uint32_t pooling_increment_connections; /**< When using sql pooling increment the pool with this amount when its to small */
238 uint32_t pooling_idle_timeout; /**< When using sql pooling set this to the number of seconds to keep an idle connection */
239 uint32_t pooling_validate_timeout; /**< When using sql pooling set this to the number of seconds after a idle connection should be validated */
240
241 /**< Methods */
242 char *display(POOLMEM *dst); /**< Get catalog information */
CatalogResource()243 CatalogResource() : BareosResource() { }
244 };
245
246 /**
247 * Forward referenced structures
248 */
249 struct runtime_client_status_t;
250 struct runtime_storage_status_t;
251 struct runtime_job_status_t;
252
253 /**
254 * Client Resource
255 */
256 class ClientResource: public TlsResource {
257 public:
258 uint32_t Protocol; /* Protocol to use to connect */
259 uint32_t AuthType; /* Authentication Type to use for protocol */
260 uint32_t ndmp_loglevel; /* NDMP Protocol specific loglevel to use */
261 uint32_t ndmp_blocksize; /* NDMP Protocol specific blocksize to use */
262 uint32_t FDport; /* Where File daemon listens */
263 uint64_t SoftQuota; /* Soft Quota permitted in bytes */
264 uint64_t HardQuota; /* Maximum permitted quota in bytes */
265 uint64_t GraceTime; /* Time remaining on gracetime */
266 uint64_t QuotaLimit; /* The total softquota supplied if over grace */
267 utime_t SoftQuotaGracePeriod; /* Grace time for softquota */
268 utime_t FileRetention; /* File retention period in seconds */
269 utime_t JobRetention; /* Job retention period in seconds */
270 utime_t heartbeat_interval; /* Interval to send heartbeats */
271 char *address; /* Hostname for remote access to Client */
272 char *lanaddress; /* Hostname for remote access to Client if behind NAT in LAN */
273 char *username; /* Username to use for authentication if protocol supports it */
274 CatalogResource *catalog; /* Catalog resource */
275 int32_t MaxConcurrentJobs; /* Maximum concurrent jobs */
276 bool passive; /* Passive Client */
277 bool conn_from_dir_to_fd; /* Connect to Client */
278 bool conn_from_fd_to_dir; /* Allow incoming connections */
279 bool enabled; /* Set if client is enabled */
280 bool AutoPrune; /* Do automatic pruning? */
281 bool StrictQuotas; /* Enable strict quotas? */
282 bool QuotaIncludeFailedJobs; /* Ignore failed jobs when calculating quota */
283 bool ndmp_use_lmdb; /* NDMP Protocol specific use LMDB for the FHDB or not */
284 int64_t max_bandwidth; /* Limit speed on this client */
285 runtime_client_status_t *rcs; /* Runtime Client Status */
286 ClientConnectionHandshakeMode connection_successful_handshake_;
287
ClientResource()288 ClientResource() : TlsResource() {}
289 };
290
291 /**
292 * Store Resource
293 */
294 class StorageResource : public TlsResource {
295 public:
296 uint32_t Protocol; /* Protocol to use to connect */
297 uint32_t AuthType; /* Authentication Type to use for protocol */
298 uint32_t SDport; /* Port where Directors connect */
299 uint32_t SDDport; /* Data port for File daemon */
300 char *address; /* Hostname for remote access to Storage */
301 char *lanaddress; /* Hostname for remote access to Storage if behind NAT in LAN */
302 char *username; /* Username to use for authentication if protocol supports it */
303 char *media_type; /**< Media Type provided by this Storage */
304 char *ndmp_changer_device; /**< If DIR controls storage directly (NDMP_NATIVE) changer device used */
305 alist *device; /**< Alternate devices for this Storage */
306 int32_t MaxConcurrentJobs; /**< Maximum concurrent jobs */
307 int32_t MaxConcurrentReadJobs; /**< Maximum concurrent jobs reading */
308 bool enabled; /**< Set if device is enabled */
309 bool autochanger; /**< Set if autochanger */
310 bool collectstats; /**< Set if statistics should be collected of this SD */
311 bool AllowCompress; /**< Set if this Storage should allow jobs to enable compression */
312 int64_t StorageId; /**< Set from Storage DB record */
313 int64_t max_bandwidth; /**< Limit speed on this storage daemon for replication */
314 utime_t heartbeat_interval; /**< Interval to send heartbeats */
315 utime_t cache_status_interval; /**< Interval to cache the vol_list in the rss */
316 runtime_storage_status_t *rss; /**< Runtime Storage Status */
317 StorageResource *paired_storage; /**< Paired storage configuration item for protocols like NDMP */
318
319 /* Methods */
320 char *dev_name() const;
321
StorageResource()322 StorageResource() : TlsResource() {}
323 };
324
dev_name()325 inline char *StorageResource::dev_name() const
326 {
327 DeviceResource *dev = (DeviceResource *)device->first();
328 return dev->name();
329 }
330
331 /**
332 * This is a sort of "unified" store that has both the
333 * storage pointer and the text of where the pointer was
334 * found.
335 */
336 class UnifiedStorageResource {
337 public:
338 StorageResource *store;
339 POOLMEM *store_source;
340
341 /* Methods */
UnifiedStorageResource()342 UnifiedStorageResource() { store = NULL; store_source = GetPoolMemory(PM_MESSAGE);
343 *store_source = 0; }
~UnifiedStorageResource()344 ~UnifiedStorageResource() { destroy(); }
345 void SetSource(const char *where);
346 void destroy();
347 };
348
destroy()349 inline void UnifiedStorageResource::destroy()
350 {
351 if (store_source) {
352 FreePoolMemory(store_source);
353 store_source = NULL;
354 }
355 }
356
SetSource(const char * where)357 inline void UnifiedStorageResource::SetSource(const char *where)
358 {
359 if (!store_source) {
360 store_source = GetPoolMemory(PM_MESSAGE);
361 }
362 PmStrcpy(store_source, where);
363 }
364
365 /**
366 * Job Resource
367 */
368 class JobResource : public BareosResource {
369 public:
370 uint32_t Protocol; /**< Protocol to use to connect */
371 uint32_t JobType; /**< Job type (backup, verify, restore) */
372 uint32_t JobLevel; /**< default backup/verify level */
373 int32_t Priority; /**< Job priority */
374 uint32_t RestoreJobId; /**< What -- JobId to restore */
375 int32_t RescheduleTimes; /**< Number of times to reschedule job */
376 uint32_t replace; /**< How (overwrite, ..) */
377 uint32_t selection_type;
378
379 char *RestoreWhere; /**< Where on disk to restore -- directory */
380 char *RegexWhere; /**< RegexWhere option */
381 char *strip_prefix; /**< Remove prefix from filename */
382 char *add_prefix; /**< add prefix to filename */
383 char *add_suffix; /**< add suffix to filename -- .old */
384 char *backup_format; /**< Format of backup to use for protocols supporting multiple backup formats */
385 char *RestoreBootstrap; /**< Bootstrap file */
386 char *WriteBootstrap; /**< Where to write bootstrap Job updates */
387 char *WriteVerifyList; /**< List of changed files */
388 utime_t MaxRunTime; /**< Max run time in seconds */
389 utime_t MaxWaitTime; /**< Max blocking time in seconds */
390 utime_t FullMaxRunTime; /**< Max Full job run time */
391 utime_t DiffMaxRunTime; /**< Max Differential job run time */
392 utime_t IncMaxRunTime; /**< Max Incremental job run time */
393 utime_t MaxStartDelay; /**< Max start delay in seconds */
394 utime_t MaxRunSchedTime; /**< Max run time in seconds from Scheduled time*/
395 utime_t RescheduleInterval; /**< Reschedule interval */
396 utime_t MaxFullInterval; /**< Maximum time interval between Fulls */
397 utime_t MaxVFullInterval; /**< Maximum time interval between Virtual Fulls */
398 utime_t MaxDiffInterval; /**< Maximum time interval between Diffs */
399 utime_t DuplicateJobProximity; /**< Permitted time between duplicicates */
400 utime_t AlwaysIncrementalJobRetention; /**< Timeinterval where incrementals are not consolidated */
401 utime_t AlwaysIncrementalMaxFullAge; /**< If Full Backup is older than this age the consolidation job will include also the full */
402 int64_t spool_size; /**< Size of spool file for this job */
403 int64_t max_bandwidth; /**< Speed limit on this job */
404 int64_t FileHistSize; /**< Hint about the size of the expected File history */
405 int32_t MaxConcurrentJobs; /**< Maximum concurrent jobs */
406 int32_t MaxConcurrentCopies; /**< Limit number of concurrent jobs one Copy Job spawns */
407 int32_t AlwaysIncrementalKeepNumber;/**< Number of incrementals that are always left and not consolidated */
408 int32_t MaxFullConsolidations; /**< Number of consolidate jobs to be started that will include a full */
409
410 MessagesResource *messages; /**< How and where to send messages */
411 ScheduleResource *schedule; /**< When -- Automatic schedule */
412 ClientResource *client; /**< Who to backup */
413 FilesetResource *fileset; /**< What to backup -- Fileset */
414 CatalogResource *catalog; /**< Which Catalog to use */
415 alist *storage; /**< Where is device -- list of Storage to be used */
416 PoolResource *pool; /**< Where is media -- Media Pool */
417 PoolResource *full_pool; /**< Pool for Full backups */
418 PoolResource *vfull_pool; /**< Pool for Virtual Full backups */
419 PoolResource *inc_pool; /**< Pool for Incremental backups */
420 PoolResource *diff_pool; /**< Pool for Differental backups */
421 PoolResource *next_pool; /**< Next Pool for Copy/Migration Jobs and Virtual backups */
422 char *selection_pattern;
423 JobResource *verify_job; /**< Job name to verify */
424 JobResource *jobdefs; /**< Job defaults */
425 alist *run_cmds; /**< Run commands */
426 alist *RunScripts; /**< Run {client} program {after|before} Job */
427 alist *FdPluginOptions; /**< Generic FD plugin options used by this Job */
428 alist *SdPluginOptions; /**< Generic SD plugin options used by this Job */
429 alist *DirPluginOptions; /**< Generic DIR plugin options used by this Job */
430 alist *base; /**< Base jobs */
431
432 bool allow_mixed_priority; /**< Allow jobs with higher priority concurrently with this */
433 bool where_use_regexp; /**< true if RestoreWhere is a BareosRegex */
434 bool RescheduleOnError; /**< Set to reschedule on error */
435 bool RescheduleIncompleteJobs; /**< Set to reschedule incomplete Jobs */
436 bool PrefixLinks; /**< Prefix soft links with Where path */
437 bool PruneJobs; /**< Force pruning of Jobs */
438 bool PruneFiles; /**< Force pruning of Files */
439 bool PruneVolumes; /**< Force pruning of Volumes */
440 bool SpoolAttributes; /**< Set to spool attributes in SD */
441 bool spool_data; /**< Set to spool data in SD */
442 bool rerun_failed_levels; /**< Upgrade to rerun failed levels */
443 bool PreferMountedVolumes; /**< Prefer vols mounted rather than new one */
444 bool write_part_after_job; /**< Set to write part after job in SD */
445 bool enabled; /**< Set if job enabled */
446 bool accurate; /**< Set if it is an accurate backup job */
447 bool AllowDuplicateJobs; /**< Allow duplicate jobs */
448 bool AllowHigherDuplicates; /**< Permit Higher Level */
449 bool CancelLowerLevelDuplicates; /**< Cancel lower level backup jobs */
450 bool CancelQueuedDuplicates; /**< Cancel queued jobs */
451 bool CancelRunningDuplicates; /**< Cancel Running jobs */
452 bool PurgeMigrateJob; /**< Purges source job on completion */
453 bool IgnoreDuplicateJobChecking; /**< Ignore Duplicate Job Checking */
454 bool SaveFileHist; /**< Ability to disable File history saving for certain protocols */
455 bool AlwaysIncremental; /**< Always incremental with regular consolidation */
456
457 runtime_job_status_t *rjs; /**< Runtime Job Status */
458
459 /* Methods */
460 bool validate();
461
JobResource()462 JobResource() : BareosResource() {}
463 };
464
465 #undef MAX_FOPTS
466 #define MAX_FOPTS 40
467
468 /**
469 * File options structure
470 */
471 struct FileOptions {
472 char opts[MAX_FOPTS]; /**< Options string */
473 alist regex; /**< Regex string(s) */
474 alist regexdir; /**< Regex string(s) for directories */
475 alist regexfile; /**< Regex string(s) for files */
476 alist wild; /**< Wild card strings */
477 alist wilddir; /**< Wild card strings for directories */
478 alist wildfile; /**< Wild card strings for files */
479 alist wildbase; /**< Wild card strings for files without '/' */
480 alist base; /**< List of base names */
481 alist fstype; /**< File system type limitation */
482 alist Drivetype; /**< Drive type limitation */
483 alist meta; /**< Backup meta information */
484 char *reader; /**< Reader program */
485 char *writer; /**< Writer program */
486 char *plugin; /**< Plugin program */
487 };
488
489 /**
490 * This is either an include item or an exclude item
491 */
492 struct IncludeExcludeItem {
493 FileOptions *current_opts; /**< Points to current options structure */
494 FileOptions **opts_list; /**< Options list */
495 int32_t num_opts; /**< Number of options items */
496 alist name_list; /**< Filename list -- holds char * */
497 alist plugin_list; /**< Filename list for plugins */
498 alist ignoredir; /**< Ignoredir string */
499 };
500
501 /**
502 * FileSet Resource
503 */
504 class FilesetResource : public BareosResource {
505 public:
506 bool new_include; /**< Set if new include used */
507 IncludeExcludeItem **include_items; /**< Array of incexe structures */
508 int32_t num_includes; /**< Number in array */
509 IncludeExcludeItem **exclude_items;
510 int32_t num_excludes;
511 bool have_MD5; /**< Set if MD5 initialized */
512 MD5_CTX md5c; /**< MD5 of include/exclude */
513 char MD5[30]; /**< Base 64 representation of MD5 */
514 bool ignore_fs_changes; /**< Don't force Full if FS changed */
515 bool enable_vss; /**< Enable Volume Shadow Copy */
516
517 /* Methods */
518 bool PrintConfig(PoolMem& buf, bool hide_sensitive_data = false, bool verbose = false);
519
FilesetResource()520 FilesetResource() : BareosResource() {}
521 };
522
523 /**
524 * Schedule Resource
525 */
526 class ScheduleResource: public BareosResource {
527 public:
528 RunResource *run;
529 bool enabled; /* Set if schedule is enabled */
530
ScheduleResource()531 ScheduleResource() : BareosResource() {}
532 };
533
534 /**
535 * Counter Resource
536 */
537 class CounterResource: public BareosResource {
538 public:
539 int32_t MinValue; /* Minimum value */
540 int32_t MaxValue; /* Maximum value */
541 int32_t CurrentValue ; /* Current value */
542 CounterResource *WrapCounter; /* Wrap counter name */
543 CatalogResource *Catalog; /* Where to store */
544 bool created; /* Created in DB */
545
CounterResource()546 CounterResource() : BareosResource() {}
547 };
548
549 /**
550 * Pool Resource
551 */
552 class PoolResource: public BareosResource {
553 public:
554 char *pool_type; /* Pool type */
555 char *label_format; /* Label format string */
556 char *cleaning_prefix; /* Cleaning label prefix */
557 int32_t LabelType; /* Bareos/ANSI/IBM label type */
558 uint32_t max_volumes; /* Max number of volumes */
559 utime_t VolRetention; /* Volume retention period in seconds */
560 utime_t VolUseDuration; /* Duration volume can be used */
561 uint32_t MaxVolJobs; /* Maximum jobs on the Volume */
562 uint32_t MaxVolFiles; /* Maximum files on the Volume */
563 uint64_t MaxVolBytes; /* Maximum bytes on the Volume */
564 utime_t MigrationTime; /* Time to migrate to next pool */
565 uint64_t MigrationHighBytes; /* When migration starts */
566 uint64_t MigrationLowBytes; /* When migration stops */
567 PoolResource *NextPool; /* Next pool for migration */
568 alist *storage; /* Where is device -- list of Storage to be used */
569 bool use_catalog; /* Maintain catalog for media */
570 bool catalog_files; /* Maintain file entries in catalog */
571 bool use_volume_once; /* Write on volume only once */
572 bool purge_oldest_volume; /* Purge oldest volume */
573 bool recycle_oldest_volume; /* Attempt to recycle oldest volume */
574 bool recycle_current_volume; /* Attempt recycle of current volume */
575 bool AutoPrune; /* Default for pool auto prune */
576 bool Recycle; /* Default for media recycle yes/no */
577 uint32_t action_on_purge; /* Action on purge, e.g. truncate the disk volume */
578 PoolResource *RecyclePool; /* RecyclePool destination when media is purged */
579 PoolResource *ScratchPool; /* ScratchPool source when requesting media */
580 CatalogResource *catalog; /* Catalog to be used */
581 utime_t FileRetention; /* File retention period in seconds */
582 utime_t JobRetention; /* Job retention period in seconds */
583 uint32_t MinBlocksize; /* Minimum Blocksize */
584 uint32_t MaxBlocksize; /* Maximum Blocksize */
585
PoolResource()586 PoolResource() : BareosResource() {}
587 };
588
589 /**
590 * Run structure contained in Schedule Resource
591 */
592 class RunResource: public BareosResource {
593 public:
594 RunResource *next; /**< points to next run record */
595 uint32_t level; /**< level override */
596 int32_t Priority; /**< priority override */
597 uint32_t job_type;
598 utime_t MaxRunSchedTime; /**< max run time in sec from Sched time */
599 bool MaxRunSchedTime_set; /**< MaxRunSchedTime given */
600 bool spool_data; /**< Data spooling override */
601 bool spool_data_set; /**< Data spooling override given */
602 bool accurate; /**< accurate */
603 bool accurate_set; /**< accurate given */
604
605 PoolResource *pool; /**< Pool override */
606 PoolResource *full_pool; /**< Full Pool override */
607 PoolResource *vfull_pool; /**< Virtual Full Pool override */
608 PoolResource *inc_pool; /**< Incr Pool override */
609 PoolResource *diff_pool; /**< Diff Pool override */
610 PoolResource *next_pool; /**< Next Pool override */
611 StorageResource *storage; /**< Storage override */
612 MessagesResource *msgs; /**< Messages override */
613 char *since;
614 uint32_t level_no;
615 uint32_t minute; /* minute to run job */
616 time_t last_run; /* last time run */
617 time_t next_run; /* next time to run */
618 char hour[NbytesForBits(24 + 1)]; /* bit set for each hour */
619 char mday[NbytesForBits(31 + 1)]; /* bit set for each day of month */
620 char month[NbytesForBits(12 + 1)]; /* bit set for each month */
621 char wday[NbytesForBits(7 + 1)]; /* bit set for each day of the week */
622 char wom[NbytesForBits(5 + 1)]; /* week of month */
623 char woy[NbytesForBits(54 + 1)]; /* week of year */
624 bool last_set; /* last week of month */
625
RunResource()626 RunResource() : BareosResource() {}
627 };
628
629 /**
630 * Define the Union of all the above
631 * resource structure definitions.
632 */
633 union UnionOfResources {
634 DirectorResource res_dir;
635 ConsoleResource res_con;
636 ProfileResource res_profile;
637 ClientResource res_client;
638 StorageResource res_store;
639 CatalogResource res_cat;
640 JobResource res_job;
641 FilesetResource res_fs;
642 ScheduleResource res_sch;
643 PoolResource res_pool;
644 MessagesResource res_msgs;
645 CounterResource res_counter;
646 DeviceResource res_dev;
647 CommonResourceHeader hdr;
648
UnionOfResources()649 UnionOfResources() {
650 new (&hdr) CommonResourceHeader();
651 Dmsg1(900, "hdr: %p \n", &hdr);
652 Dmsg1(900, "res_dir.hdr %p\n", &res_dir.hdr);
653 Dmsg1(900, "res_con.hdr %p\n", &res_con.hdr);
654 }
~UnionOfResources()655 ~UnionOfResources() {}
656 };
657
658 ConfigurationParser *InitDirConfig(const char *configfile, int exit_code);
659 bool PropagateJobdefs(int res_type, JobResource *res);
660 bool ValidateResource(int type, ResourceItem *items, BareosResource *res);
661
662 bool print_datatype_schema_json(PoolMem &buffer, int level, const int type,
663 ResourceItem items[], const bool last = false);
664 #ifdef HAVE_JANSSON
665 json_t *json_datatype(const int type, ResourceItem items[]);
666 #endif
667 const char *auth_protocol_to_str(uint32_t auth_protocol);
668 const char *level_to_str(int level);
669 extern "C" char *job_code_callback_director(JobControlRecord *jcr, const char*);
670 const char *get_configure_usage_string();
671 void DestroyConfigureUsageString();
672 bool PopulateDefs();
673
674 } /* namespace directordaemon */
675 #endif // BAREOS_DIRD_DIRD_CONF_H_
676