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