]> git.sur5r.net Git - bacula/bacula/blob - bacula/src/dird/dird_conf.h
Define foreach_res() + work on jobdefs + bstrftime_nc
[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-2003 2002 Kern Sibbald and John Walker
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 #define R_FIRST               1001
34
35 #define R_DIRECTOR            1001
36 #define R_CLIENT              1002
37 #define R_JOB                 1003
38 #define R_STORAGE             1004
39 #define R_CATALOG             1005
40 #define R_SCHEDULE            1006
41 #define R_FILESET             1007
42 #define R_GROUP               1008
43 #define R_POOL                1009
44 #define R_MSGS                1010
45 #define R_COUNTER             1011
46 #define R_CONSOLE             1012
47 #define R_JOBDEFS             1013
48
49 #define R_LAST                R_JOBDEFS    
50
51 /*
52  * Some resource attributes
53  */
54 #define R_NAME                1020
55 #define R_ADDRESS             1021
56 #define R_PASSWORD            1022
57 #define R_TYPE                1023
58 #define R_BACKUP              1024
59
60
61 /* Used for certain KeyWord tables */
62 struct s_kw {       
63    char *name;
64    int token;   
65 };
66
67 /* Job Level keyword structure */
68 struct s_jl {
69    char *level_name;                  /* level keyword */
70    int  level;                        /* level */
71    int  job_type;                     /* JobType permitting this level */
72 };
73
74 /* Job Type keyword structure */
75 struct s_jt {
76    char *type_name;
77    int job_type;
78 };
79
80 /* Definition of the contents of each Resource */
81 /* Needed for forward references */
82 struct SCHED;
83 struct CLIENT;
84 struct FILESET;
85 struct POOL;
86 struct RUN;
87
88 /* 
89  *   Director Resource  
90  *
91  */
92 struct DIRRES {
93    RES   hdr;
94    int   DIRport;                     /* where we listen -- UA port server port */
95    char *DIRaddr;                     /* bind address */
96    char *password;                    /* Password for UA access */
97    int enable_ssl;                    /* Use SSL for UA */
98    char *query_file;                  /* SQL query file */
99    char *working_directory;           /* WorkingDirectory */
100    char *pid_directory;               /* PidDirectory */
101    char *subsys_directory;            /* SubsysDirectory */
102    int require_ssl;                   /* Require SSL for all connections */
103    MSGS *messages;                    /* Daemon message handler */
104    uint32_t MaxConcurrentJobs;        /* Max concurrent jobs for whole director */
105    utime_t FDConnectTimeout;          /* timeout for connect in seconds */
106    utime_t SDConnectTimeout;          /* timeout in seconds */
107 };
108
109 /* 
110  *    Console Resource
111  */
112 struct CONRES {
113    RES   hdr;
114    char *password;                    /* UA server password */
115    int enable_ssl;                    /* Use SSL */
116 };
117
118
119 /*
120  *   Catalog Resource
121  *
122  */
123 struct CAT {
124    RES   hdr;
125
126    int   db_port;                     /* Port -- not yet implemented */
127    char *db_address;                  /* host name for remote access */
128    char *db_socket;                   /* Socket for local access */
129    char *db_password;
130    char *db_user;
131    char *db_name;
132 };
133
134
135 /*
136  *   Client Resource
137  *
138  */
139 struct CLIENT {
140    RES   hdr;
141
142    int   FDport;                      /* Where File daemon listens */
143    int   AutoPrune;                   /* Do automatic pruning? */
144    utime_t FileRetention;             /* file retention period in seconds */
145    utime_t JobRetention;              /* job retention period in seconds */
146    char *address;
147    char *password;
148    CAT *catalog;                      /* Catalog resource */
149    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
150    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
151    int enable_ssl;                    /* Use SSL */
152 };
153
154 /*
155  *   Store Resource
156  * 
157  */
158 struct STORE {
159    RES   hdr;
160
161    int   SDport;                      /* port where Directors connect */
162    int   SDDport;                     /* data port for File daemon */
163    char *address;
164    char *password;
165    char *media_type;
166    char *dev_name;   
167    int  autochanger;                  /* set if autochanger */
168    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
169    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
170    int enable_ssl;                    /* Use SSL */
171 };
172
173
174 /*
175  *   Job Resource
176  */
177 struct JOB {
178    RES   hdr;
179
180    int   JobType;                     /* job type (backup, verify, restore */
181    int   level;                       /* default backup/verify level */
182    int   Priority;                    /* Job priority */
183    int   RestoreJobId;                /* What -- JobId to restore */
184    char *RestoreWhere;                /* Where on disk to restore -- directory */
185    char *RestoreBootstrap;            /* Bootstrap file */
186    char *RunBeforeJob;                /* Run program before Job */
187    char *RunAfterJob;                 /* Run program after Job */
188    char *RunAfterFailedJob;           /* Run program after Job that errs */
189    char *ClientRunBeforeJob;          /* Run client program before Job */
190    char *ClientRunAfterJob;           /* Run client program after Job */
191    char *WriteBootstrap;              /* Where to write bootstrap Job updates */
192    int   replace;                     /* How (overwrite, ..) */
193    utime_t MaxRunTime;                /* max run time in seconds */
194    utime_t MaxWaitTime;               /* max blocking time in seconds */
195    utime_t MaxStartDelay;             /* max start delay in seconds */
196    int PrefixLinks;                   /* prefix soft links with Where path */
197    int PruneJobs;                     /* Force pruning of Jobs */
198    int PruneFiles;                    /* Force pruning of Files */
199    int PruneVolumes;                  /* Force pruning of Volumes */
200    int SpoolAttributes;               /* Set to spool attributes in SD */
201    uint32_t MaxConcurrentJobs;        /* Maximume concurrent jobs */
202    int RescheduleOnError;             /* Set to reschedule on error */
203    int RescheduleTimes;               /* Number of times to reschedule job */
204    utime_t RescheduleInterval;        /* Reschedule interval */
205    utime_t JobRetention;              /* job retention period in seconds */
206   
207    MSGS      *messages;               /* How and where to send messages */
208    SCHED     *schedule;               /* When -- Automatic schedule */
209    CLIENT    *client;                 /* Who to backup */
210    FILESET   *fileset;                /* What to backup -- Fileset */
211    STORE     *storage;                /* Where is device -- Storage daemon */
212    POOL      *pool;                   /* Where is media -- Media Pool */
213    JOB       *verify_job;             /* Job name to verify */
214    JOB       *jobdefs;                /* Job defaults */
215    uint32_t NumConcurrentJobs;        /* number of concurrent jobs running */
216 };
217
218 #define MAX_FOPTS 30
219
220 /* File options structure */
221 struct FOPTS {
222    char opts[MAX_FOPTS];              /* options string */
223    alist match;                       /* match string(s) */
224    alist base_list;                   /* list of base names */
225 };
226
227
228 /* This is either an include item or an exclude item */
229 struct INCEXE {
230    FOPTS *current_opts;               /* points to current options structure */
231    FOPTS **opts_list;                 /* options list */
232    int num_opts;                      /* number of options items */
233    alist name_list;                   /* filename list -- holds char * */
234 };
235
236 /* 
237  *   FileSet Resource
238  *
239  */
240 struct FILESET {
241    RES   hdr;
242
243    int new_include;                   /* Set if new include used */
244    INCEXE **include_items;            /* array of incexe structures */
245    int num_includes;                  /* number in array */
246    INCEXE **exclude_items;
247    int num_excludes;
248    int have_MD5;                      /* set if MD5 initialized */
249    struct MD5Context md5c;            /* MD5 of include/exclude */
250    char MD5[30];                      /* base 64 representation of MD5 */
251 };
252
253  
254 /* 
255  *   Schedule Resource
256  *
257  */
258 struct SCHED {
259    RES   hdr;
260
261    RUN *run;
262 };
263
264 /*
265  *   Group Resource (not used)
266  *
267  */
268 struct GROUP {
269    RES   hdr;
270 };
271
272 /*
273  *   Counter Resource
274  */
275 struct COUNTER {
276    RES   hdr;
277
278    int32_t  MinValue;                 /* Minimum value */
279    int32_t  MaxValue;                 /* Maximum value */
280    int32_t  CurrentValue;             /* Current value */
281    COUNTER *WrapCounter;              /* Wrap counter name */
282    CAT     *Catalog;                  /* Where to store */
283    bool     created;                  /* Created in DB */
284 };
285
286 /*
287  *   Pool Resource   
288  *
289  */
290 struct POOL {
291    RES   hdr;
292
293    char *pool_type;                   /* Pool type */
294    char *label_format;                /* Label format string */
295    char *cleaning_prefix;             /* Cleaning label prefix */
296    int   use_catalog;                 /* maintain catalog for media */
297    int   catalog_files;               /* maintain file entries in catalog */
298    int   use_volume_once;             /* write on volume only once */
299    int   accept_any_volume;           /* accept any volume */
300    int   purge_oldest_volume;         /* purge oldest volume */
301    int   recycle_oldest_volume;       /* attempt to recycle oldest volume */
302    int   recycle_current_volume;      /* attempt recycle of current volume */
303    uint32_t max_volumes;              /* max number of volumes */
304    utime_t VolRetention;              /* volume retention period in seconds */
305    utime_t VolUseDuration;            /* duration volume can be used */
306    uint32_t MaxVolJobs;               /* Maximum jobs on the Volume */
307    uint32_t MaxVolFiles;              /* Maximum files on the Volume */
308    uint64_t MaxVolBytes;              /* Maximum bytes on the Volume */
309    int   AutoPrune;                   /* default for pool auto prune */
310    int   Recycle;                     /* default for media recycle yes/no */
311 };
312
313
314 /* Define the Union of all the above
315  * resource structure definitions.
316  */
317 union URES {
318    DIRRES     res_dir;
319    CONRES     res_con;
320    CLIENT     res_client;
321    STORE      res_store;
322    CAT        res_cat;
323    JOB        res_job;
324    FILESET    res_fs;
325    SCHED      res_sch;
326    GROUP      res_group;
327    POOL       res_pool;
328    MSGS       res_msgs;
329    COUNTER    res_counter;
330    RES        hdr;
331 };
332
333
334
335 /* Run structure contained in Schedule Resource */
336 struct RUN {
337    RUN *next;                         /* points to next run record */
338    int level;                         /* level override */
339    int Priority;                      /* priority override */
340    int job_type;  
341    POOL *pool;                        /* Pool override */
342    STORE *storage;                    /* Storage override */
343    MSGS *msgs;                        /* Messages override */
344    char *since;
345    int level_no;
346    int minute;                        /* minute to run job */
347    time_t last_run;                   /* last time run */
348    time_t next_run;                   /* next time to run */
349    char hour[nbytes_for_bits(24)];    /* bit set for each hour */
350    char mday[nbytes_for_bits(31)];    /* bit set for each day of month */
351    char month[nbytes_for_bits(12)];   /* bit set for each month */
352    char wday[nbytes_for_bits(7)];     /* bit set for each day of the week */
353    char wom[nbytes_for_bits(5)];      /* week of month */
354    char woy[nbytes_for_bits(54)];     /* week of year */
355 };