]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
Vacation work -- see tech log
[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    int enable_ssl;                    /* Use SSL for UA */
102    char *query_file;                  /* SQL query file */
103    char *working_directory;           /* WorkingDirectory */
104    const char *scripts_directory;     /* ScriptsDirectory */
105    char *pid_directory;               /* PidDirectory */
106    char *subsys_directory;            /* SubsysDirectory */
107    int require_ssl;                   /* Require SSL for all connections */
108    MSGS *messages;                    /* Daemon message handler */
109    uint32_t MaxConcurrentJobs;        /* Max concurrent jobs for whole director */
110    utime_t FDConnectTimeout;          /* timeout for connect in seconds */
111    utime_t SDConnectTimeout;          /* timeout in seconds */
112 };
113
114 /*
115  * Device Resource
116  *  This resource is a bit different from the other resources
117  *  because it is not defined in the Director 
118  *  by DEVICE { ... }, but rather by a "reference" such as
119  *  DEVICE = xxx; Then when the Director connects to the
120  *  SD, it requests the information about the device.
121  */
122 class DEVICE {
123 public:
124    RES hdr;
125
126    bool found;                        /* found with SD */
127    int num_writers;
128    int num_waiting;
129    int use_count;
130    bool open;
131    bool append;                       /* in append mode */
132    bool read;
133    bool labeled;
134    char VolumeName[MAX_NAME_LENGTH];
135    char MediaType[MAX_NAME_LENGTH];
136 };
137
138 /*
139  * Console ACL positions
140  */
141 enum {
142    Job_ACL = 0,
143    Client_ACL,
144    Storage_ACL,
145    Schedule_ACL,
146    Run_ACL,
147    Pool_ACL,
148    Command_ACL,
149    FileSet_ACL,
150    Catalog_ACL,
151    Num_ACL                            /* keep last */
152 };
153
154 /*
155  *    Console Resource
156  */
157 class CONRES {
158 public:
159    RES   hdr;
160    char *password;                    /* UA server password */
161    int enable_ssl;                    /* Use SSL */
162    alist *ACL_lists[Num_ACL];         /* pointers to ACLs */
163 };
164
165
166 /*
167  *   Catalog Resource
168  *
169  */
170 class CAT {
171 public:
172    RES   hdr;
173
174    int   db_port;                     /* Port -- not yet implemented */
175    char *db_address;                  /* host name for remote access */
176    char *db_socket;                   /* Socket for local access */
177    char *db_password;
178    char *db_user;
179    char *db_name;
180    int   mult_db_connections;         /* set if multiple connections wanted */
181 };
182
183
184 /*
185  *   Client Resource
186  *
187  */
188 class CLIENT {
189 public:
190    RES   hdr;
191
192    int   FDport;                      /* Where File daemon listens */
193    int   AutoPrune;                   /* Do automatic pruning? */
194    utime_t FileRetention;             /* file retention period in seconds */
195    utime_t JobRetention;              /* job retention period in seconds */
196    char *address;
197    char *password;
198    CAT *catalog;                      /* Catalog resource */
199    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
200    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
201    int enable_ssl;                    /* Use SSL */
202 };
203
204 /*
205  *   Store Resource
206  *
207  */
208 class STORE {
209 public:
210    RES   hdr;
211
212    int   SDport;                      /* port where Directors connect */
213    int   SDDport;                     /* data port for File daemon */
214    char *address;
215    char *password;
216    char *media_type;
217    alist *device;                     /* Device name(s) */
218    int  autochanger;                  /* set if autochanger */
219    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
220    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
221    int enable_ssl;                    /* Use SSL */
222
223    char *dev_name() const;
224    char *name() const;
225 };
226
227 inline char *STORE::dev_name() const
228
229    DEVICE *dev = (DEVICE *)device->first();
230    return dev->hdr.name;
231 }
232
233 inline char *STORE::name() const { return hdr.name; }
234
235
236 /*
237  *   Job Resource
238  */
239 class JOB {
240 public:
241    RES   hdr;
242
243    int   JobType;                     /* job type (backup, verify, restore */
244    int   JobLevel;                    /* default backup/verify level */
245    int   Priority;                    /* Job priority */
246    int   RestoreJobId;                /* What -- JobId to restore */
247    char *RestoreWhere;                /* Where on disk to restore -- directory */
248    char *RestoreBootstrap;            /* Bootstrap file */
249    char *RunBeforeJob;                /* Run program before Job */
250    char *RunAfterJob;                 /* Run program after Job */
251    char *RunAfterFailedJob;           /* Run program after Job that errs */
252    char *ClientRunBeforeJob;          /* Run client program before Job */
253    char *ClientRunAfterJob;           /* Run client program after Job */
254    char *WriteBootstrap;              /* Where to write bootstrap Job updates */
255    int   replace;                     /* How (overwrite, ..) */
256    utime_t MaxRunTime;                /* max run time in seconds */
257    utime_t MaxWaitTime;               /* max blocking time in seconds */
258    utime_t MaxStartDelay;             /* max start delay in seconds */
259    int PrefixLinks;                   /* prefix soft links with Where path */
260    int PruneJobs;                     /* Force pruning of Jobs */
261    int PruneFiles;                    /* Force pruning of Files */
262    int PruneVolumes;                  /* Force pruning of Volumes */
263    int SpoolAttributes;               /* Set to spool attributes in SD */
264    int spool_data;                    /* Set to spool data in SD */
265    int rerun_failed_levels;           /* Upgrade to rerun failed levels */
266    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
267    int RescheduleOnError;             /* Set to reschedule on error */
268    int RescheduleTimes;               /* Number of times to reschedule job */
269    utime_t RescheduleInterval;        /* Reschedule interval */
270    utime_t JobRetention;              /* job retention period in seconds */
271    bool write_part_after_job;         /* Set to write part after job in SD */
272    
273    MSGS      *messages;               /* How and where to send messages */
274    SCHED     *schedule;               /* When -- Automatic schedule */
275    CLIENT    *client;                 /* Who to backup */
276    FILESET   *fileset;                /* What to backup -- Fileset */
277    alist     *storage;                /* Where is device -- Storage daemon */
278    POOL      *pool;                   /* Where is media -- Media Pool */
279    POOL      *full_pool;              /* Pool for Full backups */
280    POOL      *inc_pool;               /* Pool for Incremental backups */
281    POOL      *dif_pool;               /* Pool for Differental backups */
282    JOB       *verify_job;             /* Job name to verify */
283    JOB       *jobdefs;                /* Job defaults */
284    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
285 };
286
287 #undef  MAX_FOPTS
288 #define MAX_FOPTS 34
289
290 /* File options structure */
291 struct FOPTS {
292    char opts[MAX_FOPTS];              /* options string */
293    alist regex;                       /* regex string(s) */
294    alist regexdir;                    /* regex string(s) for directories */
295    alist regexfile;                   /* regex string(s) for files */
296    alist wild;                        /* wild card strings */
297    alist wilddir;                     /* wild card strings for directories */
298    alist wildfile;                    /* wild card strings for files */
299    alist base;                        /* list of base names */
300    alist fstype;                      /* file system type limitation */
301    char *reader;                      /* reader program */
302    char *writer;                      /* writer program */
303 };
304
305
306 /* This is either an include item or an exclude item */
307 struct INCEXE {
308    FOPTS *current_opts;               /* points to current options structure */
309    FOPTS **opts_list;                 /* options list */
310    int num_opts;                      /* number of options items */
311    alist name_list;                   /* filename list -- holds char * */
312 };
313
314 /*
315  *   FileSet Resource
316  *
317  */
318 class FILESET {
319 public:
320    RES   hdr;
321
322    bool new_include;                  /* Set if new include used */
323    INCEXE **include_items;            /* array of incexe structures */
324    int num_includes;                  /* number in array */
325    INCEXE **exclude_items;
326    int num_excludes;
327    bool have_MD5;                     /* set if MD5 initialized */
328    struct MD5Context md5c;            /* MD5 of include/exclude */
329    char MD5[30];                      /* base 64 representation of MD5 */
330    int ignore_fs_changes;             /* Don't force Full if FS changed */
331 };
332
333
334 /*
335  *   Schedule Resource
336  *
337  */
338 class SCHED {
339 public:
340    RES   hdr;
341
342    RUN *run;
343 };
344
345 /*
346  *   Counter Resource
347  */
348 class COUNTER {
349 public:
350    RES   hdr;
351
352    int32_t  MinValue;                 /* Minimum value */
353    int32_t  MaxValue;                 /* Maximum value */
354    int32_t  CurrentValue;             /* Current value */
355    COUNTER *WrapCounter;              /* Wrap counter name */
356    CAT     *Catalog;                  /* Where to store */
357    bool     created;                  /* Created in DB */
358 };
359
360 /*
361  *   Pool Resource
362  *
363  */
364 class POOL {
365 public:
366    RES   hdr;
367
368    char *pool_type;                   /* Pool type */
369    char *label_format;                /* Label format string */
370    char *cleaning_prefix;             /* Cleaning label prefix */
371    int   LabelType;                   /* Bacula/ANSI/IBM label type */
372    int   use_catalog;                 /* maintain catalog for media */
373    int   catalog_files;               /* maintain file entries in catalog */
374    int   use_volume_once;             /* write on volume only once */
375    int   accept_any_volume;           /* accept any volume */
376    int   purge_oldest_volume;         /* purge oldest volume */
377    int   recycle_oldest_volume;       /* attempt to recycle oldest volume */
378    int   recycle_current_volume;      /* attempt recycle of current volume */
379    uint32_t max_volumes;              /* max number of volumes */
380    utime_t VolRetention;              /* volume retention period in seconds */
381    utime_t VolUseDuration;            /* duration volume can be used */
382    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
383    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
384    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
385    int   AutoPrune;                   /* default for pool auto prune */
386    int   Recycle;                     /* default for media recycle yes/no */
387 };
388
389
390
391
392 /* Define the Union of all the above
393  * resource structure definitions.
394  */
395 union URES {
396    DIRRES     res_dir;
397    CONRES     res_con;
398    CLIENT     res_client;
399    STORE      res_store;
400    CAT        res_cat;
401    JOB        res_job;
402    FILESET    res_fs;
403    SCHED      res_sch;
404    POOL       res_pool;
405    MSGS       res_msgs;
406    COUNTER    res_counter;
407    DEVICE     res_dev;
408    RES        hdr;
409 };
410
411
412
413 /* Run structure contained in Schedule Resource */
414 class RUN {
415 public:
416    RUN *next;                         /* points to next run record */
417    int level;                         /* level override */
418    int Priority;                      /* priority override */
419    int job_type;
420    bool spool_data;                   /* Data spooling override */
421    bool spool_data_set;               /* Data spooling override given */
422    bool write_part_after_job;         /* Write part after job override */
423    bool write_part_after_job_set;     /* Write part after job override given */
424    
425    POOL *pool;                        /* Pool override */
426    POOL *full_pool;                   /* Pool override */
427    POOL *inc_pool;                    /* Pool override */
428    POOL *dif_pool;                    /* Pool override */
429    STORE *storage;                    /* Storage override */
430    MSGS *msgs;                        /* Messages override */
431    char *since;
432    int level_no;
433    int minute;                        /* minute to run job */
434    time_t last_run;                   /* last time run */
435    time_t next_run;                   /* next time to run */
436    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
437    char mday[nbytes_for_bits(31)];    /* bit set for each day of month */
438    char month[nbytes_for_bits(12)];   /* bit set for each month */
439    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
440    char wom[nbytes_for_bits(5)];      /* week of month */
441    char woy[nbytes_for_bits(54)];     /* week of year */
442 };