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