]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
- Remove xpg4 lib from FreeBSD build as it is no longer needed and
[bacula/bacula] / bacula / src / dird / dird_conf.h
1 /*
2  * Director specific configuration and defines
3  *
4  *     Kern Sibbald, Feb MM
5  *
6  *    Version $Id$
7  */
8 /*
9    Copyright (C) 2000-2006 Kern Sibbald
10
11    This program is free software; you can redistribute it and/or
12    modify it under the terms of the GNU General Public License
13    version 2 as amended with additional clauses defined in the
14    file LICENSE in the main source directory.
15
16    This program is distributed in the hope that it will be useful,
17    but WITHOUT ANY WARRANTY; without even the implied warranty of
18    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
19    the file LICENSE for additional details.
20
21  */
22
23 /* NOTE:  #includes at the end of this file */
24
25 /*
26  * Resource codes -- they must be sequential for indexing
27  */
28 enum {
29    R_DIRECTOR = 1001,
30    R_CLIENT,
31    R_JOB,
32    R_STORAGE,
33    R_CATALOG,
34    R_SCHEDULE,
35    R_FILESET,
36    R_POOL,
37    R_MSGS,
38    R_COUNTER,
39    R_CONSOLE,
40    R_JOBDEFS,
41    R_DEVICE,
42    R_FIRST = R_DIRECTOR,
43    R_LAST  = R_DEVICE                 /* keep this updated */
44 };
45
46
47 /*
48  * Some resource attributes
49  */
50 enum {
51    R_NAME = 1020,
52    R_ADDRESS,
53    R_PASSWORD,
54    R_TYPE,
55    R_BACKUP
56 };
57
58
59 /* Used for certain KeyWord tables */
60 struct s_kw {
61    const char *name;
62    int token;
63 };
64
65 /* Job Level keyword structure */
66 struct s_jl {
67    const char *level_name;                  /* level keyword */
68    int  level;                        /* level */
69    int  job_type;                     /* JobType permitting this level */
70 };
71
72 /* Job Type keyword structure */
73 struct s_jt {
74    const char *type_name;
75    int job_type;
76 };
77
78 /* Definition of the contents of each Resource */
79 /* Needed for forward references */
80 struct SCHED;
81 struct CLIENT;
82 struct FILESET;
83 struct POOL;
84 struct RUN;
85 struct DEVICE;
86 struct RUNSCRIPT;
87
88 /*
89  *   Director Resource
90  *
91  */
92 class DIRRES {
93 public:
94    RES   hdr;
95    dlist *DIRaddrs;
96    char *password;                    /* Password for UA access */
97    char *query_file;                  /* SQL query file */
98    char *working_directory;           /* WorkingDirectory */
99    const char *scripts_directory;     /* ScriptsDirectory */
100    char *pid_directory;               /* PidDirectory */
101    char *subsys_directory;            /* SubsysDirectory */
102    MSGS *messages;                    /* Daemon message handler */
103    uint32_t MaxConcurrentJobs;        /* Max concurrent jobs for whole director */
104    utime_t FDConnectTimeout;          /* timeout for connect in seconds */
105    utime_t SDConnectTimeout;          /* timeout in seconds */
106    char *tls_ca_certfile;             /* TLS CA Certificate File */
107    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
108    char *tls_certfile;                /* TLS Server Certificate File */
109    char *tls_keyfile;                 /* TLS Server Key File */
110    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
111    alist *tls_allowed_cns;            /* TLS Allowed Clients */
112    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
113    bool tls_enable;                   /* Enable TLS */
114    bool tls_require;                  /* Require TLS */
115    bool tls_verify_peer;              /* TLS Verify Client Certificate */
116 };
117
118 /*
119  * Device Resource
120  *  This resource is a bit different from the other resources
121  *  because it is not defined in the Director 
122  *  by DEVICE { ... }, but rather by a "reference" such as
123  *  DEVICE = xxx; Then when the Director connects to the
124  *  SD, it requests the information about the device.
125  */
126 class DEVICE {
127 public:
128    RES hdr;
129
130    bool found;                        /* found with SD */
131    int num_writers;                   /* number of writers */
132    int max_writers;                   /* = 1 for files */
133    int reserved;                      /* number of reserves */
134    int num_drives;                    /* for autochanger */
135    bool autochanger;                  /* set if device is autochanger */
136    bool open;                         /* drive open */
137    bool append;                       /* in append mode */
138    bool read;                         /* in read mode */
139    bool labeled;                      /* Volume name valid */
140    bool offline;                      /* not available */
141    bool autoselect;                   /* can be selected via autochanger */
142    uint32_t PoolId;
143    char ChangerName[MAX_NAME_LENGTH];
144    char VolumeName[MAX_NAME_LENGTH];
145    char MediaType[MAX_NAME_LENGTH];
146 };
147
148 /*
149  * Console ACL positions
150  */
151 enum {
152    Job_ACL = 0,
153    Client_ACL,
154    Storage_ACL,
155    Schedule_ACL,
156    Run_ACL,
157    Pool_ACL,
158    Command_ACL,
159    FileSet_ACL,
160    Catalog_ACL,
161    Num_ACL                            /* keep last */
162 };
163
164 /*
165  *    Console Resource
166  */
167 class CONRES {
168 public:
169    RES   hdr;
170    char *password;                    /* UA server password */
171    alist *ACL_lists[Num_ACL];         /* pointers to ACLs */
172    char *tls_ca_certfile;             /* TLS CA Certificate File */
173    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
174    char *tls_certfile;                /* TLS Server Certificate File */
175    char *tls_keyfile;                 /* TLS Server Key File */
176    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
177    alist *tls_allowed_cns;            /* TLS Allowed Clients */
178    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
179    bool tls_enable;                   /* Enable TLS */
180    bool tls_require;                  /* Require TLS */
181    bool tls_verify_peer;              /* TLS Verify Client Certificate */
182 };
183
184
185 /*
186  *   Catalog Resource
187  *
188  */
189 class CAT {
190 public:
191    RES   hdr;
192
193    int   db_port;                     /* Port */
194    char *db_address;                  /* host name for remote access */
195    char *db_socket;                   /* Socket for local access */
196    char *db_password;
197    char *db_user;
198    char *db_name;
199    int   mult_db_connections;         /* set if multiple connections wanted */
200 };
201
202
203 /*
204  *   Client Resource
205  *
206  */
207 class CLIENT {
208 public:
209    RES   hdr;
210
211    int   FDport;                      /* Where File daemon listens */
212    utime_t FileRetention;             /* file retention period in seconds */
213    utime_t JobRetention;              /* job retention period in seconds */
214    char *address;
215    char *password;
216    CAT *catalog;                      /* Catalog resource */
217    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
218    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
219    char *tls_ca_certfile;             /* TLS CA Certificate File */
220    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
221    char *tls_certfile;                /* TLS Client Certificate File */
222    char *tls_keyfile;                 /* TLS Client Key File */
223    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
224    bool tls_enable;                   /* Enable TLS */
225    bool tls_require;                  /* Require TLS */
226    bool AutoPrune;                    /* Do automatic pruning? */
227 };
228
229 /*
230  *   Store Resource
231  *
232  */
233 class STORE {
234 public:
235    RES   hdr;
236
237    int   SDport;                      /* port where Directors connect */
238    int   SDDport;                     /* data port for File daemon */
239    char *address;
240    char *password;
241    char *media_type;
242    alist *device;                     /* Alternate devices for this Storage */
243    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
244    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
245    char *tls_ca_certfile;             /* TLS CA Certificate File */
246    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
247    char *tls_certfile;                /* TLS Client Certificate File */
248    char *tls_keyfile;                 /* TLS Client Key File */
249    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
250    bool tls_enable;                   /* Enable TLS */
251    bool tls_require;                  /* Require TLS */
252    bool enabled;                      /* Set if device is enabled */
253    bool  autochanger;                 /* set if autochanger */
254    int64_t StorageId;                 /* Set from Storage DB record */
255    int  drives;                       /* number of drives in autochanger */
256
257    /* Methods */
258    char *dev_name() const;
259    char *name() const;
260 };
261
262 inline char *STORE::dev_name() const
263
264    DEVICE *dev = (DEVICE *)device->first();
265    return dev->hdr.name;
266 }
267
268 inline char *STORE::name() const { return hdr.name; }
269
270
271 /*
272  *   Job Resource
273  */
274 class JOB {
275 public:
276    RES   hdr;
277
278    int   JobType;                     /* job type (backup, verify, restore */
279    int   JobLevel;                    /* default backup/verify level */
280    int   Priority;                    /* Job priority */
281    int   RestoreJobId;                /* What -- JobId to restore */
282    char *RestoreWhere;                /* Where on disk to restore -- directory */
283    char *RestoreBootstrap;            /* Bootstrap file */
284    alist *RunScripts;                 /* Run {client} program {after|before} Job */
285    union {
286       char *WriteBootstrap;           /* Where to write bootstrap Job updates */
287       char *WriteVerifyList;          /* List of changed files */
288    };
289    int   replace;                     /* How (overwrite, ..) */
290    utime_t MaxRunTime;                /* max run time in seconds */
291    utime_t MaxWaitTime;               /* max blocking time in seconds */
292    utime_t FullMaxWaitTime;           /* Max Full job wait time */
293    utime_t DiffMaxWaitTime;           /* Max Differential job wait time */
294    utime_t IncMaxWaitTime;            /* Max Incremental job wait time */
295    utime_t MaxStartDelay;             /* max start delay in seconds */
296    utime_t RescheduleInterval;        /* Reschedule interval */
297    utime_t JobRetention;              /* job retention period in seconds */
298    uint32_t MaxConcurrentJobs;        /* Maximum concurrent jobs */
299    int RescheduleTimes;               /* Number of times to reschedule job */
300    bool RescheduleOnError;            /* Set to reschedule on error */
301    bool PrefixLinks;                  /* prefix soft links with Where path */
302    bool PruneJobs;                    /* Force pruning of Jobs */
303    bool PruneFiles;                   /* Force pruning of Files */
304    bool PruneVolumes;                 /* Force pruning of Volumes */
305    bool SpoolAttributes;              /* Set to spool attributes in SD */
306    bool spool_data;                   /* Set to spool data in SD */
307    bool rerun_failed_levels;          /* Upgrade to rerun failed levels */
308    bool PreferMountedVolumes;         /* Prefer vols mounted rather than new one */
309    bool write_part_after_job;         /* Set to write part after job in SD */
310    bool enabled;                      /* Set if job enabled */
311    
312    MSGS      *messages;               /* How and where to send messages */
313    SCHED     *schedule;               /* When -- Automatic schedule */
314    CLIENT    *client;                 /* Who to backup */
315    FILESET   *fileset;                /* What to backup -- Fileset */
316    alist     *storage;                /* Where is device -- list of Storage to be used */
317    POOL      *pool;                   /* Where is media -- Media Pool */
318    POOL      *full_pool;              /* Pool for Full backups */
319    POOL      *inc_pool;               /* Pool for Incremental backups */
320    POOL      *dif_pool;               /* Pool for Differental backups */
321    POOL      *next_pool;              /* Next Pool for Migration */
322    char      *selection_pattern;
323    int        selection_type;
324    union {
325       JOB       *verify_job;          /* Job name to verify */
326    };
327    JOB       *jobdefs;                /* Job defaults */
328    alist     *run_cmds;               /* Run commands */
329    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
330 };
331
332 #undef  MAX_FOPTS
333 #define MAX_FOPTS 34
334
335 /* File options structure */
336 struct FOPTS {
337    char opts[MAX_FOPTS];              /* options string */
338    alist regex;                       /* regex string(s) */
339    alist regexdir;                    /* regex string(s) for directories */
340    alist regexfile;                   /* regex string(s) for files */
341    alist wild;                        /* wild card strings */
342    alist wilddir;                     /* wild card strings for directories */
343    alist wildfile;                    /* wild card strings for files */
344    alist base;                        /* list of base names */
345    alist fstype;                      /* file system type limitation */
346    char *reader;                      /* reader program */
347    char *writer;                      /* writer program */
348 };
349
350
351 /* This is either an include item or an exclude item */
352 struct INCEXE {
353    FOPTS *current_opts;               /* points to current options structure */
354    FOPTS **opts_list;                 /* options list */
355    int num_opts;                      /* number of options items */
356    alist name_list;                   /* filename list -- holds char * */
357 };
358
359 /*
360  *   FileSet Resource
361  *
362  */
363 class FILESET {
364 public:
365    RES   hdr;
366
367    bool new_include;                  /* Set if new include used */
368    INCEXE **include_items;            /* array of incexe structures */
369    int num_includes;                  /* number in array */
370    INCEXE **exclude_items;
371    int num_excludes;
372    bool have_MD5;                     /* set if MD5 initialized */
373    struct MD5Context md5c;            /* MD5 of include/exclude */
374    char MD5[30];                      /* base 64 representation of MD5 */
375    bool ignore_fs_changes;            /* Don't force Full if FS changed */
376    bool enable_vss;                   /* Enable Volume Shadow Copy */
377 };
378
379
380 /*
381  *   Schedule Resource
382  *
383  */
384 class SCHED {
385 public:
386    RES   hdr;
387
388    RUN *run;
389 };
390
391 /*
392  *   Counter Resource
393  */
394 class COUNTER {
395 public:
396    RES   hdr;
397
398    int32_t  MinValue;                 /* Minimum value */
399    int32_t  MaxValue;                 /* Maximum value */
400    int32_t  CurrentValue;             /* Current value */
401    COUNTER *WrapCounter;              /* Wrap counter name */
402    CAT     *Catalog;                  /* Where to store */
403    bool     created;                  /* Created in DB */
404 };
405
406 /*
407  *   Pool Resource
408  *
409  */
410 class POOL {
411 public:
412    RES   hdr;
413
414    char *pool_type;                   /* Pool type */
415    char *label_format;                /* Label format string */
416    char *cleaning_prefix;             /* Cleaning label prefix */
417    int   LabelType;                   /* Bacula/ANSI/IBM label type */
418    uint32_t max_volumes;              /* max number of volumes */
419    utime_t VolRetention;              /* volume retention period in seconds */
420    utime_t VolUseDuration;            /* duration volume can be used */
421    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
422    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
423    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
424    utime_t MigrationTime;             /* Time to migrate to next pool */
425    uint32_t MigrationHighBytes;       /* When migration starts */
426    uint32_t MigrationLowBytes;        /* When migration stops */
427    POOL  *NextPool;                   /* Next pool for migration */
428    alist *storage;                    /* Where is device -- list of Storage to be used */
429    bool  use_catalog;                 /* maintain catalog for media */
430    bool  catalog_files;               /* maintain file entries in catalog */
431    bool  use_volume_once;             /* write on volume only once */
432    bool  accept_any_volume;           /* accept any volume */
433    bool  purge_oldest_volume;         /* purge oldest volume */
434    bool  recycle_oldest_volume;       /* attempt to recycle oldest volume */
435    bool  recycle_current_volume;      /* attempt recycle of current volume */
436    bool  AutoPrune;                   /* default for pool auto prune */
437    bool  Recycle;                     /* default for media recycle yes/no */
438 };
439
440
441
442
443 /* Define the Union of all the above
444  * resource structure definitions.
445  */
446 union URES {
447    DIRRES     res_dir;
448    CONRES     res_con;
449    CLIENT     res_client;
450    STORE      res_store;
451    CAT        res_cat;
452    JOB        res_job;
453    FILESET    res_fs;
454    SCHED      res_sch;
455    POOL       res_pool;
456    MSGS       res_msgs;
457    COUNTER    res_counter;
458    DEVICE     res_dev;
459    RES        hdr;
460 };
461
462
463
464 /* Run structure contained in Schedule Resource */
465 class RUN {
466 public:
467    RUN *next;                         /* points to next run record */
468    int level;                         /* level override */
469    int Priority;                      /* priority override */
470    int job_type;
471    bool spool_data;                   /* Data spooling override */
472    bool spool_data_set;               /* Data spooling override given */
473    bool write_part_after_job;         /* Write part after job override */
474    bool write_part_after_job_set;     /* Write part after job override given */
475    
476    POOL *pool;                        /* Pool override */
477    POOL *full_pool;                   /* Pool override */
478    POOL *inc_pool;                    /* Pool override */
479    POOL *dif_pool;                    /* Pool override */
480    STORE *storage;                    /* Storage override */
481    MSGS *msgs;                        /* Messages override */
482    char *since;
483    int level_no;
484    int minute;                        /* minute to run job */
485    time_t last_run;                   /* last time run */
486    time_t next_run;                   /* next time to run */
487    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
488    char mday[nbytes_for_bits(31)];    /* bit set for each day of month */
489    char month[nbytes_for_bits(12)];   /* bit set for each month */
490    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
491    char wom[nbytes_for_bits(5)];      /* week of month */
492    char woy[nbytes_for_bits(54)];     /* week of year */
493 };