]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
kes Add -c option to pg_dump so that it initializes tables when
[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 class SCHED;
81 class CLIENT;
82 class FILESET;
83 class POOL;
84 class RUN;
85 class DEVICE;
86 class 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    /* Methods */
118    char *name() const;
119 };
120
121 inline char *DIRRES::name() const { return hdr.name; }
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    /* Methods */
153    char *name() const;
154 };
155
156 inline char *DEVICE::name() const { return hdr.name; }
157
158 /*
159  * Console ACL positions
160  */
161 enum {
162    Job_ACL = 0,
163    Client_ACL,
164    Storage_ACL,
165    Schedule_ACL,
166    Run_ACL,
167    Pool_ACL,
168    Command_ACL,
169    FileSet_ACL,
170    Catalog_ACL,
171    Where_ACL,
172    Num_ACL                            /* keep last */
173 };
174
175 /*
176  *    Console Resource
177  */
178 class CONRES {
179 public:
180    RES   hdr;
181    char *password;                    /* UA server password */
182    alist *ACL_lists[Num_ACL];         /* pointers to ACLs */
183    char *tls_ca_certfile;             /* TLS CA Certificate File */
184    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
185    char *tls_certfile;                /* TLS Server Certificate File */
186    char *tls_keyfile;                 /* TLS Server Key File */
187    char *tls_dhfile;                  /* TLS Diffie-Hellman Parameters */
188    alist *tls_allowed_cns;            /* TLS Allowed Clients */
189    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
190    bool tls_enable;                   /* Enable TLS */
191    bool tls_require;                  /* Require TLS */
192    bool tls_verify_peer;              /* TLS Verify Client Certificate */
193
194    /* Methods */
195    char *name() const;
196 };
197
198 inline char *CONRES::name() const { return hdr.name; }
199
200
201 /*
202  *   Catalog Resource
203  *
204  */
205 class CAT {
206 public:
207    RES   hdr;
208
209    int   db_port;                     /* Port */
210    char *db_address;                  /* host name for remote access */
211    char *db_socket;                   /* Socket for local access */
212    char *db_password;
213    char *db_user;
214    char *db_name;
215    int   mult_db_connections;         /* set if multiple connections wanted */
216
217    /* Methods */
218    char *name() const;
219 };
220
221 inline char *CAT::name() const { return hdr.name; }
222
223
224 /*
225  *   Client Resource
226  *
227  */
228 class CLIENT {
229 public:
230    RES   hdr;
231
232    int   FDport;                      /* Where File daemon listens */
233    utime_t FileRetention;             /* file retention period in seconds */
234    utime_t JobRetention;              /* job retention period in seconds */
235    char *address;
236    char *password;
237    CAT *catalog;                      /* Catalog resource */
238    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
239    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
240    char *tls_ca_certfile;             /* TLS CA Certificate File */
241    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
242    char *tls_certfile;                /* TLS Client Certificate File */
243    char *tls_keyfile;                 /* TLS Client Key File */
244    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
245    bool tls_enable;                   /* Enable TLS */
246    bool tls_require;                  /* Require TLS */
247    bool AutoPrune;                    /* Do automatic pruning? */
248
249    /* Methods */
250    char *name() const;
251 };
252
253 inline char *CLIENT::name() const { return hdr.name; }
254
255
256 /*
257  *   Store Resource
258  *
259  */
260 class STORE {
261 public:
262    RES   hdr;
263
264    int   SDport;                      /* port where Directors connect */
265    int   SDDport;                     /* data port for File daemon */
266    char *address;
267    char *password;
268    char *media_type;
269    alist *device;                     /* Alternate devices for this Storage */
270    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
271    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
272    char *tls_ca_certfile;             /* TLS CA Certificate File */
273    char *tls_ca_certdir;              /* TLS CA Certificate Directory */
274    char *tls_certfile;                /* TLS Client Certificate File */
275    char *tls_keyfile;                 /* TLS Client Key File */
276    TLS_CONTEXT *tls_ctx;              /* Shared TLS Context */
277    bool tls_enable;                   /* Enable TLS */
278    bool tls_require;                  /* Require TLS */
279    bool enabled;                      /* Set if device is enabled */
280    bool  autochanger;                 /* set if autochanger */
281    int64_t StorageId;                 /* Set from Storage DB record */
282    int  drives;                       /* number of drives in autochanger */
283
284    /* Methods */
285    char *dev_name() const;
286    char *name() const;
287 };
288
289 inline char *STORE::dev_name() const
290
291    DEVICE *dev = (DEVICE *)device->first();
292    return dev->hdr.name;
293 }
294
295 inline char *STORE::name() const { return hdr.name; }
296
297
298 /*
299  *   Job Resource
300  */
301 class JOB {
302 public:
303    RES   hdr;
304
305    int   JobType;                     /* job type (backup, verify, restore */
306    int   JobLevel;                    /* default backup/verify level */
307    int   Priority;                    /* Job priority */
308    int   RestoreJobId;                /* What -- JobId to restore */
309    char *RestoreWhere;                /* Where on disk to restore -- directory */
310    char *RestoreBootstrap;            /* Bootstrap file */
311    alist *RunScripts;                 /* Run {client} program {after|before} Job */
312    union {
313       char *WriteBootstrap;           /* Where to write bootstrap Job updates */
314       char *WriteVerifyList;          /* List of changed files */
315    };
316    int   replace;                     /* How (overwrite, ..) */
317    utime_t MaxRunTime;                /* max run time in seconds */
318    utime_t MaxWaitTime;               /* max blocking time in seconds */
319    utime_t FullMaxWaitTime;           /* Max Full job wait time */
320    utime_t DiffMaxWaitTime;           /* Max Differential job wait time */
321    utime_t IncMaxWaitTime;            /* Max Incremental job wait time */
322    utime_t MaxStartDelay;             /* max start delay in seconds */
323    utime_t RescheduleInterval;        /* Reschedule interval */
324    utime_t JobRetention;              /* job retention period in seconds */
325    uint32_t MaxConcurrentJobs;        /* Maximum concurrent jobs */
326    int RescheduleTimes;               /* Number of times to reschedule job */
327    bool RescheduleOnError;            /* Set to reschedule on error */
328    bool PrefixLinks;                  /* prefix soft links with Where path */
329    bool PruneJobs;                    /* Force pruning of Jobs */
330    bool PruneFiles;                   /* Force pruning of Files */
331    bool PruneVolumes;                 /* Force pruning of Volumes */
332    bool SpoolAttributes;              /* Set to spool attributes in SD */
333    bool spool_data;                   /* Set to spool data in SD */
334    bool rerun_failed_levels;          /* Upgrade to rerun failed levels */
335    bool PreferMountedVolumes;         /* Prefer vols mounted rather than new one */
336    bool write_part_after_job;         /* Set to write part after job in SD */
337    bool enabled;                      /* Set if job enabled */
338    
339    MSGS      *messages;               /* How and where to send messages */
340    SCHED     *schedule;               /* When -- Automatic schedule */
341    CLIENT    *client;                 /* Who to backup */
342    FILESET   *fileset;                /* What to backup -- Fileset */
343    alist     *storage;                /* Where is device -- list of Storage to be used */
344    POOL      *pool;                   /* Where is media -- Media Pool */
345    POOL      *full_pool;              /* Pool for Full backups */
346    POOL      *inc_pool;               /* Pool for Incremental backups */
347    POOL      *diff_pool;              /* Pool for Differental backups */
348    POOL      *next_pool;              /* Next Pool for Migration */
349    char      *selection_pattern;
350    int        selection_type;
351    union {
352       JOB       *verify_job;          /* Job name to verify */
353    };
354    JOB       *jobdefs;                /* Job defaults */
355    alist     *run_cmds;               /* Run commands */
356    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
357
358    /* Methods */
359    char *name() const;
360 };
361
362 inline char *JOB::name() const { return hdr.name; }
363
364 #undef  MAX_FOPTS
365 #define MAX_FOPTS 34
366
367 /* File options structure */
368 struct FOPTS {
369    char opts[MAX_FOPTS];              /* options string */
370    alist regex;                       /* regex string(s) */
371    alist regexdir;                    /* regex string(s) for directories */
372    alist regexfile;                   /* regex string(s) for files */
373    alist wild;                        /* wild card strings */
374    alist wilddir;                     /* wild card strings for directories */
375    alist wildfile;                    /* wild card strings for files */
376    alist wildbase;                    /* wild card strings for files without '/' */
377    alist base;                        /* list of base names */
378    alist fstype;                      /* file system type limitation */
379    alist drivetype;                   /* drive type limitation */
380    char *reader;                      /* reader program */
381    char *writer;                      /* writer program */
382 };
383
384
385 /* This is either an include item or an exclude item */
386 struct INCEXE {
387    FOPTS *current_opts;               /* points to current options structure */
388    FOPTS **opts_list;                 /* options list */
389    int num_opts;                      /* number of options items */
390    alist name_list;                   /* filename list -- holds char * */
391 };
392
393 /*
394  *   FileSet Resource
395  *
396  */
397 class FILESET {
398 public:
399    RES   hdr;
400
401    bool new_include;                  /* Set if new include used */
402    INCEXE **include_items;            /* array of incexe structures */
403    int num_includes;                  /* number in array */
404    INCEXE **exclude_items;
405    int num_excludes;
406    bool have_MD5;                     /* set if MD5 initialized */
407    struct MD5Context md5c;            /* MD5 of include/exclude */
408    char MD5[30];                      /* base 64 representation of MD5 */
409    bool ignore_fs_changes;            /* Don't force Full if FS changed */
410    bool enable_vss;                   /* Enable Volume Shadow Copy */
411
412    /* Methods */
413    char *name() const;
414 };
415
416 inline char *FILESET::name() const { return hdr.name; }
417
418 /*
419  *   Schedule Resource
420  *
421  */
422 class SCHED {
423 public:
424    RES   hdr;
425
426    RUN *run;
427 };
428
429 /*
430  *   Counter Resource
431  */
432 class COUNTER {
433 public:
434    RES   hdr;
435
436    int32_t  MinValue;                 /* Minimum value */
437    int32_t  MaxValue;                 /* Maximum value */
438    int32_t  CurrentValue;             /* Current value */
439    COUNTER *WrapCounter;              /* Wrap counter name */
440    CAT     *Catalog;                  /* Where to store */
441    bool     created;                  /* Created in DB */
442    /* Methods */
443    char *name() const;
444 };
445
446 inline char *COUNTER::name() const { return hdr.name; }
447
448 /*
449  *   Pool Resource
450  *
451  */
452 class POOL {
453 public:
454    RES   hdr;
455
456    char *pool_type;                   /* Pool type */
457    char *label_format;                /* Label format string */
458    char *cleaning_prefix;             /* Cleaning label prefix */
459    int32_t LabelType;                 /* Bacula/ANSI/IBM label type */
460    uint32_t max_volumes;              /* max number of volumes */
461    utime_t VolRetention;              /* volume retention period in seconds */
462    utime_t VolUseDuration;            /* duration volume can be used */
463    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
464    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
465    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
466    utime_t MigrationTime;             /* Time to migrate to next pool */
467    uint64_t MigrationHighBytes;       /* When migration starts */
468    uint64_t MigrationLowBytes;        /* When migration stops */
469    POOL  *NextPool;                   /* Next pool for migration */
470    alist *storage;                    /* Where is device -- list of Storage to be used */
471    bool  use_catalog;                 /* maintain catalog for media */
472    bool  catalog_files;               /* maintain file entries in catalog */
473    bool  use_volume_once;             /* write on volume only once */
474    bool  purge_oldest_volume;         /* purge oldest volume */
475    bool  recycle_oldest_volume;       /* attempt to recycle oldest volume */
476    bool  recycle_current_volume;      /* attempt recycle of current volume */
477    bool  AutoPrune;                   /* default for pool auto prune */
478    bool  Recycle;                     /* default for media recycle yes/no */
479
480    /* Methods */
481    char *name() const;
482 };
483
484 inline char *POOL::name() const { return hdr.name; }
485
486
487
488
489 /* Define the Union of all the above
490  * resource structure definitions.
491  */
492 union URES {
493    DIRRES     res_dir;
494    CONRES     res_con;
495    CLIENT     res_client;
496    STORE      res_store;
497    CAT        res_cat;
498    JOB        res_job;
499    FILESET    res_fs;
500    SCHED      res_sch;
501    POOL       res_pool;
502    MSGS       res_msgs;
503    COUNTER    res_counter;
504    DEVICE     res_dev;
505    RES        hdr;
506    RUNSCRIPT  res_runscript;
507 };
508
509
510
511 /* Run structure contained in Schedule Resource */
512 class RUN {
513 public:
514    RUN *next;                         /* points to next run record */
515    int level;                         /* level override */
516    int Priority;                      /* priority override */
517    int job_type;
518    bool spool_data;                   /* Data spooling override */
519    bool spool_data_set;               /* Data spooling override given */
520    bool write_part_after_job;         /* Write part after job override */
521    bool write_part_after_job_set;     /* Write part after job override given */
522    
523    POOL *pool;                        /* Pool override */
524    POOL *full_pool;                   /* Pool override */
525    POOL *inc_pool;                    /* Pool override */
526    POOL *diff_pool;                   /* Pool override */
527    STORE *storage;                    /* Storage override */
528    MSGS *msgs;                        /* Messages override */
529    char *since;
530    int level_no;
531    int minute;                        /* minute to run job */
532    time_t last_run;                   /* last time run */
533    time_t next_run;                   /* next time to run */
534    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
535    char mday[nbytes_for_bits(31)];    /* bit set for each day of month */
536    char month[nbytes_for_bits(12)];   /* bit set for each month */
537    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
538    char wom[nbytes_for_bits(5)];      /* week of month */
539    char woy[nbytes_for_bits(54)];     /* week of year */
540 };