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