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