]> git.sur5r.net Git - bacula/docs/blob - docs/manual/dirdconf.tex
047b40c83ad35db04519811091b2ec9f55f6ef6e
[bacula/docs] / docs / manual / dirdconf.tex
1 %%
2 %%
3
4 \chapter{Configuring the Director}
5 \label{DirectorChapter}
6 \index[general]{Director!Configuring the}
7 \index[general]{Configuring the Director}
8
9 Of all the configuration files needed to run {\bf Bacula}, the Director's is
10 the most complicated, and the one that you will need to modify the most often
11 as you add clients or modify the FileSets. 
12
13 For a general discussion of configuration files and resources including the
14 data types recognized by {\bf Bacula}. Please see the 
15 \ilink{Configuration}{ConfigureChapter} chapter of this manual. 
16
17 \section{Director Resource Types}
18 \index[general]{Types!Director Resource}
19 \index[general]{Director Resource Types}
20
21 Director resource type may be one of the following: 
22
23 Job, JobDefs, Client, Storage, Catalog, Schedule, FileSet, Pool, Director,  or
24 Messages. We present them here in the most logical order for defining them: 
25
26 \begin{itemize}
27 \item 
28    \ilink{Director}{DirectorResource4} -- to  define the Director's
29    name and its access password used for authenticating the Console program.
30    Only a single  Director resource definition may appear in the Director's 
31    configuration file.  If you have either {\bf /dev/random} or  {\bf bc} on your
32    machine, Bacula will generate a random password during the configuration
33    process, otherwise it will  be left blank. 
34 \item 
35    \ilink{Job}{JobResource} -- to define the backup/restore Jobs 
36    and to tie together the Client, FileSet and Schedule resources to  be used
37    for each Job.  
38 \item 
39    \ilink{JobDefs}{JobDefsResource} -- optional resource for 
40    providing defaults for Job resources.  
41 \item 
42    \ilink{Schedule}{ScheduleResource} -- to define when a Job is to 
43    be automatically run by {\bf Bacula's} internal scheduler.  
44 \item 
45    \ilink{FileSet}{FileSetResource} -- to define the set of files 
46    to be backed up for each Client. 
47 \item 
48    \ilink{Client}{ClientResource2} -- to define what Client is  to be
49    backed up.  
50 \item 
51    \ilink{Storage}{StorageResource2} -- to define on what physical
52    device the Volumes should be mounted. 
53 \item 
54    \ilink{Pool}{PoolResource} -- to define the pool of Volumes
55    that can be used for a particular Job. 
56 \item 
57    \ilink{Catalog}{CatalogResource} -- to define in what database to
58    keep the list of files and the Volume names where they are backed up.  
59 \item 
60    \ilink{Messages}{MessagesChapter} -- to define where error  and
61    information messages are to be sent or logged. 
62 \end{itemize}
63
64 \section{The Director Resource}
65 \label{DirectorResource4}
66 \index[general]{Director Resource}
67 \index[general]{Resource!Director}
68
69 The Director resource defines the attributes of the Directors running on the
70 network. In the current implementation, there is only a single Director
71 resource, but the final design will contain multiple Directors to maintain
72 index and media database redundancy. 
73
74 \begin{description}
75
76 \item [Director]
77    \index[dir]{Director}
78    Start of the Director resource. One and only one  director resource must be
79 supplied.  
80
81 \item [Name = \lt{}name\gt{}]
82    \index[dir]{Name}
83    \index[dir]{Directive!Name}
84    The director name used by the system  administrator. This directive is
85 required.  
86
87 \item [Description = \lt{}text\gt{}]
88    \index[dir]{Description}
89    \index[dir]{Directive!Description}
90    The text field contains a  description of the Director that will be displayed
91 in the  graphical user interface. This directive is optional.  
92
93 \item [Password = \lt{}UA-password\gt{}]
94    \index[dir]{Password}
95    \index[dir]{Directive!Password}
96    Specifies the password that  must be supplied for the default Bacula Console
97    to be  authorized. The same password must appear in the  {\bf Director}
98    resource of the Console configuration file.  For added security, the password
99    is never actually passed  across the network but rather a challenge response
100    hash code  created with the password. This directive is required. If you  have
101    either {\bf /dev/random} or {\bf bc} on your machine,  Bacula will generate a
102    random password during the  configuration process, otherwise it will be left
103    blank and  you must manually supply it.  
104
105 \item [Messages = \lt{}Messages-resource-name\gt{}]
106    \index[dir]{Messages}
107    \index[dir]{Directive!Messages}
108    The messages resource  specifies where to deliver Director messages that are
109    not associated  with a specific Job. Most messages are specific to a job and
110    will  be directed to the Messages resource specified by the job. However, 
111    there are a few messages that can occur when no job is running.  This
112    directive is required.  
113
114 \item [Working Directory = \lt{}Directory\gt{}]
115    \index[dir]{Working Directory}
116    \index[dir]{Directive!Working Directory}
117    This directive  is mandatory and specifies a directory in which the Director 
118    may put its status files. This directory should be used only  by Bacula but
119    may be shared by other Bacula daemons. However, please note, if this
120    directory is shared with other Bacula daemons (the File daemon and Storage
121    daemon), you must ensure that the {\bf Name} given to each daemon is
122    unique so that the temporary filenames used do not collide.  By default
123    the Bacula configure process creates unique daemon names by postfixing them
124    with -dir, -fd, and -sd. Standard shell expansion of the {\bf
125    Directory}  is done when the configuration file is read so that values such 
126    as {\bf \$HOME} will be properly expanded. This directive is required.
127    The working directory specified must already exist and be
128    readable and writable by the Bacula daemon referencing it.
129
130    If you have specified a Director user and/or a Director group on your
131    ./configure line with {\bf {-}{-}with-dir-user} and/or 
132    {\bf {-}{-}with-dir-group} the Working Directory owner and group will
133    be set to those values.
134
135 \item [Pid Directory = \lt{}Directory\gt{}]
136    \index[dir]{Pid Directory}
137    \index[dir]{Directive!Pid Directory}
138    This directive  is mandatory and specifies a directory in which the Director 
139    may put its process Id file. The process Id file is used to  shutdown
140    Bacula and to prevent multiple copies of  Bacula from running simultaneously. 
141    Standard shell expansion of the {\bf Directory}  is done when the
142    configuration file is read so that values such  as {\bf \$HOME} will be
143    properly expanded.  
144
145    The PID directory specified must already exist and be
146    readable and writable by the Bacula daemon referencing it
147
148    Typically on Linux systems, you will set this to:  {\bf /var/run}. If you are
149    not installing Bacula in the  system directories, you can use the {\bf Working
150    Directory} as  defined above.  This directive is required.  
151
152 \item [Scripts Directory = \lt{}Directory\gt{}]
153    \index[dir]{Scripts Directory}
154    \index[dir]{Directive!Scripts Directory}
155    This directive is optional and, if defined, specifies a directory in
156    which the Director will look for the Python startup script {\bf
157    DirStartup.py}.  This directory may be shared by other Bacula daemons.
158    Standard shell expansion of the directory is done when the configuration
159    file is read so that values such as {\bf \$HOME} will be properly
160    expanded.
161
162 \item [QueryFile = \lt{}Path\gt{}]
163    \index[dir]{QueryFile}
164    \index[dir]{Directive!QueryFile}
165    This directive is mandatory and specifies a directory and file in which
166    the Director can find the canned SQL statements for the {\bf Query}
167    command of the Console.  Standard shell expansion of the {\bf Path} is
168    done when the configuration file is read so that values such as {\bf
169    \$HOME} will be properly expanded.  This directive is required.
170
171 \label{DirMaxConJobs}
172 \item [Maximum Concurrent Jobs = \lt{}number\gt{}]
173 \index[dir]{Maximum Concurrent Jobs}
174 \index[dir]{Directive!Maximum Concurrent Jobs}
175 \index[general]{Simultaneous Jobs}
176 \index[general]{Concurrent Jobs}
177    where \lt{}number\gt{}  is the maximum number of total Director Jobs that
178    should run  concurrently. The default is set to 1, but you may set it to a 
179    larger number.  
180
181    Please  note that the Volume format becomes much more complicated with 
182    multiple simultaneous jobs, consequently, restores can take much  longer if
183    Bacula must sort through interleaved volume blocks from  multiple simultaneous
184    jobs. This can be avoided by having each  simultaneously running job write to
185    a different volume or  by using data spooling, which will first spool the data
186    to disk simultaneously, then write each spool file to the  volume in
187    sequence.  
188
189    There may also still be some cases where directives such as  {\bf Maximum
190    Volume Jobs} are not properly synchronized with  multiple simultaneous jobs
191    (subtle timing issues can arise),  so careful testing is recommended. 
192
193    At the current time,  there is no configuration parameter set to limit the
194    number of console connections. A maximum of five simultaneous console 
195    connections are permitted.  
196
197 \item [FD Connect Timeout = \lt{}time\gt{}]
198    \index[dir]{FD Connect Timeout}
199    \index[dir]{Directive!FD Connect Timeout}
200    where {\bf time} is the time that the Director should continue
201    attempting to contact the File daemon to start a job, and after which
202    the Director will cancel the job.  The default is 30 minutes.
203
204 \item [SD Connect Timeout = \lt{}time\gt{}]
205    \index[dir]{SD Connect Timeout}
206    \index[dir]{Directive!SD Connect Timeout}
207    where {\bf time} is the time that the Director should continue
208    attempting to contact the Storage daemon to start a job, and after which
209    the Director will cancel the job.  The default is 30 minutes.
210
211 \item [DirAddresses = \lt{}IP-address-specification\gt{}]
212    \index[dir]{DirAddresses}
213    \index[dir]{Address}
214    \index[general]{Address}
215    \index[dir]{Directive!DirAddresses}
216    Specify the ports and addresses on which the Director daemon will listen
217    for Bacula Console connections.  Probably the simplest way to explain
218    this is to show an example:
219
220 \footnotesize
221 \begin{verbatim}
222  DirAddresses  = { 
223     ip = { addr = 1.2.3.4; port = 1205;}
224     ipv4 = {
225         addr = 1.2.3.4; port = http;}
226     ipv6 = {
227         addr = 1.2.3.4;
228         port = 1205;
229     }
230     ip = {
231         addr = 1.2.3.4
232         port = 1205
233     }
234     ip = { addr = 1.2.3.4 }
235     ip = { addr = 201:220:222::2 }
236     ip = {
237         addr = bluedot.thun.net
238     }
239 }
240 \end{verbatim}
241 \normalsize
242
243 where ip, ip4, ip6, addr, and port are all keywords. Note, that  the address
244 can be specified as either a dotted quadruple, or  IPv6 colon notation, or as
245 a symbolic name (only in the ip specification).  Also, port can be specified
246 as a number or as the mnemonic value from  the /etc/services file.  If a port
247 is not specified, the default will be used. If an ip  section is specified,
248 the resolution can be made either by IPv4 or  IPv6. If ip4 is specified, then
249 only IPv4 resolutions will be permitted,  and likewise with ip6. 
250
251 Please note that if you use the DirAddresses directive, you must
252 not use either a DirPort or a DirAddress directive in the same 
253 resource.
254
255 \item [DirPort = \lt{}port-number\gt{}]
256    \index[dir]{DirPort}
257    \index[dir]{Directive!DirPort}
258    Specify the port (a positive  integer) on which the  Director daemon will
259 listen for Bacula Console connections.  This same port number must be
260 specified in the Director resource  of the Console configuration file. The
261 default is 9101, so  normally this directive need not be specified.  This
262 directive should not be used if you specify DirAddresses (not plural)
263 directive.
264
265 \item [DirAddress = \lt{}IP-Address\gt{}]
266    \index[dir]{DirAddress}
267    \index[dir]{Directive!DirAddress}
268    This directive is optional,  but if it is specified, it will cause the
269 Director server (for  the Console program) to bind to the specified {\bf
270 IP-Address},  which is either a domain name or an IP address specified as a 
271 dotted quadruple in string or quoted string format.  If this directive is not
272 specified, the Director  will bind to any available address (the default). 
273 Note, unlike the DirAddresses specification noted above, this  directive only
274 permits a single address to be specified.  This directive should not be used if you
275 specify a DirAddresses (note plural) directive. 
276 \end{description}
277
278 The following is an example of a valid Director resource definition: 
279
280 \footnotesize
281 \begin{verbatim}
282 Director {
283   Name = HeadMan
284   WorkingDirectory = "$HOME/bacula/bin/working"
285   Password = UA_password
286   PidDirectory = "$HOME/bacula/bin/working"
287   QueryFile = "$HOME/bacula/bin/query.sql"
288   Messages = Standard
289 }
290 \end{verbatim}
291 \normalsize
292
293 \section{The Job Resource}
294 \label{JobResource}
295 \index[general]{Resource!Job}
296 \index[general]{Job Resource}
297
298 The Job resource defines a Job (Backup, Restore, ...) that Bacula must
299 perform. Each Job resource definition contains the name of a Client and
300 a FileSet to backup, the Schedule for the Job, where the data
301 are to be stored, and what media Pool can be used. In effect, each Job
302 resource must specify What, Where, How, and When or FileSet, Storage,
303 Backup/Restore/Level, and Schedule respectively. Note, the FileSet must
304 be specified for a restore job for historical reasons, but it is no longer used.
305
306 Only a single type ({\bf Backup}, {\bf Restore}, ...) can be specified for any
307 job. If you want to backup multiple FileSets on the same Client or multiple
308 Clients, you must define a Job for each one. 
309
310 Note, you define only a single Job to do the Full, Differential, and
311 Incremental backups since the different backup levels are tied together by 
312 a unique Job name.  Normally, you will have only one Job per Client, but   
313 if a client has a really huge number of files (more than several million),
314 you might want to split it into to Jobs each with a different FileSet
315 covering only part of the total files.
316                
317
318 \begin{description}
319
320 \item [Job]
321    \index[dir]{Job}
322    \index[dir]{Directive!Job}
323    Start of the Job resource. At least one Job  resource is required. 
324
325 \item [Name = \lt{}name\gt{}]
326    \index[dir]{Name}
327    \index[dir]{Directive!Name}
328    The Job name. This name can be specified  on the {\bf Run} command in the
329    console program to start a job. If the  name contains spaces, it must be
330    specified between quotes. It is  generally a good idea to give your job the
331    same name as the Client  that it will backup. This permits easy
332    identification of jobs.  
333
334    When the job actually runs, the unique Job Name will consist  of the name you
335    specify here followed by the date and time the  job was scheduled for
336    execution. This directive is required. 
337
338 \item [Enabled = \lt{}yes|no\gt{}]
339   \index[dir]{Enable}
340   \index[dir]{Directive!Enable}
341   This directive allows you to enable or disable automatic execution
342   via the scheduler of a Job.
343
344 \item [Type = \lt{}job-type\gt{}]
345    \index[dir]{Type}
346    \index[dir]{Directive!Type}
347    The {\bf Type} directive specifies  the Job type, which may be one of the
348    following: {\bf Backup},  {\bf Restore}, {\bf Verify}, or {\bf Admin}. This
349    directive  is required. Within a particular Job Type, there are also Levels 
350    as discussed in the next item.  
351
352 \begin{description}
353
354 \item [Backup]
355    \index[dir]{Backup}
356    Run a backup Job. Normally you will  have at least one Backup job for each
357    client you want  to save. Normally, unless you turn off cataloging,  most all
358    the important statistics and data concerning  files backed up will be placed
359    in the catalog. 
360
361 \item [Restore]
362    \index[dir]{Restore}
363    Run a restore Job.  Normally, you will specify only one Restore job
364    which acts as a sort of prototype that you will modify using the console
365    program in order to perform restores.  Although certain basic
366    information from a Restore job is saved in the catalog, it is very
367    minimal compared to the information stored for a Backup job -- for
368    example, no File database entries are generated since no Files are
369    saved.
370
371 \item [Verify]
372    \index[dir]{Verify}
373    Run a verify Job. In general, {\bf verify}  jobs permit you to compare the
374    contents of the catalog  to the file system, or to what was backed up. In
375    addition,  to verifying that a tape that was written can be read,  you can
376    also use {\bf verify} as a sort of tripwire  intrusion detection.  
377
378 \item [Admin]
379    \index[dir]{Admin}
380    Run an admin Job. An {\bf Admin} job can  be used to periodically run catalog
381    pruning, if you  do not want to do it at the end of each {\bf Backup}  Job.
382    Although an Admin job is recorded in the  catalog, very little data is saved. 
383 \end{description}
384
385 \label{Level}
386
387 \item [Level = \lt{}job-level\gt{}]
388 \index[dir]{Level}
389 \index[dir]{Directive!Level}
390    The Level directive specifies the default Job level to be run.  Each
391    different Job Type (Backup, Restore, ...) has a different set of Levels
392    that can be specified.  The Level is normally overridden by a different
393    value that is specified in the {\bf Schedule} resource.  This directive
394    is not required, but must be specified either by a {\bf Level} directive
395    or as an override specified in the {\bf Schedule} resource.
396
397 For a {\bf Backup} Job, the Level may be one of the  following:  
398
399 \begin{description}
400
401 \item [Full]
402 \index[dir]{Full}
403    When the Level is set to Full all files in the FileSet whether or not
404    they have changed will be backed up.
405
406 \item [Incremental]
407    \index[dir]{Incremental}
408    When the Level is set to Incremental all files specified in the FileSet
409    that have changed since the last successful backup of the the same Job
410    using the same FileSet and Client, will be backed up.  If the Director
411    cannot find a previous valid Full backup then the job will be upgraded
412    into a Full backup.  When the Director looks for a valid backup record
413    in the catalog database, it looks for a previous Job with:
414
415 \begin{itemize}
416 \item The same Job name.  
417 \item The same Client name.  
418 \item The same FileSet (any change to the definition of  the FileSet such as
419    adding or deleting a file in the  Include or Exclude sections constitutes a
420    different FileSet.  
421 \item The Job was a Full, Differential, or Incremental backup.  
422 \item The Job terminated normally (i.e. did not fail or was not  canceled).  
423 \end{itemize}
424
425    If all the above conditions do not hold, the Director will upgrade  the
426    Incremental to a Full save. Otherwise, the Incremental  backup will be
427    performed as requested.  
428
429    The File daemon (Client) decides which files to backup for an
430    Incremental backup by comparing start time of the prior Job (Full,
431    Differential, or Incremental) against the time each file was last
432    "modified" (st\_mtime) and the time its attributes were last
433    "changed"(st\_ctime).  If the file was modified or its attributes
434    changed on or after this start time, it will then be backed up.
435
436    Some virus scanning software may change st\_ctime while
437    doing the scan.  For example, if the virus scanning program attempts to
438    reset the access time (st\_atime), which Bacula does not use, it will
439    cause st\_ctime to change and hence Bacula will backup the file during
440    an Incremental or Differential backup.  In the case of Sophos virus
441    scanning, you can prevent it from resetting the access time (st\_atime)
442    and hence changing st\_ctime by using the {\bf \verb:--:no-reset-atime}
443    option.  For other software, please see their manual.
444
445    When Bacula does an Incremental backup, all modified files that are
446    still on the system are backed up.  However, any file that has been
447    deleted since the last Full backup remains in the Bacula catalog, which
448    means that if between a Full save and the time you do a restore, some
449    files are deleted, those deleted files will also be restored.  The
450    deleted files will no longer appear in the catalog after doing another
451    Full save.  However, to remove deleted files from the catalog during an
452    Incremental backup is quite a time consuming process and not currently
453    implemented in Bacula.
454
455    In addition, if you move a directory rather than copy it, the files in
456    it do not have their modification time (st\_mtime) or their attribute
457    change time (st\_ctime) changed.  As a consequence, those files will
458    probably not be backed up by an Incremental or Differential backup which
459    depend solely on these time stamps.  If you move a directory, and wish
460    it to be properly backed up, it is generally preferable to copy it, then
461    delete the original.
462
463 \item [Differential]
464    \index[dir]{Differential}
465    When the Level is set to Differential
466    all files specified in the FileSet that have changed since the last
467    successful Full backup of the same Job will be backed up.
468    If the Director cannot find a
469    valid previous Full backup for the same Job, FileSet, and Client,
470    backup, then the Differential job will be upgraded into a Full backup.
471    When the Director looks for a valid Full backup record in the catalog
472    database, it looks for a previous Job with:
473
474 \begin{itemize}
475 \item The same Job name.  
476 \item The same Client name.  
477 \item The same FileSet (any change to the definition of  the FileSet such as
478    adding or deleting a file in the  Include or Exclude sections constitutes a
479    different FileSet.  
480 \item The Job was a FULL backup.  
481 \item The Job terminated normally (i.e. did not fail or was not  canceled).  
482 \end{itemize}
483
484    If all the above conditions do not hold, the Director will  upgrade the
485    Differential to a Full save. Otherwise, the  Differential backup will be
486    performed as requested.  
487
488    The File daemon (Client) decides which files to backup for a
489    differential backup by comparing the start time of the prior Full backup
490    Job against the time each file was last "modified" (st\_mtime) and the
491    time its attributes were last "changed" (st\_ctime).  If the file was
492    modified or its attributes were changed on or after this start time, it
493    will then be backed up.  The start time used is displayed after the {\bf
494    Since} on the Job report.  In rare cases, using the start time of the
495    prior backup may cause some files to be backed up twice, but it ensures
496    that no change is missed.  As with the Incremental option, you should
497    ensure that the clocks on your server and client are synchronized or as
498    close as possible to avoid the possibility of a file being skipped.
499    Note, on versions 1.33 or greater Bacula automatically makes the
500    necessary adjustments to the time between the server and the client so
501    that the times Bacula uses are synchronized.
502
503    When Bacula does a Differential backup, all modified files that are
504    still on the system are backed up.  However, any file that has been
505    deleted since the last Full backup remains in the Bacula catalog, which
506    means that if between a Full save and the time you do a restore, some
507    files are deleted, those deleted files will also be restored.  The
508    deleted files will no longer appear in the catalog after doing another
509    Full save.  However, to remove deleted files from the catalog during a
510    Differential backup is quite a time consuming process and not currently
511    implemented in Bacula.  It is, however, a planned future feature.
512
513    As noted above, if you move a directory rather than copy it, the
514    files in it do not have their modification time (st\_mtime) or
515    their attribute change time (st\_ctime) changed.  As a
516    consequence, those files will probably not be backed up by an
517    Incremental or Differential backup which depend solely on these
518    time stamps.  If you move a directory, and wish it to be
519    properly backed up, it is generally preferable to copy it, then
520    delete the original. Alternatively, you can move the directory, then
521    use the {\bf touch} program to update the timestamps.
522
523    Every once and a while, someone asks why we need Differential
524    backups as long as Incremental backups pickup all changed files.
525    There are possibly many answers to this question, but the one
526    that is the most important for me is that a Differential backup
527    effectively merges
528    all the Incremental and Differential backups since the last Full backup
529    into a single Differential backup.  This has two effects: 1.  It gives
530    some redundancy since the old backups could be used if the merged backup
531    cannot be read.  2.  More importantly, it reduces the number of Volumes
532    that are needed to do a restore effectively eliminating the need to read
533    all the volumes on which the preceding Incremental and Differential
534    backups since the last Full are done.
535
536 \end{description}
537
538 For a {\bf Restore} Job, no level needs to be specified.  
539
540 For a {\bf Verify} Job, the Level may be one of the  following:  
541
542 \begin{description}
543
544 \item [InitCatalog]
545 \index[dir]{InitCatalog}
546    does a scan of the specified {\bf FileSet} and stores the file
547    attributes in the Catalog database.  Since no file data is saved, you
548    might ask why you would want to do this.  It turns out to be a very
549    simple and easy way to have a {\bf Tripwire} like feature using {\bf
550    Bacula}.  In other words, it allows you to save the state of a set of
551    files defined by the {\bf FileSet} and later check to see if those files
552    have been modified or deleted and if any new files have been added.
553    This can be used to detect system intrusion.  Typically you would
554    specify a {\bf FileSet} that contains the set of system files that
555    should not change (e.g.  /sbin, /boot, /lib, /bin, ...).  Normally, you
556    run the {\bf InitCatalog} level verify one time when your system is
557    first setup, and then once again after each modification (upgrade) to
558    your system.  Thereafter, when your want to check the state of your
559    system files, you use a {\bf Verify} {\bf level = Catalog}.  This
560    compares the results of your {\bf InitCatalog} with the current state of
561    the files.
562
563 \item [Catalog]
564 \index[dir]{Catalog}
565    Compares the current state of the files against the state previously
566    saved during an {\bf InitCatalog}.  Any discrepancies are reported.  The
567    items reported are determined by the {\bf verify} options specified on
568    the {\bf Include} directive in the specified {\bf FileSet} (see the {\bf
569    FileSet} resource below for more details).  Typically this command will
570    be run once a day (or night) to check for any changes to your system
571    files.
572
573    Please note!  If you run two Verify Catalog jobs on the same client at
574    the same time, the results will certainly be incorrect.  This is because
575    Verify Catalog modifies the Catalog database while running in order to
576    track new files.
577
578 \item [VolumeToCatalog]
579 \index[dir]{VolumeToCatalog}
580    This level causes Bacula to read the file attribute data written to the
581    Volume from the last Job.  The file attribute data are compared to the
582    values saved in the Catalog database and any differences are reported.
583    This is similar to the {\bf Catalog} level except that instead of
584    comparing the disk file attributes to the catalog database, the
585    attribute data written to the Volume is read and compared to the catalog
586    database.  Although the attribute data including the signatures (MD5 or
587    SHA1) are compared, the actual file data is not compared (it is not in
588    the catalog).
589
590    Please note!  If you run two Verify VolumeToCatalog jobs on the same
591    client at the same time, the results will certainly be incorrect.  This
592    is because the Verify VolumeToCatalog modifies the Catalog database
593    while running.
594
595 \item [DiskToCatalog]
596 \index[dir]{DiskToCatalog}
597    This level causes Bacula to read the files as they currently are on
598    disk, and to compare the current file attributes with the attributes
599    saved in the catalog from the last backup for the job specified on the
600    {\bf VerifyJob} directive.  This level differs from the {\bf Catalog}
601    level described above by the fact that it doesn't compare against a
602    previous Verify job but against a previous backup.  When you run this
603    level, you must supply the verify options on your Include statements.
604    Those options determine what attribute fields are compared.
605
606    This command can be very useful if you have disk problems because it
607    will compare the current state of your disk against the last successful
608    backup, which may be several jobs.
609
610    Note, the current implementation (1.32c) does not identify files that
611    have been deleted.
612 \end{description}
613
614 \item [Verify Job = \lt{}Job-Resource-Name\gt{}]
615    \index[dir]{Verify Job}
616    \index[dir]{Directive!Verify Job}
617    If you run a verify job without this directive, the last job run will be
618    compared with the catalog, which means that you must immediately follow
619    a backup by a verify command.  If you specify a {\bf Verify Job} Bacula
620    will find the last job with that name that ran.  This permits you to run
621    all your backups, then run Verify jobs on those that you wish to be
622    verified (most often a {\bf VolumeToCatalog}) so that the tape just
623    written is re-read.
624
625 \item [JobDefs = \lt{}JobDefs-Resource-Name\gt{}]
626 \index[dir]{JobDefs}
627 \index[dir]{Directive!JobDefs}
628    If a JobDefs-Resource-Name is specified, all the values contained in the
629    named JobDefs resource will be used as the defaults for the current Job.
630    Any value that you explicitly define in the current Job resource, will
631    override any defaults specified in the JobDefs resource.  The use of
632    this directive permits writing much more compact Job resources where the
633    bulk of the directives are defined in one or more JobDefs.  This is
634    particularly useful if you have many similar Jobs but with minor
635    variations such as different Clients.  A simple example of the use of
636    JobDefs is provided in the default bacula-dir.conf file.
637
638 \item [Bootstrap = \lt{}bootstrap-file\gt{}]
639 \index[dir]{Bootstrap}
640 \index[dir]{Directive!Bootstrap}
641    The Bootstrap directive specifies a bootstrap file that, if provided,
642    will be used during {\bf Restore} Jobs and is ignored in other Job
643    types.  The {\bf bootstrap} file contains the list of tapes to be used
644    in a restore Job as well as which files are to be restored.
645    Specification of this directive is optional, and if specified, it is
646    used only for a restore job.  In addition, when running a Restore job
647    from the console, this value can be changed.
648
649    If you use the {\bf Restore} command in the Console program, to start a
650    restore job, the {\bf bootstrap} file will be created automatically from
651    the files you select to be restored.
652
653    For additional details of the {\bf bootstrap} file, please see
654    \ilink{Restoring Files with the Bootstrap File}{BootstrapChapter} chapter
655    of this manual.
656
657 \label{writebootstrap}
658 \item [Write Bootstrap =  \lt{}bootstrap-file-specification\gt{}]
659 \index[dir]{Write Bootstrap}
660 \index[dir]{Directive!Write Bootstrap}
661    The {\bf writebootstrap} directive specifies a file name where Bacula
662    will write a {\bf bootstrap} file for each Backup job run.  This
663    directive applies only to Backup Jobs.  If the Backup job is a Full
664    save, Bacula will erase any current contents of the specified file
665    before writing the bootstrap records.  If the Job is an Incremental
666    or Differential
667    save, Bacula will append the current bootstrap record to the end of the
668    file.
669
670    Using this feature, permits you to constantly have a bootstrap file that
671    can recover the current state of your system.  Normally, the file
672    specified should be a mounted drive on another machine, so that if your
673    hard disk is lost, you will immediately have a bootstrap record
674    available.  Alternatively, you should copy the bootstrap file to another
675    machine after it is updated. Note, it is a good idea to write a separate
676    bootstrap file for each Job backed up including the job that backs up
677    your catalog database.
678
679    If the {\bf bootstrap-file-specification} begins with a vertical bar
680    (|), Bacula will use the specification as the name of a program to which
681    it will pipe the bootstrap record.  It could for example be a shell
682    script that emails you the bootstrap record.
683
684    On versions 1.39.22 or greater, before opening the file or executing the
685    specified command, Bacula performs 
686    \ilink{character substitution}{character substitution} like in RunScript
687    directive. To automatically manage your bootstrap files, you can use
688    this in your {\bf JobDefs} resources:
689 \begin{verbatim}
690 JobDefs {
691    Write Bootstrap = "%c_%n.bsr"
692    ...
693 }
694 \end{verbatim}
695
696    For more details on using this file, please see the chapter entitled
697    \ilink{The Bootstrap File}{BootstrapChapter} of this manual.
698
699 \item [Client = \lt{}client-resource-name\gt{}]
700 \index[dir]{Client}
701 \index[dir]{Directive!Client}
702    The Client directive  specifies the Client (File daemon) that will be used in
703    the  current Job. Only a single Client may be specified in any one Job.  The
704    Client runs on the machine to be backed up,  and sends the requested files to
705    the Storage daemon for backup,  or receives them when restoring. For
706    additional details, see the  
707    \ilink{Client Resource section}{ClientResource2} of this chapter.
708    This directive is required. 
709
710 \item [FileSet = \lt{}FileSet-resource-name\gt{}]
711 \index[dir]{FileSet}
712 \index[dir]{FileSet}
713    The FileSet directive specifies the FileSet that will be used in the
714    current Job.  The FileSet specifies which directories (or files) are to
715    be backed up, and what options to use (e.g.  compression, ...).  Only a
716    single FileSet resource may be specified in any one Job.  For additional
717    details, see the \ilink{FileSet Resource section}{FileSetResource} of
718    this chapter.  This directive is required.
719
720 \item [Messages = \lt{}messages-resource-name\gt{}]
721 \index[dir]{Messages}
722 \index[dir]{Directive!Messages}
723    The Messages directive defines what Messages resource should be used for
724    this job, and thus how and where the various messages are to be
725    delivered.  For example, you can direct some messages to a log file, and
726    others can be sent by email.  For additional details, see the
727    \ilink{Messages Resource}{MessagesChapter} Chapter of this manual.  This
728    directive is required.
729
730 \item [Pool = \lt{}pool-resource-name\gt{}]
731 \index[dir]{Pool}
732 \index[dir]{Directive!Pool}
733    The Pool directive defines the pool of Volumes where your data can be
734    backed up.  Many Bacula installations will use only the {\bf Default}
735    pool.  However, if you want to specify a different set of Volumes for
736    different Clients or different Jobs, you will probably want to use
737    Pools.  For additional details, see the \ilink{Pool Resource
738    section}{PoolResource} of this chapter.  This directive is required.
739
740 \item [Full Backup Pool = \lt{}pool-resource-name\gt{}]
741 \index[dir]{Full Backup Pool}
742 \index[dir]{Directive!Full Backup Pool}
743    The {\it Full Backup Pool} specifies a Pool to be used for Full backups.
744    It will override any Pool specification during a Full backup.  This
745    directive is optional.
746    
747 \item [Differential Backup Pool = \lt{}pool-resource-name\gt{}]  
748 \index[dir]{Differential Backup Pool}
749 \index[dir]{Directive!Differential Backup Pool}
750    The {\it Differential Backup Pool} specifies a Pool to be used for
751    Differential backups.  It will override any Pool specification during a
752    Differential backup.  This directive is optional.
753    
754 \item [Incremental Backup Pool = \lt{}pool-resource-name\gt{}]  
755 \index[dir]{Incremental Backup Pool}
756 \index[dir]{Directive!Incremental Backup Pool}
757    The {\it Incremental Backup Pool} specifies a Pool to be used for
758    Incremental backups.  It will override any Pool specification during an
759    Incremental backup.  This directive is optional.
760
761 \item [Schedule = \lt{}schedule-name\gt{}]
762 \index[dir]{Schedule}
763 \index[dir]{Directive!Schedule}
764    The Schedule directive defines what schedule is to be used for the Job.
765    The schedule in turn determines when the Job will be automatically
766    started and what Job level (i.e.  Full, Incremental, ...) is to be run.
767    This directive is optional, and if left out, the Job can only be started
768    manually using the Console program.  Although you may specify only a
769    single Schedule resource for any one job, the Schedule resource may
770    contain multiple {\bf Run} directives, which allow you to run the Job at
771    many different times, and each {\bf run} directive permits overriding
772    the default Job Level Pool, Storage, and Messages resources.  This gives
773    considerable flexibility in what can be done with a single Job.  For
774    additional details, see the \ilink{Schedule Resource
775    Chapter}{ScheduleResource} of this manual.
776           
777
778 \item [Storage = \lt{}storage-resource-name\gt{}]
779 \index[dir]{Storage}
780 \index[dir]{Directive!Storage}
781    The Storage directive defines the name of the storage services where you
782    want to backup the FileSet data.  For additional details, see the
783    \ilink{Storage Resource Chapter}{StorageResource2} of this manual.
784    The Storage resource may also be specified in the Job's Pool resource,
785    in which case the value in the Pool resource overrides any value
786    in the Job. This Storage resource definition is not required by either
787    the Job resource or in the Pool, but it must be specified in
788    one or the other.  If not configuration error will result.
789
790 \item [Max Start Delay = \lt{}time\gt{}]
791 \index[dir]{Max Start Delay}
792 \index[dir]{Directive!Max Start Delay}
793    The time specifies the maximum delay between the scheduled time and the
794    actual start time for the Job.  For example, a job can be scheduled to
795    run at 1:00am, but because other jobs are running, it may wait to run.
796    If the delay is set to 3600 (one hour) and the job has not begun to run
797    by 2:00am, the job will be canceled.  This can be useful, for example,
798    to prevent jobs from running during day time hours.  The default is 0
799    which indicates no limit.
800
801 \item [Max Run Time = \lt{}time\gt{}]
802 \index[dir]{Max Run Time}
803 \index[dir]{Directive!Max Run Time}
804    The time specifies the maximum allowed time that a job may run, counted
805    from when the job starts, ({\bf not} necessarily the same as when the
806    job was scheduled).  This directive is implemented in version 1.33 and
807    later.
808
809 \item [Max Wait Time = \lt{}time\gt{}]
810 \index[dir]{Max Wait Time}
811 \index[dir]{Directive!Max Wait Time}
812    The time specifies the maximum allowed time that a job may block waiting
813    for a resource (such as waiting for a tape to be mounted, or waiting for
814    the storage or file daemons to perform their duties), counted from the
815    when the job starts, ({\bf not} necessarily the same as when the job was
816    scheduled).  This directive is implemented only in version 1.33 and
817    later.
818
819 \item [Incremental Max Wait Time = \lt{}time\gt{}]
820 \index[dir]{Incremental Max Wait Time}
821 \index[dir]{Directive!Incremental Max Wait Time}
822    The time specifies the maximum allowed time that an Incremental backup
823    job may block waiting for a resource (such as waiting for a tape to be
824    mounted, or waiting for the storage or file daemons to perform their
825    duties), counted from the when the job starts, ({\bf not} necessarily
826    the same as when the job was scheduled).  Please note that if there is a
827    {\bf Max Wait Time} it may also be applied to the job.
828
829 \item [Differential Max Wait Time = \lt{}time\gt{}]
830 \index[dir]{Differential Max Wait Time}
831 \index[dir]{Directive!Differential Max Wait Time}
832    The time specifies the maximum allowed time that a Differential backup
833    job may block waiting for a resource (such as waiting for a tape to be
834    mounted, or waiting for the storage or file daemons to perform their
835    duties), counted from the when the job starts, ({\bf not} necessarily
836    the same as when the job was scheduled).  Please note that if there is a
837    {\bf Max Wait Time} it may also be applied to the job.
838
839 \item [Prefer Mounted Volumes = \lt{}yes|no\gt{}]
840 \index[dir]{Prefer Mounted Volumes}
841 \index[dir]{Directive!Prefer Mounted Volumes}
842    If the Prefer Mounted Volumes directive is set to {\bf yes} (default
843    yes), the Storage daemon is requested to select either an Autochanger or
844    a drive with a valid Volume already mounted in preference to a drive
845    that is not ready.  If no drive with a suitable Volume is available, it
846    will select the first available drive.  
847
848    If the directive is set to {\bf no}, the Storage daemon will prefer
849    finding an unused drive, otherwise, each job started will append to the
850    same Volume (assuming the Pool is the same for all jobs).  Setting
851    Prefer Mounted Volumes to no can be useful for those sites particularly
852    with multiple drive autochangers that prefer to maximize backup
853    throughput at the expense of using additional drives and Volumes.  As an
854    optimization, when using multiple drives, you will probably want to
855    start each of your jobs one after another with approximately 5 second
856    intervals.  This will help ensure that each night, the same drive
857    (Volume) is selected for the same job, otherwise, when you do a restore,
858    you may find the files spread over many more Volumes than necessary.
859
860
861 \item [Prune Jobs = \lt{}yes|no\gt{}]
862 \index[dir]{Prune Jobs}
863 \index[dir]{Directive!Prune Jobs}
864    Normally, pruning of Jobs from the Catalog is specified on a Client by
865    Client basis in the Client resource with the {\bf AutoPrune} directive.
866    If this directive is specified (not normally) and the value is {\bf
867    yes}, it will override the value specified in the Client resource.  The
868    default is {\bf no}.
869
870
871 \item [Prune Files = \lt{}yes|no\gt{}]
872 \index[dir]{Prune Files}
873 \index[dir]{Directive!Prune Files}
874    Normally, pruning of Files from the Catalog is specified on a Client by
875    Client basis in the Client resource with the {\bf AutoPrune} directive.
876    If this directive is specified (not normally) and the value is {\bf
877    yes}, it will override the value specified in the Client resource.  The
878    default is {\bf no}.
879
880 \item [Prune Volumes = \lt{}yes|no\gt{}]
881 \index[dir]{Prune Volumes}
882 \index[dir]{Directive!Prune Volumes}
883    Normally, pruning of Volumes from the Catalog is specified on a Client
884    by Client basis in the Client resource with the {\bf AutoPrune}
885    directive.  If this directive is specified (not normally) and the value
886    is {\bf yes}, it will override the value specified in the Client
887    resource.  The default is {\bf no}.
888
889 \item [RunScript \{\lt{}body-of-runscript\gt{}\}]
890    \index[dir]{RunScript}
891    \index[dir]{Directive!Run Script}
892
893    This directive is implemented in version 1.39.22 and later.
894    The RunScript directive behaves like a resource in that it
895    requires opening and closing braces around a number of directives
896    that make up the body of the runscript.
897
898    The specified {\bf Command} (see below for details) is run as an
899    external program prior or after the current Job.  This is optional.
900
901    You can use following options may be specified in the body
902    of the runscript:\\
903
904 \begin{tabular}{|c|c|c|l}
905 Options         & Value  & Default & Information   \\
906 \hline
907 \hline
908 Runs On Success & Yes/No & {\it Yes} & Run command if JobStatus is successful\\
909 \hline
910 Runs On Failure & Yes/No & {\it No} & Run command if JobStatus isn't successful\\
911 \hline
912 Runs On Client  & Yes/No & {\it Yes} & Run command on client\\
913 \hline
914 Runs When       & Before|After|Always & {\it Never} & When run commands\\
915 \hline
916 Abort Job On Error & Yes/No & {\it Yes} & Abort job if script returns 
917                                           something different from 0 \\
918 \hline
919 Command          &       &          & Path to your script\\
920 \hline
921 \end{tabular}
922    \\
923
924    Any output sent by the command to standard output will be included in the
925    Bacula job report.  The command string must be a valid program name or name
926    of a shell script.
927
928    In addition, the command string is parsed then fed to the OS,
929    which means that the path will be searched to execute your specified
930    command, but there is no shell interpretation, as a consequence, if you
931    invoke complicated commands or want any shell features such as redirection
932    or piping, you must call a shell script and do it inside that script.
933  
934    Before submitting the specified command to the operating system, Bacula
935    performs character substitution of the following characters:
936
937 \label{character substitution}
938 \footnotesize
939 \begin{verbatim}
940     %% = %
941     %c = Client's name
942     %d = Director's name
943     %e = Job Exit Status
944     %i = JobId
945     %j = Unique Job id
946     %l = Job Level
947     %n = Job name
948     %s = Since time
949     %t = Job type (Backup, ...)
950     %v = Volume name
951     
952 \end{verbatim}
953 \normalsize
954
955 The Job Exit Status code \%e edits the following values:
956
957 \index[dir]{Exit Status}
958 \begin{itemize}
959 \item OK
960 \item Error
961 \item Fatal Error
962 \item Canceled
963 \item Differences
964 \item Unknown term code
965 \end{itemize}
966
967    Thus if you edit it on a command line, you will need to enclose 
968    it within some sort of quotes.
969
970
971 You can use these following shortcuts:\\
972
973 \begin{tabular}{|c|c|c|c|c|c}
974 Keyword & RunsOnSuccess & RunsOnFailure  & AbortJobOnError & Runs On Client & RunsWhen  \\
975 \hline
976 Run Before Job         &        &       & Yes     & No     & Before \\
977 \hline
978 Run After Job          &  Yes   &   No  &         & No     & After  \\
979 \hline
980 Run After Failed Job   &  No    &  Yes  &         & No     & After  \\
981 \hline
982 Client Run Before Job  &        &       & Yes     & Yes    & Before \\
983 \hline
984 Client Run After Job   &  Yes   &   No  &         & Yes    & After  \\
985 \end{tabular}
986
987 Examples:
988 \begin{verbatim}
989 RunScript {
990     RunsWhen = Before
991     AbortJobOnError = No
992     Command = "/etc/init.d/apache stop"
993 }
994
995 RunScript {
996     RunsWhen = After
997     RunsOnFailure = yes
998     Command = "/etc/init.d/apache start"
999 }
1000 \end{verbatim}
1001
1002    {\bf Special Windows Considerations}
1003
1004    In addition, for a Windows client on version 1.33 and above, please take
1005    note that you must ensure a correct path to your script.  The script or
1006    program can be a .com, .exe or a .bat file.  If you just put the program
1007    name in then Bacula will search using the same rules that cmd.exe uses
1008    (current directory, Bacula bin directory, and PATH).  It will even try the
1009    different extensions in the same order as cmd.exe.
1010    The command can be anything that cmd.exe or command.com will recognize
1011    as an executable file.  
1012
1013    However, if you have slashes in the program name then Bacula figures you
1014    are fully specifying the name, so you must also explicitly add the three
1015    character extension.
1016
1017    The command is run in a Win32 environment, so Unix like commands will not
1018    work unless you have installed and properly configured Cygwin in addition
1019    to and separately from Bacula.
1020    
1021    The System \%Path\% will be searched for the command.  (under the
1022    environment variable dialog you have have both System Environment and
1023    User Environment, we believe that only the System environment will be
1024    available to bacula-fd, if it is running as a service.)
1025    
1026    System environment variables can be referenced with \%var\% and
1027    used as either part of the command name or arguments.  
1028
1029    So if you have a script in the Bacula\\bin directory then the following lines
1030    should work fine:
1031    
1032 \footnotesize
1033 \begin{verbatim}
1034         Client Run Before Job = systemstate
1035 or
1036         Client Run Before Job = systemstate.bat
1037 or
1038         Client Run Before Job = "systemstate"
1039 or
1040         Client Run Before Job = "systemstate.bat"
1041 or
1042         ClientRunBeforeJob = "\"C:/Program Files/Bacula/systemstate.bat\""
1043 \end{verbatim}
1044 \normalsize
1045
1046 The outer set of quotes is removed when the configuration file is parsed.
1047 You need to escape the inner quotes so that they are there when the code
1048 that parses the command line for execution runs so it can tell what the
1049 program name is.
1050
1051
1052 \footnotesize
1053 \begin{verbatim}
1054 ClientRunBeforeJob = "\"C:/Program Files/Software
1055      Vendor/Executable\" /arg1 /arg2 \"foo bar\""
1056 \end{verbatim}
1057 \normalsize
1058
1059    The special characters 
1060 \begin{verbatim}
1061 &<>()@^|
1062 \end{verbatim}
1063    will need to be quoted,
1064    if they are part of a filename or argument.
1065    
1066    If someone is logged in, a blank "command" window running the commands
1067    will be present during the execution of the command.
1068    
1069    Some Suggestions from Phil Stracchino for running on Win32 machines with
1070    the native Win32 File daemon:
1071
1072    \begin{enumerate}
1073    \item You might want the ClientRunBeforeJob directive to specify a .bat
1074       file which runs the actual client-side commands, rather than trying
1075       to run (for example) regedit /e directly.
1076    \item The batch file should explicitly 'exit 0' on successful completion.  
1077    \item The path to the batch file should be specified in Unix form:  
1078    
1079       ClientRunBeforeJob = "c:/bacula/bin/systemstate.bat"  
1080    
1081    rather than DOS/Windows form:  
1082    
1083    ClientRunBeforeJob =
1084
1085 "c:\textbackslash{}bacula\textbackslash{}bin\textbackslash{}systemstate.bat"
1086    INCORRECT 
1087    \end{enumerate}
1088
1089 For Win32, please note that there are certain limitations:  
1090
1091 ClientRunBeforeJob = "C:/Program Files/Bacula/bin/pre-exec.bat"
1092
1093 Lines like the above do not work because there are limitations of
1094 cmd.exe that is used to execute the command.
1095 Bacula prefixes the string you supply with {\bf cmd.exe /c }.  To test that
1096 your command works you should type {\bf cmd /c "C:/Program Files/test.exe"} at a
1097 cmd prompt and see what happens.  Once the command is correct insert a
1098 backslash (\textbackslash{}) before each double quote ("), and
1099 then put quotes around the whole thing when putting it in
1100 the director's .conf file.  You either need to have only one set of quotes
1101 or else use the short name and don't put quotes around the command path.
1102  
1103 Below is the output from cmd's help as it relates to the command line
1104 passed to the /c option.
1105  
1106  
1107  If /C or /K is specified, then the remainder of the command line after
1108  the switch is processed as a command line, where the following logic is
1109  used to process quote (") characters:
1110  
1111 \begin{enumerate}
1112 \item 
1113      If all of the following conditions are met, then quote characters
1114          on the command line are preserved:
1115     \begin{itemize}
1116        \item no /S switch.
1117        \item exactly two quote characters.
1118        \item no special characters between the two quote characters,
1119            where special is one of: 
1120 \begin{verbatim}
1121 &<>()@^| 
1122 \end{verbatim}
1123        \item there are one or more whitespace characters between the
1124            the two quote characters.
1125        \item the string between the two quote characters is the name
1126            of an executable file.
1127     \end{itemize}
1128  
1129 \item  Otherwise, old behavior is to see if the first character is
1130          a quote character and if so, strip the leading character and
1131          remove the last quote character on the command line, preserving
1132          any text after the last quote character. 
1133    
1134 \end{enumerate}
1135
1136    
1137 The following example of the use of the Client Run Before Job directive was 
1138 submitted by a user:\\
1139 You could write a shell script to back up a DB2 database to a FIFO. The shell
1140 script is:
1141
1142 \footnotesize
1143 \begin{verbatim}
1144  #!/bin/sh
1145  # ===== backupdb.sh
1146  DIR=/u01/mercuryd
1147  
1148  mkfifo $DIR/dbpipe
1149  db2 BACKUP DATABASE mercuryd TO $DIR/dbpipe WITHOUT PROMPTING &
1150  sleep 1
1151 \end{verbatim}
1152 \normalsize
1153  
1154 The following line in the Job resource in the bacula-dir.conf file:
1155 \footnotesize
1156 \begin{verbatim}
1157  Client Run Before Job = "su - mercuryd -c \"/u01/mercuryd/backupdb.sh '%t'
1158 '%l'\""
1159 \end{verbatim}
1160 \normalsize
1161
1162 When the job is run, you will get messages from the output of the script
1163 stating that the backup has started. Even though the command being run is
1164 backgrounded with \&, the job will block until the "db2 BACKUP DATABASE"
1165 command, thus the backup stalls.
1166  
1167 To remedy this situation, the "db2 BACKUP DATABASE" line should be changed to
1168 the following:
1169  
1170 \footnotesize
1171 \begin{verbatim} 
1172  db2 BACKUP DATABASE mercuryd TO $DIR/dbpipe WITHOUT PROMPTING > $DIR/backup.log
1173 2>&1 < /dev/null &
1174 \end{verbatim}
1175 \normalsize
1176
1177 It is important to redirect the input and outputs of a backgrounded command to
1178 /dev/null to prevent the script from blocking.
1179
1180 \item [Run Before Job = \lt{}command\gt{}]
1181 \index[dir]{Run Before Job}
1182 \index[dir]{Directive!Run Before Job}
1183 \index[dir]{Directive!Run Before Job}
1184 The specified {\bf command} is run as an external program prior to running the
1185 current Job.  This directive is not required, but if it is defined, and if the
1186 exit code of the program run is non-zero, the current Bacula job will be
1187 canceled.
1188
1189 \begin{verbatim}
1190 Run Before Job = "echo test"
1191 \end{verbatim}
1192    it's equivalent to :
1193 \begin{verbatim}
1194 RunScript {
1195  Command = "echo test"
1196  RunsOnClient = No
1197  RunsWhen = Before
1198 }
1199 \end{verbatim} 
1200
1201    Lutz Kittler has pointed out that using the RunBeforeJob directive can be a
1202    simple way to modify your schedules during a holiday.  For example, suppose
1203    that you normally do Full backups on Fridays, but Thursday and Friday are
1204    holidays.  To avoid having to change tapes between Thursday and Friday when
1205    no one is in the office, you can create a RunBeforeJob that returns a
1206    non-zero status on Thursday and zero on all other days.  That way, the
1207    Thursday job will not run, and on Friday the tape you inserted on Wednesday
1208    before leaving will be used.
1209
1210 \item [Run After Job = \lt{}command\gt{}]
1211 \index[dir]{Run After Job}
1212 \index[dir]{Directive!Run After Job}
1213    The specified {\bf command} is run as an external program if the current
1214    job terminates normally (without error or without being canceled).  This
1215    directive is not required.  If the exit code of the program run is
1216    non-zero, Bacula will print a warning message.  Before submitting the
1217    specified command to the operating system, Bacula performs character
1218    substitution as described above for the {\bf RunScript} directive.
1219    
1220    An example of the use of this directive is given in the  
1221    \ilink{Tips Chapter}{JobNotification} of this manual.  
1222
1223    See the {\bf Run After Failed Job} if you
1224    want to run a script after the job has terminated with any
1225    non-normal status.
1226
1227 \item [Run After Failed Job = \lt{}command\gt{}]
1228 \index[dir]{Run After Job}
1229 \index[dir]{Directive!Run After Job}
1230    The specified {\bf command} is run as an external program after the current
1231    job terminates with any error status.  This directive is not required.  The
1232    command string must be a valid program name or name of a shell script. If
1233    the exit code of the program run is non-zero, Bacula will print a
1234    warning message. Before submitting the specified command to the
1235    operating system, Bacula performs character substitution as described above
1236    for the {\bf RunScript} directive. Note, if you wish that your script
1237    will run regardless of the exit status of the Job, you can use this :
1238 \begin{verbatim}
1239 RunScript {
1240  Command = "echo test"
1241  RunsWhen = After
1242  RunsOnFailure = yes
1243  RunsOnClient  = no
1244  RunsOnSuccess = yes    # default, you can drop this line
1245 }
1246 \end{verbatim}
1247
1248    An example of the use of this directive is given in the  
1249    \ilink{Tips Chapter}{JobNotification} of this manual.
1250   
1251
1252 \item [Client Run Before Job = \lt{}command\gt{}]
1253 \index[dir]{Client Run Before Job}
1254 \index[dir]{Directive!Client Run Before Job}
1255    This directive is the same as {\bf Run Before Job} except that the
1256    program is run on the client machine.  The same restrictions apply to
1257    Unix systems as noted above for the {\bf RunScript}.
1258
1259 \item [Client Run After Job = \lt{}command\gt{}]
1260    \index[dir]{Client Run After Job}
1261    \index[dir]{Directive!Client Run After Job}
1262    This directive is the same as {\bf Run After Job} except that it is run on
1263    the client machine.  Note, please see the notes above in {\bf RunScript} 
1264    concerning Windows clients.
1265
1266 \item [Rerun Failed Levels = \lt{}yes|no\gt{}]
1267    \index[dir]{Rerun Failed Levels}
1268    \index[dir]{Directive!Rerun Failed Levels}
1269    If this directive is set to {\bf yes} (default no), and Bacula detects that
1270    a previous job at a higher level (i.e.  Full or Differential) has failed,
1271    the current job level will be upgraded to the higher level.  This is
1272    particularly useful for Laptops where they may often be unreachable, and if
1273    a prior Full save has failed, you wish the very next backup to be a Full
1274    save rather than whatever level it is started as.
1275
1276    There are several points that must be taken into account when using this
1277    directive: first, a failed job is defined as one that has not terminated
1278    normally, which includes any running job of the same name (you need to
1279    ensure that two jobs of the same name do not run simultaneously);
1280    secondly, the {\bf Ignore FileSet Changes} directive is not considered 
1281    when checing for failed levels, which means that any FileSet change will
1282    trigger a rerun.
1283
1284 \item [Spool Data = \lt{}yes|no\gt{}]
1285    \index[dir]{Spool Data}
1286    \index[dir]{Directive!Spool Data}
1287    If this directive is set  to {\bf yes} (default no), the Storage daemon will
1288    be requested  to spool the data for this Job to disk rather than write it 
1289    directly to tape. Once all the data arrives or the spool files' maximum sizes
1290    are reached, the data will be despooled and written  to tape. When this
1291    directive is set to yes, the Spool Attributes  is also automatically set to
1292    yes. Spooling data prevents tape  shoe-shine (start and stop) during
1293    Incremental saves. This option  should not be used if you are writing to a
1294    disk file. 
1295
1296 \item [Spool Attributes = \lt{}yes|no\gt{}]
1297    \index[dir]{Spool Attributes}
1298    \index[dir]{Directive!Spool Attributes}
1299    \index[dir]{slow}
1300    \index[general]{slow}
1301    \index[dir]{Backups!slow}
1302    \index[general]{Backups!slow}
1303    The default is set to  {\bf no}, which means that the File attributes are
1304 sent
1305 by the  Storage daemon to the Director as they are stored on tape. However, 
1306 if you want to avoid the possibility that database updates will  slow down
1307 writing to the tape, you may want to set the value to  {\bf yes}, in which
1308 case the Storage daemon will buffer the  File attributes and Storage
1309 coordinates to a temporary file  in the Working Directory, then when writing
1310 the Job data to the tape is  completed, the attributes and storage coordinates
1311 will be  sent to the Director. 
1312
1313 \item [Where = \lt{}directory\gt{}]
1314    \index[dir]{Where}
1315    \index[dir]{Directive!Where}
1316    This directive applies only to a Restore job and specifies a prefix to
1317    the directory name of all files being restored.  This permits files to
1318    be restored in a different location from which they were saved.  If {\bf
1319    Where} is not specified or is set to backslash ({\bf /}), the files will
1320    be restored to their original location.  By default, we have set {\bf
1321    Where} in the example configuration files to be {\bf
1322    /tmp/bacula-restores}.  This is to prevent accidental overwriting of
1323    your files.
1324
1325 \item [Replace = \lt{}replace-option\gt{}]
1326    \index[dir]{Replace}
1327    \index[dir]{Directive!Replace}
1328    This directive applies only to a Restore job and specifies what happens
1329    when Bacula wants to restore a file or directory that already exists.
1330    You have the following options for {\bf replace-option}:
1331
1332 \begin{description}
1333
1334 \item [always]
1335    \index[dir]{always}
1336   when the file to be restored already exists, it is deleted and then
1337   replaced by the copy that was backed up.
1338
1339 \item [ifnewer]
1340 \index[dir]{ifnewer}
1341   if the backed up file (on tape) is newer than the existing file, the
1342   existing file is deleted and replaced by the back up.
1343
1344 \item [ifolder]
1345    \index[dir]{ifolder}
1346   if the backed up file (on tape) is older than the existing file, the
1347   existing file is deleted and replaced by the back up.
1348
1349 \item [never]
1350    \index[dir]{never}
1351   if the backed up file already exists, Bacula skips  restoring this file.  
1352 \end{description}
1353
1354 \item [Prefix Links=\lt{}yes|no\gt{}]
1355    \index[dir]{Prefix Links}
1356    \index[dir]{Directive!Prefix Links}
1357    If a {\bf Where} path prefix is specified for a recovery job, apply it
1358    to absolute links as well.  The default is {\bf No}.  When set to {\bf
1359    Yes} then while restoring files to an alternate directory, any absolute
1360    soft links will also be modified to point to the new alternate
1361    directory.  Normally this is what is desired -- i.e.  everything is self
1362    consistent.  However, if you wish to later move the files to their
1363    original locations, all files linked with absolute names will be broken.
1364
1365 \item [Maximum Concurrent Jobs = \lt{}number\gt{}]
1366    \index[dir]{Maximum Concurrent Jobs}
1367    \index[dir]{Directive!Maximum Concurrent Jobs}
1368    where \lt{}number\gt{} is the maximum number of Jobs from the current
1369    Job resource that can run concurrently.  Note, this directive limits
1370    only Jobs with the same name as the resource in which it appears.  Any
1371    other restrictions on the maximum concurrent jobs such as in the
1372    Director, Client, or Storage resources will also apply in addition to
1373    the limit specified here.  The default is set to 1, but you may set it
1374    to a larger number.  We strongly recommend that you read the WARNING
1375    documented under \ilink{ Maximum Concurrent Jobs}{DirMaxConJobs} in the
1376    Director's resource.
1377
1378 \item [Reschedule On Error = \lt{}yes|no\gt{}]
1379    \index[dir]{Reschedule On Error}
1380    \index[dir]{Directive!Reschedule On Error}
1381    If this directive is enabled, and the job terminates in error, the job
1382    will be rescheduled as determined by the {\bf Reschedule Interval} and
1383    {\bf Reschedule Times} directives.  If you cancel the job, it will not
1384    be rescheduled.  The default is {\bf no} (i.e.  the job will not be
1385    rescheduled).
1386
1387    This specification can be useful for portables, laptops, or other
1388    machines that are not always connected to the network or switched on.
1389
1390 \item [Reschedule Interval = \lt{}time-specification\gt{}]
1391    \index[dir]{Reschedule Interval}
1392    \index[dir]{Directive!Reschedule Interval}
1393    If you have specified {\bf Reschedule On Error = yes} and the job
1394    terminates in error, it will be rescheduled after the interval of time
1395    specified by {\bf time-specification}.  See \ilink{the time
1396    specification formats}{Time} in the Configure chapter for details of
1397    time specifications.  If no interval is specified, the job will not be
1398    rescheduled on error.
1399
1400 \item [Reschedule Times = \lt{}count\gt{}]
1401    \index[dir]{Reschedule Times}
1402    \index[dir]{Directive!Reschedule Times}
1403    This directive specifies the maximum number of times to reschedule the
1404    job.  If it is set to zero (the default) the job will be rescheduled an
1405    indefinite number of times.
1406
1407 \item [Run = \lt{}job-name\gt{}]
1408    \index[dir]{Run}
1409    \index[dir]{Directive!Run}
1410    \index[dir]{Clone a Job}
1411    The Run directive (not to be confused with the Run option in a 
1412    Schedule) allows you to start other jobs or to clone jobs. By using the
1413    cloning keywords (see below), you can backup
1414    the same data (or almost the same data) to two or more drives
1415    at the same time. The {\bf job-name} is normally the same name
1416    as the current Job resource (thus creating a clone). However, it
1417    may be any Job name, so one job may start other related jobs.
1418
1419    The part after the equal sign must be enclosed in double quotes,
1420    and can contain any string or set of options (overrides) that you
1421    can specify when entering the Run command from the console. For
1422    example {\bf storage=DDS-4 ...}.  In addition, there are two special
1423    keywords that permit you to clone the current job. They are {\bf level=\%l}
1424    and {\bf since=\%s}. The \%l in the level keyword permits 
1425    entering the actual level of the current job and the \%s in the since
1426    keyword permits putting the same time for comparison as used on the
1427    current job.  Note, in the case of the since keyword, the \%s must be
1428    enclosed in double quotes, and thus they must be preceded by a backslash
1429    since they are already inside quotes. For example:
1430
1431 \begin{verbatim}
1432    run = "Nightly-backup level=%l since=\"%s\" storage=DDS-4"
1433 \end{verbatim}
1434
1435
1436    A cloned job will not start additional clones, so it is not
1437    possible to recurse.
1438
1439    
1440
1441 \label{Priority}
1442 \item [Priority = \lt{}number\gt{}]
1443    \index[dir]{Priority}
1444    \index[dir]{Directive!Priority}
1445    This directive permits you to control the order in which your jobs run
1446    by specifying a positive non-zero number.  The higher the number, the
1447    lower the job priority.  Assuming you are not running concurrent jobs,
1448    all queued jobs of priority 1 will run before queued jobs of priority 2
1449    and so on, regardless of the original scheduling order.
1450
1451    The priority only affects waiting jobs that are queued to run, not jobs
1452    that are already running.  If one or more jobs of priority 2 are already
1453    running, and a new job is scheduled with priority 1, the currently
1454    running priority 2 jobs must complete before the priority 1 job is run.
1455
1456    The default priority is 10.  
1457
1458    If you want to run concurrent jobs you should
1459    keep these points in mind:
1460
1461 \begin{itemize}
1462 \item To run concurrent jobs, you must set Maximum Concurrent Jobs = 2 in five
1463    or six distinct places: in bacula-dir.conf in the Director, the Job, the
1464    Client, the Storage resources; in bacula-fd in the FileDaemon (or
1465    Client) resource, and in bacula-sd.conf in the Storage resource.  If any
1466    one is missing, it will throttle the jobs to one at a time. You may, of
1467    course, set the Maximum Concurrent Jobs to more than 2.
1468
1469 \item Bacula concurrently runs jobs of only one priority at a time.  It
1470    will not simultaneously run a priority 1 and a priority 2 job.
1471
1472 \item If Bacula is running a priority 2 job and a new priority 1 job is
1473    scheduled, it will wait until the running priority 2 job terminates even
1474    if the Maximum Concurrent Jobs settings would otherwise allow two jobs
1475    to run simultaneously.
1476
1477 \item Suppose that bacula is running a priority 2 job and a new priority 1
1478    job is scheduled and queued waiting for the running priority 2 job to
1479    terminate.  If you then start a second priority 2 job, the waiting
1480    priority 1 job will prevent the new priority 2 job from running
1481    concurrently with the running priority 2 job.  That is: as long as there
1482    is a higher priority job waiting to run, no new lower priority jobs will
1483    start even if the Maximum Concurrent Jobs settings would normally allow
1484    them to run.  This ensures that higher priority jobs will be run as soon
1485    as possible.
1486 \end{itemize}
1487
1488 If you have several jobs of different priority, it may not best to start
1489 them at exactly the same time, because Bacula must examine them one at a
1490 time.  If by Bacula starts a lower priority job first, then it will run
1491 before your high priority jobs.  If you experience this problem, you may
1492 avoid it by starting any higher priority jobs a few seconds before lower
1493 priority ones.  This insures that Bacula will examine the jobs in the
1494 correct order, and that your priority scheme will be respected.
1495
1496 \label{WritePartAfterJob}
1497 \item [Write Part After Job = \lt{}yes|no\gt{}]
1498 \index[dir]{Write Part After Job}
1499 \index[dir]{Directive!Write Part After Job}
1500    This directive is only implemented in version 1.37 and later.
1501    If this directive is set to {\bf yes} (default {\bf no}), a new part file
1502    will be created after the job is finished.  
1503
1504    It should be set to {\bf yes} when writing to devices that require mount
1505    (for example DVD), so you are sure that the current part, containing
1506    this job's data, is written to the device, and that no data is left in
1507    the temporary file on the hard disk.  However, on some media, like DVD+R
1508    and DVD-R, a lot of space (about 10Mb) is lost every time a part is
1509    written.  So, if you run several jobs each after another, you could set
1510    this directive to {\bf no} for all jobs, except the last one, to avoid
1511    wasting too much space, but to ensure that the data is written to the
1512    medium when all jobs are finished.
1513
1514    This directive is ignored with tape and FIFO devices.  
1515 \end{description}
1516
1517 The following is an example of a valid Job resource definition: 
1518
1519 \footnotesize
1520 \begin{verbatim}
1521 Job {
1522   Name = "Minou"
1523   Type = Backup
1524   Level = Incremental                 # default
1525   Client = Minou
1526   FileSet="Minou Full Set"
1527   Storage = DLTDrive
1528   Pool = Default
1529   Schedule = "MinouWeeklyCycle"
1530   Messages = Standard
1531 }
1532 \end{verbatim}
1533 \normalsize
1534
1535 \section{The JobDefs Resource}
1536 \label{JobDefsResource}
1537 \index[general]{JobDefs Resource}
1538 \index[general]{Resource!JobDefs}
1539
1540 The JobDefs resource permits all the same directives that can appear in a Job
1541 resource. However, a JobDefs resource does not create a Job, rather it can be
1542 referenced within a Job to provide defaults for that Job. This permits you to
1543 concisely define several nearly identical Jobs, each one referencing a JobDefs
1544 resource which contains the defaults. Only the changes from the defaults need to
1545 be mentioned in each Job. 
1546
1547 \section{The Schedule Resource}
1548 \label{ScheduleResource}
1549 \index[general]{Resource!Schedule}
1550 \index[general]{Schedule Resource}
1551
1552 The Schedule resource provides a means of automatically scheduling a Job as
1553 well as the ability to override the default Level, Pool, Storage and Messages
1554 resources. If a Schedule resource is not referenced in a Job, the Job can only
1555 be run manually. In general, you specify an action to be taken and when. 
1556
1557 \begin{description}
1558
1559 \item [Schedule]
1560 \index[dir]{Schedule}
1561 \index[dir]{Directive!Schedule}
1562    Start of the Schedule directives.  No {\bf Schedule} resource is
1563    required, but you will need at least one if you want Jobs to be
1564    automatically started.
1565
1566 \item [Name = \lt{}name\gt{}]
1567    \index[dir]{Name}
1568    \index[dir]{Directive!Name}
1569    The name of the schedule being defined.  The Name directive is required. 
1570
1571 \item [Run = \lt{}Job-overrides\gt{} \lt{}Date-time-specification\gt{}]
1572    \index[dir]{Run}
1573    \index[dir]{Directive!Run}
1574    The Run directive defines when a Job is to be run, and what overrides if
1575    any to apply.  You may specify multiple {\bf run} directives within a
1576    {\bf Schedule} resource.  If you do, they will all be applied (i.e.
1577    multiple schedules).  If you have two {\bf Run} directives that start at
1578    the same time, two Jobs will start at the same time (well, within one
1579    second of each other).
1580
1581    The {\bf Job-overrides} permit overriding the Level, the Storage, the
1582    Messages, and the Pool specifications provided in the Job resource.  In
1583    addition, the FullPool, the IncrementalPool, and the DifferentialPool
1584    specifications permit overriding the Pool specification according to
1585    what backup Job Level is in effect.
1586
1587    By the use of overrides, you may customize a particular Job.  For
1588    example, you may specify a Messages override for your Incremental
1589    backups that outputs messages to a log file, but for your weekly or
1590    monthly Full backups, you may send the output by email by using a
1591    different Messages override.
1592
1593    {\bf Job-overrides} are specified as: {\bf keyword=value} where the
1594    keyword is Level, Storage, Messages, Pool, FullPool, DifferentialPool,
1595    or IncrementalPool, and the {\bf value} is as defined on the respective
1596    directive formats for the Job resource.  You may specify multiple {\bf
1597    Job-overrides} on one {\bf Run} directive by separating them with one or
1598    more spaces or by separating them with a trailing comma.  For example:
1599
1600 \begin{description}
1601
1602 \item [Level=Full]
1603    \index[dir]{Level}
1604    \index[dir]{Directive!Level}
1605    is all files in the FileSet whether or not  they have changed.  
1606
1607 \item [Level=Incremental]
1608    \index[dir]{Level}
1609    \index[dir]{Directive!Level}
1610    is all files that have changed since  the last backup.  
1611
1612 \item [Pool=Weekly]
1613    \index[dir]{Pool}
1614    \index[dir]{Directive!Pool}
1615    specifies to use the Pool named {\bf Weekly}.  
1616
1617 \item [Storage=DLT\_Drive]
1618    \index[dir]{Storage}
1619    \index[dir]{Directive!Storage}
1620    specifies to use {\bf DLT\_Drive} for  the storage device.  
1621
1622 \item [Messages=Verbose]
1623    \index[dir]{Messages}
1624    \index[dir]{Directive!Messages}
1625    specifies to use the {\bf Verbose}  message resource for the Job.  
1626
1627 \item [FullPool=Full]
1628    \index[dir]{FullPool}
1629    \index[dir]{Directive!FullPool}
1630    specifies to use the Pool named {\bf Full}  if the job is a full backup, or
1631 is
1632 upgraded from another type  to a full backup.  
1633
1634 \item [DifferentialPool=Differential]
1635    \index[dir]{DifferentialPool}
1636    \index[dir]{Directive!DifferentialPool}
1637    specifies to use the Pool  named {\bf Differential} if the job is a
1638 differential  backup.  
1639
1640 \item [IncrementalPool=Incremental]
1641    \index[dir]{IncrementalPool}
1642    \index[dir]{Directive!IncrementalPool}
1643    specifies to use the Pool  named {\bf Incremental} if the job is an
1644 incremental  backup.  
1645
1646 \item [SpoolData=yes|no]
1647    \index[dir]{SpoolData}
1648    \index[dir]{Directive!SpoolData}
1649    tells Bacula to request the Storage  daemon to spool data to a disk file
1650 before putting it on  tape.  
1651
1652 \item [WritePartAfterJob=yes|no]
1653    \index[dir]{WritePartAfterJob}
1654    \index[dir]{Directive!WritePartAfterJob}
1655    tells Bacula to request the Storage  daemon to write the current part file to
1656    the device when the job  is finished (see 
1657    \ilink{Write Part After Job directive in the Job
1658    resource}{WritePartAfterJob}). Please note, this directive is implemented 
1659    only in version 1.37 and later. The default is yes. We strongly
1660    recommend that you keep this set to yes otherwise, when the last job
1661    has finished one part will remain in the spool file and restore may
1662    or may not work.
1663
1664 \end{description}
1665
1666 {\bf Date-time-specification} determines when the  Job is to be run. The
1667 specification is a repetition, and as  a default Bacula is set to run a job at
1668 the beginning of the  hour of every hour of every day of every week of every
1669 month  of every year. This is not normally what you want, so you  must specify
1670 or limit when you want the job to run. Any  specification given is assumed to
1671 be repetitive in nature and  will serve to override or limit the default
1672 repetition. This  is done by specifying masks or times for the hour, day of the
1673 month, day of the week, week of the month, week of the year,  and month when
1674 you want the job to run. By specifying one or  more of the above, you can
1675 define a schedule to repeat at  almost any frequency you want.  
1676
1677 Basically, you must supply a {\bf month}, {\bf day}, {\bf hour}, and  {\bf
1678 minute} the Job is to be run. Of these four items to be specified,  {\bf day}
1679 is special in that you may either specify a day of the month  such as 1, 2,
1680 ... 31, or you may specify a day of the week such  as Monday, Tuesday, ...
1681 Sunday. Finally, you may also specify a  week qualifier to restrict the
1682 schedule to the first, second, third,  fourth, or fifth week of the month.  
1683
1684 For example, if you specify only a day of the week, such as {\bf Tuesday}  the
1685 Job will be run every hour of every Tuesday of every Month. That  is the {\bf
1686 month} and {\bf hour} remain set to the defaults of  every month and all
1687 hours.  
1688
1689 Note, by default with no other specification, your job will run  at the
1690 beginning of every hour. If you wish your job to run more than  once in any
1691 given hour, you will need to specify multiple {\bf run}  specifications each
1692 with a different minute.  
1693
1694 The date/time to run the Job can be specified in the following way  in
1695 pseudo-BNF:  
1696
1697 \footnotesize
1698 \begin{verbatim}
1699 <void-keyword>    = on
1700 <at-keyword>      = at
1701 <week-keyword>    = 1st | 2nd | 3rd | 4th | 5th | first |
1702                     second | third | fourth | fifth
1703 <wday-keyword>    = sun | mon | tue | wed | thu | fri | sat |
1704                     sunday | monday | tuesday | wednesday |
1705                     thursday | friday | saturday
1706 <week-of-year-keyword> = w00 | w01 | ... w52 | w53
1707 <month-keyword>   = jan | feb | mar | apr | may | jun | jul |
1708                     aug | sep | oct | nov | dec | january |
1709                     february | ... | december
1710 <daily-keyword>   = daily
1711 <weekly-keyword>  = weekly
1712 <monthly-keyword> = monthly
1713 <hourly-keyword>  = hourly
1714 <digit>           = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0
1715 <number>          = <digit> | <digit><number>
1716 <12hour>          = 0 | 1 | 2 | ... 12
1717 <hour>            = 0 | 1 | 2 | ... 23
1718 <minute>          = 0 | 1 | 2 | ... 59
1719 <day>             = 1 | 2 | ... 31
1720 <time>            = <hour>:<minute> |
1721                     <12hour>:<minute>am |
1722                     <12hour>:<minute>pm
1723 <time-spec>       = <at-keyword> <time> |
1724                     <hourly-keyword>
1725 <date-keyword>    = <void-keyword>  <weekly-keyword>
1726 <day-range>       = <day>-<day>
1727 <month-range>     = <month-keyword>-<month-keyword>
1728 <wday-range>      = <wday-keyword>-<wday-keyword>
1729 <range>           = <day-range> | <month-range> |
1730                           <wday-range>
1731 <date>            = <date-keyword> | <day> | <range>
1732 <date-spec>       = <date> | <date-spec>
1733 <day-spec>        = <day> | <wday-keyword> |
1734                     <day-range> | <wday-range> |
1735                     <daily-keyword>
1736 <day-spec>        = <day> | <wday-keyword> |
1737                     <day> | <wday-range> |
1738                     <week-keyword> <wday-keyword> |
1739                     <week-keyword> <wday-range>
1740 <month-spec>      = <month-keyword> | <month-range> |
1741                     <monthly-keyword>
1742 <date-time-spec>  = <month-spec> <day-spec> <time-spec>
1743 \end{verbatim}
1744 \normalsize
1745
1746 \end{description}
1747
1748 Note, the Week of Year specification wnn follows the ISO standard definition
1749 of the week of the year, where Week 1 is the week in which the first Thursday
1750 of the year occurs, or alternatively, the week which contains the 4th of
1751 January. Weeks are numbered w01 to w53. w00 for Bacula is the week that
1752 precedes the first ISO week (i.e. has the first few days of the year if any
1753 occur before Thursday). w00 is not defined by the ISO specification. A week
1754 starts with Monday and ends with Sunday. 
1755
1756 An example schedule resource that is named {\bf WeeklyCycle} and runs a job
1757 with level full each Sunday at 1:05am and an incremental job Monday through
1758 Saturday at 1:05am is: 
1759
1760 \footnotesize
1761 \begin{verbatim}
1762 Schedule {
1763   Name = "WeeklyCycle"
1764   Run = Level=Full sun at 1:05
1765   Run = Level=Incremental mon-sat at 1:05
1766 }
1767 \end{verbatim}
1768 \normalsize
1769
1770 An example of a possible monthly cycle is as follows: 
1771
1772 \footnotesize
1773 \begin{verbatim}
1774 Schedule {
1775   Name = "MonthlyCycle"
1776   Run = Level=Full Pool=Monthly 1st sun at 1:05
1777   Run = Level=Differential 2nd-5th sun at 1:05
1778   Run = Level=Incremental Pool=Daily mon-sat at 1:05
1779 }
1780 \end{verbatim}
1781 \normalsize
1782
1783 The first of every month: 
1784
1785 \footnotesize
1786 \begin{verbatim}
1787 Schedule {
1788   Name = "First"
1789   Run = Level=Full on 1 at 1:05
1790   Run = Level=Incremental on 2-31 at 1:05
1791 }
1792 \end{verbatim}
1793 \normalsize
1794
1795 Every 10 minutes: 
1796
1797 \footnotesize
1798 \begin{verbatim}
1799 Schedule {
1800   Name = "TenMinutes"
1801   Run = Level=Full hourly at 0:05
1802   Run = Level=Full hourly at 0:15
1803   Run = Level=Full hourly at 0:25
1804   Run = Level=Full hourly at 0:35
1805   Run = Level=Full hourly at 0:45
1806   Run = Level=Full hourly at 0:55
1807 }
1808 \end{verbatim}
1809 \normalsize
1810
1811 \section{Technical Notes on Schedules}
1812 \index[general]{Schedules!Technical Notes on}
1813 \index[general]{Technical Notes on Schedules}
1814
1815 Internally Bacula keeps a schedule as a bit mask. There are six masks and a
1816 minute field to each schedule. The masks are hour, day of the month (mday),
1817 month, day of the week (wday), week of the month (wom), and week of the year
1818 (woy). The schedule is initialized to have the bits of each of these masks
1819 set, which means that at the beginning of every hour, the job will run. When
1820 you specify a month for the first time, the mask will be cleared and the bit
1821 corresponding to your selected month will be selected. If you specify a second
1822 month, the bit corresponding to it will also be added to the mask. Thus when
1823 Bacula checks the masks to see if the bits are set corresponding to the
1824 current time, your job will run only in the two months you have set. Likewise,
1825 if you set a time (hour), the hour mask will be cleared, and the hour you
1826 specify will be set in the bit mask and the minutes will be stored in the
1827 minute field. 
1828
1829 For any schedule you have defined, you can see how these bits are set by doing
1830 a {\bf show schedules} command in the Console program. Please note that the
1831 bit mask is zero based, and Sunday is the first day of the week (bit zero). 
1832
1833 \input{fileset}
1834
1835 \section{The Client Resource}
1836 \label{ClientResource2}
1837 \index[general]{Resource!Client}
1838 \index[general]{Client Resource}
1839
1840 The Client resource defines the attributes of the Clients that are served by
1841 this Director; that is the machines that are to be backed up. You will need
1842 one Client resource definition for each machine to be backed up. 
1843
1844 \begin{description}
1845
1846 \item [Client (or FileDaemon)]
1847    \index[dir]{Client (or FileDaemon)}
1848    \index[dir]{Directive!Client (or FileDaemon)}
1849    Start of the Client directives.  
1850
1851 \item [Name = \lt{}name\gt{}]
1852    \index[dir]{Name}
1853    \index[dir]{Directive!Name}
1854    The client name which will be used in the  Job resource directive or in the
1855 console run command.  This directive is required.  
1856
1857 \item [Address = \lt{}address\gt{}]
1858    \index[dir]{Address}
1859    \index[dir]{Directive!FD Address}
1860    \index[dir]{File Daemon Address}
1861    \index[dir]{Client Address}
1862    Where the address is a host name, a fully qualified domain name, or a
1863    network address in dotted quad notation for a Bacula File server daemon.
1864    This directive is required.
1865
1866 \item [FD Port = \lt{}port-number\gt{}]
1867    \index[dir]{FD Port}
1868    \index[dir]{Directive!FD Port}
1869    Where the port is a port  number at which the Bacula File server daemon can
1870    be contacted.  The default is 9102. 
1871
1872 \item [Catalog = \lt{}Catalog-resource-name\gt{}]
1873    \index[dir]{Catalog}
1874    \index[dir]{Directive!Catalog}
1875    This specifies the  name of the catalog resource to be used for this Client. 
1876    This directive is required.  
1877
1878 \item [Password = \lt{}password\gt{}]
1879    \index[dir]{Password}
1880    \index[dir]{Directive!Password}
1881    This is the password to be  used when establishing a connection with the File
1882    services, so  the Client configuration file on the machine to be backed up
1883    must  have the same password defined for this Director. This directive is 
1884    required.  If you have either {\bf /dev/random}  {\bf bc} on your machine,
1885    Bacula will generate a random  password during the configuration process,
1886    otherwise it will  be left blank. 
1887
1888 \label{FileRetention}
1889 \item [File Retention = \lt{}time-period-specification\gt{}]
1890    \index[dir]{File Retention}
1891    \index[dir]{Directive!File Retention}
1892    The File Retention directive defines the length of time that  Bacula will
1893    keep File records in the Catalog database after the End time of the
1894    Job corresponding to the File records.
1895    When this time period expires, and if
1896    {\bf AutoPrune} is set to  {\bf yes} Bacula will prune (remove) File records
1897    that  are older than the specified File Retention period. Note, this  affects
1898    only records in the catalog database. It does not  affect your archive
1899    backups.  
1900
1901    File records  may actually be retained for a shorter period than you specify
1902    on  this directive if you specify either a shorter {\bf Job Retention}  or a
1903    shorter {\bf Volume Retention} period. The shortest  retention period of the
1904    three takes precedence.  The time may be expressed in seconds, minutes, 
1905    hours, days, weeks, months, quarters, or years. See the 
1906    \ilink{ Configuration chapter}{Time} of this  manual for
1907    additional details of time specification. 
1908
1909    The  default is 60 days. 
1910
1911 \label{JobRetention}
1912 \item [Job Retention = \lt{}time-period-specification\gt{}]
1913    \index[dir]{Job Retention}
1914    \index[dir]{Directive!Job Retention}
1915    The Job Retention directive defines the length of time that  Bacula will keep
1916    Job records in the Catalog database after the Job End time.  When
1917    this time period expires, and if {\bf AutoPrune} is set to {\bf yes}
1918    Bacula will prune (remove) Job records that are older than the specified
1919    File Retention period.  As with the other retention periods, this
1920    affects only records in the catalog and not data in your archive backup.
1921
1922    If a Job record is selected for pruning, all associated File and JobMedia
1923    records will also be pruned regardless of the File Retention period set.
1924    As a consequence, you normally will set the File retention period to be
1925    less than the Job retention period.  The Job retention period can actually
1926    be less than the value you specify here if you set the {\bf Volume
1927    Retention} directive in the Pool resource to a smaller duration.  This is
1928    because the Job retention period and the Volume retention period are
1929    independently applied, so the smaller of the two takes precedence.
1930
1931    The Job retention period is specified as seconds,  minutes, hours, days,
1932    weeks, months,  quarters, or years.  See the 
1933    \ilink{ Configuration chapter}{Time} of this manual for
1934    additional details of  time specification.  
1935
1936    The default is 180 days.  
1937
1938 \label{AutoPrune}
1939 \item [AutoPrune = \lt{}yes|no\gt{}]
1940    \index[dir]{AutoPrune}
1941    \index[dir]{Directive!AutoPrune}
1942    If AutoPrune is set to  {\bf yes} (default), Bacula (version 1.20 or greater)
1943    will  automatically apply the File retention period and the Job  retention
1944    period for the Client at the end of the Job.  If you set {\bf AutoPrune = no},
1945    pruning will not be done,  and your Catalog will grow in size each time you
1946    run a Job.  Pruning affects only information in the catalog and not data 
1947    stored in the backup archives (on Volumes).  
1948
1949 \item [Maximum Concurrent Jobs = \lt{}number\gt{}]
1950    \index[dir]{Maximum Concurrent Jobs}
1951    \index[dir]{Directive!Maximum Concurrent Jobs}
1952    where \lt{}number\gt{}  is the maximum number of Jobs with the current Client
1953    that  can run concurrently. Note, this directive limits only Jobs  for Clients
1954    with the same name as the resource in which it appears. Any  other
1955    restrictions on the maximum concurrent jobs such as in  the Director, Job, or
1956    Storage resources will also apply in addition to  any limit specified here.
1957    The  default is set to 1, but you may set it to a larger number.  We strongly
1958    recommend that you read the WARNING documented under  
1959    \ilink{ Maximum Concurrent Jobs}{DirMaxConJobs} in the Director's
1960    resource.  
1961
1962 \item [Priority = \lt{}number\gt{}]
1963    \index[dir]{Priority}
1964    \index[dir]{Directive!Priority}
1965    The number specifies the  priority of this client relative to other clients
1966    that the  Director is processing simultaneously. The priority can range  from
1967    1 to 1000. The clients are ordered such that the smaller  number priorities
1968    are performed first (not currently  implemented). 
1969 \end{description}
1970
1971    The following is an example of a valid Client resource definition: 
1972
1973 \footnotesize
1974 \begin{verbatim}
1975 Client {
1976   Name = Minimatou
1977   FDAddress = minimatou
1978   Catalog = MySQL
1979   Password = very_good
1980 }
1981 \end{verbatim}
1982 \normalsize
1983
1984 \section{The Storage Resource}
1985 \label{StorageResource2}
1986 \index[general]{Resource!Storage}
1987 \index[general]{Storage Resource}
1988
1989 The Storage resource defines which Storage daemons are available for use by
1990 the Director. 
1991
1992 \begin{description}
1993
1994 \item [Storage]
1995    \index[dir]{Storage}
1996    \index[dir]{Directive!Storage}
1997    Start of the Storage resources. At least one  storage resource must be
1998    specified. 
1999
2000 \item [Name = \lt{}name\gt{}]
2001    \index[dir]{Name}
2002    \index[dir]{Directive!Name}
2003    The name of the storage resource. This  name appears on the Storage directive
2004    specified in the Job resource and is required. 
2005
2006 \item [Address = \lt{}address\gt{}]
2007    \index[dir]{Address}
2008    \index[dir]{Directive!SD Address}
2009    \index[dir]{Storage daemon Address}
2010    Where the address is a host name,  a {\bf fully qualified domain name}, or an
2011    {\bf IP address}. Please note  that the \lt{}address\gt{} as specified here
2012    will be transmitted to  the File daemon who will then use it to contact the
2013    Storage daemon. Hence,  it is {\bf not}, a good idea to use {\bf localhost} as
2014    the  name but rather a fully qualified machine name or an IP address.  This
2015    directive is required. 
2016
2017 \item [SD Port = \lt{}port\gt{}]
2018    \index[dir]{SD Port}
2019    \index[dir]{Directive!SD Port}
2020    Where port is the port to use to  contact the storage daemon for information
2021    and to start jobs.  This same port number must appear in the Storage resource
2022    of the  Storage daemon's configuration file. The default is 9103. 
2023
2024 \item [Password = \lt{}password\gt{}]
2025    \index[dir]{Password}
2026    \index[dir]{Directive!Password}
2027    This is the password to be used  when establishing a connection with the
2028    Storage services. This  same password also must appear in the Director
2029    resource of the Storage  daemon's configuration file. This directive is
2030    required.  If you have either {\bf /dev/random}  {\bf bc} on your machine,
2031    Bacula will generate a random  password during the configuration process,
2032    otherwise it will  be left blank. 
2033
2034 \item [Device = \lt{}device-name\gt{}]
2035    \index[dir]{Device}
2036    \index[dir]{Directive!Device}
2037    This directive specifies the Storage daemon's name of the device resource
2038    to be used for the storage.  This name is not the physical device name, but
2039    the logical device name as defined on the {\bf Name} directive contained in
2040    the {\bf Device} resource definition of the {\bf Storage daemon}
2041    configuration file or if the device is an Autochanger, you must put the
2042    name as defined on the {\bf Name} directive contained in the {\bf
2043    Autochanger} resource definition of the {\bf Storage daemon}.  You can
2044    specify any name you would like (even the device name if you prefer) up to
2045    a maximum of 127 characters in length.  The physical device name associated
2046    with this device is specified in the {\bf Storage daemon} configuration
2047    file (as {\bf Archive Device}).  Please take care not to define two
2048    different Storage resource directives in the Director that point to the
2049    same Device in the Storage daemon.  Doing so may cause the Storage daemon
2050    to block (or hang) attempting to open the same device that is already open.
2051    This directive is required.
2052
2053 \label{MediaType}
2054 \item [Media Type = \lt{}MediaType\gt{}]
2055    \index[dir]{Media Type}
2056    \index[dir]{Directive!Media Type}
2057    This directive specifies the Media Type to be used to store the data.
2058    This is an arbitrary string of characters up to 127 maximum that you
2059    define.  It can be anything you want.  However, it is best to make it
2060    descriptive of the storage media (e.g.  File, DAT, "HP DLT8000", 8mm,
2061    ...).  In addition, it is essential that you make the {\bf Media Type}
2062    specification unique for each storage media type.  If you have two DDS-4
2063    drives that have incompatible formats, or if you have a DDS-4 drive and
2064    a DDS-4 autochanger, you almost certainly should specify different {\bf
2065    Media Types}.  During a restore, assuming a {\bf DDS-4} Media Type is
2066    associated with the Job, Bacula can decide to use any Storage daemon
2067    that supports Media Type {\bf DDS-4} and on any drive that supports it.
2068
2069    If you are writing to disk Volumes, you must make doubly sure that each
2070    Device resource defined in the Storage daemon (and hence in the
2071    Director's conf file) has a unique media type.  Otherwise for Bacula
2072    versions 1.38 and older, your restores may not work because Bacula
2073    will assume that you can mount any Media Type with the same name on
2074    any Device associated with that Media Type. This is possible with
2075    tape drives, but with disk drives, unless you are very clever you
2076    cannot mount a Volume in any directory -- this can be done by creating
2077    an appropriate soft link.
2078
2079    Currently Bacula permits only a single Media Type. Consequently, if
2080    you have a drive that supports more than one Media Type, you can
2081    give a unique string to Volumes with different intrinsic Media 
2082    Type (Media Type = DDS-3-4 for DDS-3 and DDS-4 types), but then
2083    those volumes will only be mounted on drives indicated with the
2084    dual type (DDS-3-4).
2085
2086    If you want to tie Bacula to using a single Storage daemon or drive, you
2087    must specify a unique Media Type for that drive.  This is an important
2088    point that should be carefully understood.  Note, this applies equally
2089    to Disk Volumes.  If you define more than one disk Device resource in
2090    your Storage daemon's conf file, the Volumes on those two devices are in
2091    fact incompatible because one can not be mounted on the other device
2092    since they are found in different directories.  For this reason, you
2093    probably should use two different Media Types for your two disk Devices
2094    (even though you might think of them as both being File types).  You can
2095    find more on this subject in the \ilink{Basic Volume
2096    Management}{DiskChapter} chapter of this manual.
2097
2098    The {\bf MediaType} specified here, {\bf must} correspond to the {\bf
2099    Media Type} specified in the {\bf Device} resource of the {\bf Storage
2100    daemon} configuration file.  This directive is required, and it is used
2101    by the Director and the Storage daemon to ensure that a Volume
2102    automatically selected from the Pool corresponds to the physical device.
2103    If a Storage daemon handles multiple devices (e.g.  will write to
2104    various file Volumes on different partitions), this directive allows you
2105    to specify exactly which device.
2106
2107    As mentioned above, the value specified in the Director's Storage  resource
2108    must agree with the value specified in the Device resource in  the {\bf
2109    Storage daemon's} configuration file. It is also an  additional check so  that
2110    you don't try to write data for a DLT onto an 8mm device. 
2111
2112 \label{Autochanger1}
2113 \item [Autochanger = \lt{}yes|no\gt{}]  
2114    \index[dir]{Autochanger}
2115    \index[dir]{Directive!Autochanger}
2116    If you specify {\bf yes}  for this command (the default is {\bf no}), when
2117    you use the {\bf label} command or the {\bf add} command to create a new
2118    Volume, {\bf Bacula} will also request the Autochanger Slot number.
2119    This simplifies creating database entries for Volumes in an autochanger.
2120    If you forget to specify the Slot, the autochanger will not be used.
2121    However, you may modify the Slot associated with a Volume at any time by
2122    using the {\bf update volume} command in the console program.  When {\bf
2123    autochanger} is enabled, the algorithm used by Bacula to search for
2124    available volumes will be modified to consider only Volumes that are
2125    known to be in the autochanger's magazine.  If no {\bf in changer}
2126    volume is found, Bacula will attempt recycling, pruning, ..., and if
2127    still no volume is found, Bacula will search for any volume whether or
2128    not in the magazine.  By privileging in changer volumes, this procedure
2129    minimizes operator intervention.  The default is {\bf no}.
2130
2131    For the autochanger to be used, you must also specify {\bf Autochanger =
2132    yes} in the \ilink{Device Resource}{Autochanger} in the Storage daemon's
2133    configuration file as well as other important Storage daemon
2134    configuration information.  Please consult the \ilink{Using
2135    Autochangers}{AutochangersChapter} manual of this chapter for the details of
2136    using autochangers.
2137
2138 \item [Maximum Concurrent Jobs = \lt{}number\gt{}]
2139    \index[dir]{Maximum Concurrent Jobs}
2140    \index[dir]{Directive!Maximum Concurrent Jobs}
2141    where \lt{}number\gt{}  is the maximum number of Jobs with the current
2142 Storage
2143 resource that  can run concurrently. Note, this directive limits only Jobs 
2144 for Jobs using this Storage daemon. Any  other restrictions on the maximum
2145 concurrent jobs such as in  the Director, Job, or Client resources will also
2146 apply in addition to  any limit specified here. The  default is set to 1, but
2147 you may set it to a larger number.  However, if you set the Storage
2148 daemon's number of concurrent jobs greater than one,
2149 we recommend that you read the
2150 waring documented under  \ilink{Maximum Concurrent Jobs}{DirMaxConJobs} 
2151 in the Director's resource or simply turn data spooling on as documented
2152 in the \ilink{Data Spooling}{SpoolingChapter} chapter of this manual.
2153 \end{description}
2154
2155 The following is an example of a valid Storage resource definition: 
2156
2157 \footnotesize
2158 \begin{verbatim}
2159 # Definition of tape storage device
2160 Storage {
2161   Name = DLTDrive
2162   Address = lpmatou
2163   Password = storage_password # password for Storage daemon
2164   Device = "HP DLT 80"    # same as Device in Storage daemon
2165   Media Type = DLT8000    # same as MediaType in Storage daemon
2166 }
2167 \end{verbatim}
2168 \normalsize
2169
2170 \section{The Pool Resource}
2171 \label{PoolResource}
2172 \index[general]{Resource!Pool}
2173 \index[general]{Pool Resource}
2174
2175 The Pool resource defines the set of storage Volumes (tapes or files) to be
2176 used by Bacula to write the data. By configuring different Pools, you can
2177 determine which set of Volumes (media) receives the backup data. This permits,
2178 for example, to store all full backup data on one set of Volumes and all
2179 incremental backups on another set of Volumes. Alternatively, you could assign
2180 a different set of Volumes to each machine that you backup. This is most
2181 easily done by defining multiple Pools. 
2182
2183 Another important aspect of a Pool is that it contains the default attributes
2184 (Maximum Jobs, Retention Period, Recycle flag, ...) that will be given to a
2185 Volume when it is created. This avoids the need for you to answer a large
2186 number of questions when labeling a new Volume. Each of these attributes can
2187 later be changed on a Volume by Volume basis using the {\bf update} command in
2188 the console program. Note that you must explicitly specify which Pool Bacula
2189 is to use with each Job. Bacula will not automatically search for the correct
2190 Pool. 
2191
2192 Most often in Bacula installations all backups for all machines (Clients) go
2193 to a single set of Volumes. In this case, you will probably only use the {\bf
2194 Default} Pool. If your backup strategy calls for you to mount a different tape
2195 each day, you will probably want to define a separate Pool for each day. For
2196 more information on this subject, please see the 
2197 \ilink{Backup Strategies}{StrategiesChapter} chapter of this
2198 manual. 
2199
2200
2201 To use a Pool, there are three distinct steps. First the Pool must be defined
2202 in the Director's configuration file. Then the Pool must be written to the
2203 Catalog database. This is done automatically by the Director each time that it
2204 starts, or alternatively can be done using the {\bf create} command in the
2205 console program. Finally, if you change the Pool definition in the Director's
2206 configuration file and restart Bacula, the pool will be updated alternatively
2207 you can use the {\bf update pool} console command to refresh the database
2208 image. It is this database image rather than the Director's resource image
2209 that is used for the default Volume attributes. Note, for the pool to be
2210 automatically created or updated, it must be explicitly referenced by a Job
2211 resource. 
2212
2213 Next the physical media must be labeled. The labeling can either be done with
2214 the {\bf label} command in the {\bf console} program or using the {\bf btape}
2215 program. The preferred method is to use the {\bf label} command in the {\bf
2216 console} program. 
2217
2218 Finally, you must add Volume names (and their attributes) to the Pool. For
2219 Volumes to be used by Bacula they must be of the same {\bf Media Type} as the
2220 archive device specified for the job (i.e. if you are going to back up to a
2221 DLT device, the Pool must have DLT volumes defined since 8mm volumes cannot be
2222 mounted on a DLT drive). The {\bf Media Type} has particular importance if you
2223 are backing up to files. When running a Job, you must explicitly specify which
2224 Pool to use. Bacula will then automatically select the next Volume to use from
2225 the Pool, but it will ensure that the {\bf Media Type} of any Volume selected
2226 from the Pool is identical to that required by the Storage resource you have
2227 specified for the Job. 
2228
2229 If you use the {\bf label} command in the console program to label the
2230 Volumes, they will automatically be added to the Pool, so this last step is
2231 not normally required. 
2232
2233 It is also possible to add Volumes to the database without explicitly labeling
2234 the physical volume. This is done with the {\bf add} console command. 
2235
2236 As previously mentioned, each time Bacula starts, it scans all the Pools
2237 associated with each Catalog, and if the database record does not already
2238 exist, it will be created from the Pool Resource definition. {\bf Bacula}
2239 probably should do an {\bf update pool} if you change the Pool definition, but
2240 currently, you must do this manually using the {\bf update pool} command in
2241 the Console program. 
2242
2243 The Pool Resource defined in the Director's configuration file
2244 (bacula-dir.conf) may contain the following directives: 
2245
2246 \begin{description}
2247
2248 \item [Pool]
2249    \index[dir]{Pool}
2250    \index[dir]{Directive!Pool}
2251    Start of the Pool resource.  There must be at least one Pool resource
2252    defined.
2253
2254
2255 \item [Name = \lt{}name\gt{}]
2256    \index[dir]{Name}
2257    \index[dir]{Directive!Name}
2258    The name of the pool.  For most applications, you will use the default
2259    pool name {\bf Default}.  This directive is required.
2260
2261 \label{MaxVolumes}
2262 \item [Maximum Volumes = \lt{}number\gt{}]
2263    \index[dir]{Maximum Volumes}
2264    \index[dir]{Directive!Maximum Volumes}
2265    This directive specifies the maximum number of volumes (tapes or files)
2266    contained in the pool.  This directive is optional, if omitted or set to
2267    zero, any number of volumes will be permitted.  In general, this
2268    directive is useful for Autochangers where there is a fixed number of
2269    Volumes, or for File storage where you wish to ensure that the backups
2270    made to disk files do not become too numerous or consume too much space.
2271
2272 \item [Pool Type = \lt{}type\gt{}]
2273    \index[dir]{Pool Type}
2274    \index[dir]{Directive!Pool Type}
2275    This directive defines the pool type, which corresponds to the type of
2276    Job being run.  It is required and may be one of the following:
2277
2278 \begin{itemize}
2279   \item [Backup]  
2280   \item [*Archive]  
2281   \item [*Cloned]  
2282   \item [*Migration]  
2283   \item [*Copy]  
2284   \item [*Save]  
2285 \end{itemize}
2286    Note, only Backup is current implemented.
2287
2288 \item [Storage = \lt{}storage-resource-name\gt{}]
2289 \index[dir]{Storage}
2290 \index[dir]{Directive!Storage}
2291    The Storage directive defines the name of the storage services where you
2292    want to backup the FileSet data.  For additional details, see the
2293    \ilink{Storage Resource Chapter}{StorageResource2} of this manual.
2294    The Storage resource may also be specified in the Job resource,
2295    but the value, if any, in the Pool resource overrides any value
2296    in the Job. This Storage resource definition is not required by either
2297    the Job resource or in the Pool, but it must be specified in
2298    one or the other.  If not configuration error will result.
2299
2300 \item [Use Volume Once = \lt{}yes|no\gt{}]
2301    \index[dir]{Use Volume Once}
2302    \index[dir]{Directive!Use Volume Once}
2303    This directive if set to {\bf yes} specifies that each volume is to be
2304    used only once.  This is most useful when the Media is a file and you
2305    want a new file for each backup that is done.  The default is {\bf no}
2306    (i.e.  use volume any number of times).  This directive will most likely
2307    be phased out (deprecated), so you are recommended to use {\bf Maximum
2308    Volume Jobs = 1} instead.
2309
2310    The value defined by this directive in the bacula-dir.conf file is the
2311    default value used when a Volume is created.  Once the volume is
2312    created, changing the value in the bacula-dir.conf file will not change
2313    what is stored for the Volume.  To change the value for an existing
2314    Volume you must use the {\bf update} command in the Console.
2315
2316 \item [Maximum Volume Jobs = \lt{}positive-integer\gt{}]
2317    \index[dir]{Maximum Volume Jobs}
2318    \index[dir]{Directive!Maximum Volume Jobs}
2319    This directive specifies the maximum number of Jobs that can be written
2320    to the Volume.  If you specify zero (the default), there is no limit.
2321    Otherwise, when the number of Jobs backed up to the Volume equals {\bf
2322    positive-integer} the Volume will be marked {\bf Used}.  When the Volume
2323    is marked {\bf Used} it can no longer be used for appending Jobs, much
2324    like the {\bf Full} status but it can be recycled if recycling is
2325    enabled, and thus used again.  By setting {\bf MaximumVolumeJobs} to
2326    one, you get the same effect as setting {\bf UseVolumeOnce = yes}.
2327
2328    The value defined by this directive in the  bacula-dir.conf
2329    file is the default value used when a Volume  is created. Once the volume is
2330    created, changing the value  in the bacula-dir.conf file will not change what
2331    is stored  for the Volume. To change the value for an existing Volume  you
2332    must use the {\bf update} command in the Console.  
2333
2334 \item [Maximum Volume Files = \lt{}positive-integer\gt{}]
2335    \index[dir]{Maximum Volume Files}
2336    \index[dir]{Directive!Maximum Volume Files}
2337    This directive specifies the maximum number of files that can be written
2338    to the Volume.  If you specify zero (the default), there is no limit.
2339    Otherwise, when the number of files written to the Volume equals {\bf
2340    positive-integer} the Volume will be marked {\bf Used}.  When the Volume
2341    is marked {\bf Used} it can no longer be used for appending Jobs, much
2342    like the {\bf Full} status but it can be recycled if recycling is
2343    enabled and thus used again.  This value is checked and the {\bf Used}
2344    status is set only at the end of a job that writes to the particular
2345    volume.
2346
2347    The value defined by this directive in the bacula-dir.conf file is the
2348    default value used when a Volume is created.  Once the volume is
2349    created, changing the value in the bacula-dir.conf file will not change
2350    what is stored for the Volume.  To change the value for an existing
2351    Volume you must use the {\bf update} command in the Console.
2352
2353 \item [Maximum Volume Bytes = \lt{}size\gt{}]
2354    \index[dir]{Maximum Volume Bytes}
2355    \index[dir]{Directive!Maximum Volume Bytes}
2356    This directive specifies the maximum number of bytes that can be written
2357    to the Volume.  If you specify zero (the default), there is no limit
2358    except the physical size of the Volume.  Otherwise, when the number of
2359    bytes written to the Volume equals {\bf size} the Volume will be marked
2360    {\bf Used}.  When the Volume is marked {\bf Used} it can no longer be
2361    used for appending Jobs, much like the {\bf Full} status but it can be
2362    recycled if recycling is enabled, and thus the Volume can be re-used
2363    after recycling.  This value is checked and the {\bf Used} status set
2364    while the job is writing to the particular volume.
2365
2366    The value defined by this directive in the bacula-dir.conf file is the
2367    default value used when a Volume is created.  Once the volume is
2368    created, changing the value in the bacula-dir.conf file will not change
2369    what is stored for the Volume.  To change the value for an existing
2370    Volume you must use the {\bf update} command in the Console.
2371
2372 \item [Volume Use Duration = \lt{}time-period-specification\gt{}]
2373    \index[dir]{Volume Use Duration}
2374    \index[dir]{Directive!Volume Use Duration}
2375    The Volume Use Duration directive defines the time period that the
2376    Volume can be written beginning from the time of first data write to the
2377    Volume.  If the time-period specified is zero (the default), the Volume
2378    can be written indefinitely.  Otherwise, the next time a job
2379    runs that wants to access this Volume, and the time period from the
2380    first write to the volume (the first Job written) exceeds the
2381    time-period-specification, the Volume will be marked {\bf Used}, which
2382    means that no more Jobs can be appended to the Volume, but it may be
2383    recycled if recycling is enabled. Using the command {\bf
2384    status dir} applies algorithms similar to running jobs, so
2385    during such a command, the Volume status may also be changed.
2386    Once the Volume is
2387    recycled, it will be available for use again.
2388    
2389    You might use this directive, for example, if you have a Volume used for
2390    Incremental backups, and Volumes used for Weekly Full backups.  Once the
2391    Full backup is done, you will want to use a different Incremental
2392    Volume.  This can be accomplished by setting the Volume Use Duration for
2393    the Incremental Volume to six days.  I.e.  it will be used for the 6
2394    days following a Full save, then a different Incremental volume will be
2395    used.  Be careful about setting the duration to short periods such as 23
2396    hours, or you might experience problems of Bacula waiting for a tape
2397    over the weekend only to complete the backups Monday morning when an
2398    operator mounts a new tape.
2399    
2400    The use duration is checked and the {\bf Used} status is set only at the
2401    end of a job that writes to the particular volume, which means that even
2402    though the use duration may have expired, the catalog entry will not be
2403    updated until the next job that uses this volume is run.
2404    
2405    Please note that the value defined by this directive in the  bacula-dir.conf
2406    file is the default value used when a Volume  is created. Once the volume is
2407    created, changing the value  in the bacula-dir.conf file will not change what
2408    is stored  for the Volume. To change the value for an existing Volume  you
2409    must use the 
2410    \ilink{\bf update volume}{UpdateCommand} command in the Console.  
2411
2412 \item [Catalog Files = \lt{}yes|no\gt{}]
2413    \index[dir]{Catalog Files}
2414    \index[dir]{Directive!Catalog Files}
2415    This directive defines whether or not you want the names of the files
2416    that were saved to be put into the catalog.  The default is {\bf yes}.
2417    The advantage of specifying {\bf Catalog Files = No} is that you will
2418    have a significantly smaller Catalog database.  The disadvantage is that
2419    you will not be able to produce a Catalog listing of the files backed up
2420    for each Job (this is often called Browsing).  Also, without the File
2421    entries in the catalog, you will not be able to use the Console {\bf
2422    restore} command nor any other command that references File entries.
2423    
2424 \label{PoolAutoPrune}
2425 \item [AutoPrune = \lt{}yes|no\gt{}]
2426    \index[dir]{AutoPrune}
2427    \index[dir]{Directive!AutoPrune}
2428    If AutoPrune is set to {\bf yes} (default), Bacula (version 1.20 or
2429    greater) will automatically apply the Volume Retention period when new
2430    Volume is needed and no appendable Volumes exist in the Pool.  Volume
2431    pruning causes expired Jobs (older than the {\bf Volume Retention}
2432    period) to be deleted from the Catalog and permits possible recycling of
2433    the Volume.
2434    
2435 \label{VolRetention}
2436 \item [Volume Retention = \lt{}time-period-specification\gt{}]
2437    \index[dir]{Volume Retention}
2438    \index[dir]{Directive!Volume Retention}
2439    The Volume Retention directive defines the length of time that {\bf
2440    Bacula} will keep Job and Files records associated with the Volume in
2441    the Catalog database after the End time of each Job written to the
2442    Volume.  When this time period expires, and if {\bf AutoPrune} is set to
2443    {\bf yes} Bacula may prune (remove) Job records that are older than the
2444    specified Volume Retention period if it is necessary to free up a
2445    Volume.  Recycling will not occur until it is absolutely necessary to
2446    free up a volume.  All File records associated with pruned Jobs are also
2447    pruned.  The time may be specified as seconds, minutes, hours, days,
2448    weeks, months, quarters, or years.  The {\bf Volume Retention} is
2449    applied independently of the {\bf Job Retention} and the {\bf File
2450    Retention} periods defined in the Client resource.  This means that all
2451    the retentions periods are applied in turn and that the shorter period
2452    is the one that effectively takes precedence.  Note, that when the {\bf
2453    Volume Retention} period has been reached, and it is necessary to obtain
2454    a new volume, Bacula will prune both the Job and the File records.  This
2455    pruning could also occur during a {\bf status dir} command because it
2456    uses similar algorithms for finding the next available Volume.
2457
2458    It is important to know that when the Volume Retention period expires, 
2459    Bacula does not automatically recycle a Volume. It attempts to keep the
2460    Volume data intact as long as possible before over writing the Volume.
2461    
2462    The default Volume retention period is 365 days.  Note, this directive
2463    sets the default value for each Volume entry in the Catalog when the
2464    Volume is created.  The value in the catalog may be later individually
2465    changed for each Volume using the Console program.
2466    
2467    By defining multiple Pools with different Volume Retention periods, you
2468    may effectively have a set of tapes that is recycled weekly, another
2469    Pool of tapes that is recycled monthly and so on.  However, one must
2470    keep in mind that if your {\bf Volume Retention} period is too short, it
2471    may prune the last valid Full backup, and hence until the next Full
2472    backup is done, you will not have a complete backup of your system, and
2473    in addition, the next Incremental or Differential backup will be
2474    promoted to a Full backup.  As a consequence, the minimum {\bf Volume
2475    Retention} period should be at twice the interval of your Full backups.
2476    This means that if you do a Full backup once a month, the minimum Volume
2477    retention period should be two months.
2478    
2479    Please note that the value defined by this directive in the  bacula-dir.conf
2480    file is the default value used when a Volume  is created. Once the volume is
2481    created, changing the value  in the bacula-dir.conf file will not change what
2482    is stored  for the Volume. To change the value for an existing Volume  you
2483    must use the {\bf update} command in the Console.
2484    
2485 \label{PoolRecycle}
2486 \item [Recycle = \lt{}yes|no\gt{}]
2487    \index[dir]{Recycle}
2488    \index[dir]{Directive!Recycle}
2489    This directive specifies whether or not Purged Volumes may be recycled.
2490    If it is set to {\bf yes} (default) and Bacula needs a volume but finds
2491    none that are appendable, it will search for and recycle (reuse) Purged
2492    Volumes (i.e.  volumes with all the Jobs and Files expired and thus
2493    deleted from the Catalog).  If the Volume is recycled, all previous data
2494    written to that Volume will be overwritten. If Recycle is set to {\bf
2495    no}, the Volume will not be recycled, and hence, the data will remain
2496    valid.  If you want to reuse (re-write) the Volume, and the recycle flag
2497    is no (0 in the catalog), you may manually set the recycle flag (update
2498    command) for a Volume to be reused.
2499
2500    Please note that the value defined by this directive in the
2501    bacula-dir.conf file is the default value used when a Volume is created.
2502    Once the volume is created, changing the value in the bacula-dir.conf
2503    file will not change what is stored for the Volume.  To change the value
2504    for an existing Volume you must use the {\bf update} command in the
2505    Console.
2506
2507    When all Job and File records have been pruned or purged from the      
2508    catalog for a particular Volume, if that Volume is marked as
2509    Append, Full, Used, or Error, it will then be marked as Purged. Only
2510    Volumes marked as Purged will be considered to be converted to the
2511    Recycled state if the {\bf Recycle} directive is set to {\bf yes}.
2512
2513
2514 \label{RecycleOldest}
2515 \item [Recycle Oldest Volume = \lt{}yes|no\gt{}]
2516    \index[dir]{Recycle Oldest Volume}
2517    \index[dir]{Directive!Recycle Oldest Volume}
2518    This directive instructs the Director to search for the oldest used
2519    Volume in the Pool when another Volume is requested by the Storage
2520    daemon and none are available.  The catalog is then {\bf pruned}
2521    respecting the retention periods of all Files and Jobs written to this
2522    Volume.  If all Jobs are pruned (i.e. the volume is Purged), then the
2523    Volume is recycled and will be used as the next Volume to be written.
2524    This directive respects any Job, File, or Volume retention periods that
2525    you may have specified, and as such it is {\bf much} better to use this
2526    directive than the Purge Oldest Volume.
2527
2528    This directive can be useful if you have a fixed number of Volumes in the
2529    Pool and you want to cycle through them and you have specified the correct
2530    retention periods.  
2531
2532    However, if you use this directive and have only one
2533    Volume in the Pool, you will immediately recycle your Volume if you fill
2534    it and Bacula needs another one. Thus your backup will be totally invalid.
2535    Please use this directive with care. The default is {\bf no}.
2536
2537 \label{RecycleCurrent}
2538
2539 \item [Recycle Current Volume = \lt{}yes|no\gt{}]
2540    \index[dir]{Recycle Current Volume}
2541    \index[dir]{Directive!Recycle Current Volume}
2542    If Bacula needs a new Volume, this directive instructs Bacula to Prune
2543    the volume respecting the Job and File retention periods.  If all Jobs
2544    are pruned (i.e.  the volume is Purged), then the Volume is recycled and
2545    will be used as the next Volume to be written.  This directive respects
2546    any Job, File, or Volume retention periods that you may have specified,
2547    and thus it is {\bf much} better to use it rather than the Purge Oldest
2548    Volume directive.
2549
2550    This directive can be useful if you have: a fixed number of Volumes in
2551    the Pool, you want to cycle through them, and you have specified
2552    retention periods that prune Volumes before you have cycled through the
2553    Volume in the Pool.
2554
2555    However, if you use this directive and have only one Volume in the Pool,
2556    you will immediately recycle your Volume if you fill it and Bacula needs
2557    another one.  Thus your backup will be totally invalid.  Please use this
2558    directive with care.  The default is {\bf no}.
2559
2560 \label{PurgeOldest}
2561
2562 \item [Purge Oldest Volume = \lt{}yes|no\gt{}]
2563    \index[dir]{Purge Oldest Volume}
2564    \index[dir]{Directive!Purge Oldest Volume}
2565    This directive instructs the Director to search for the oldest used
2566    Volume in the Pool when another Volume is requested by the Storage
2567    daemon and none are available.  The catalog is then {\bf purged}
2568    irrespective of retention periods of all Files and Jobs written to this
2569    Volume.  The Volume is then recycled and will be used as the next Volume
2570    to be written.  This directive overrides any Job, File, or Volume
2571    retention periods that you may have specified.
2572
2573    This directive can be useful if you have a fixed number of Volumes in
2574    the Pool and you want to cycle through them and reusing the oldest one
2575    when all Volumes are full, but you don't want to worry about setting
2576    proper retention periods.  However, by using this option you risk losing
2577    valuable data.
2578
2579    Please be aware that {\bf Purge Oldest Volume} disregards all retention
2580    periods. If you have only a single Volume defined and you turn this
2581    variable on, that Volume will always be immediately overwritten when it
2582    fills!  So at a minimum, ensure that you have a decent number of Volumes
2583    in your Pool before running any jobs.  If you want retention periods to
2584    apply do not use this directive.  To specify a retention period, use the
2585    {\bf Volume Retention} directive (see above).
2586
2587    We {\bf highly} recommend against using this directive, because it is
2588    sure that some day, Bacula will recycle a Volume that contains current
2589    data.  The default is {\bf no}.
2590
2591 \item [Cleaning Prefix = \lt{}string\gt{}]
2592    \index[dir]{Cleaning Prefix}
2593    \index[dir]{Directive!Cleaning Prefix}
2594    This directive defines a prefix string, which if it matches the
2595    beginning of a Volume name during labeling of a Volume, the Volume will
2596    be defined with the VolStatus set to {\bf Cleaning} and thus Bacula will
2597    never attempt to use this tape.  This is primarily for use with
2598    autochangers that accept barcodes where the convention is that barcodes
2599    beginning with {\bf CLN} are treated as cleaning tapes.
2600
2601 \label{Label}
2602 \item [Label Format = \lt{}format\gt{}]
2603    \index[dir]{Label Format}
2604    \index[dir]{Directive!Label Format}
2605    This directive specifies the format of the labels contained in this
2606    pool.  The format directive is used as a sort of template to create new
2607    Volume names during automatic Volume labeling.
2608
2609    The {\bf format} should be specified in double quotes, and consists of
2610    letters, numbers and the special characters hyphen ({\bf -}), underscore
2611    ({\bf \_}), colon ({\bf :}), and period ({\bf .}), which are the legal
2612    characters for a Volume name.  The {\bf format} should be enclosed in
2613    double quotes (").
2614
2615    In addition, the format may contain a number of variable expansion
2616    characters which will be expanded by a complex algorithm allowing you to
2617    create Volume names of many different formats.  In all cases, the
2618    expansion process must resolve to the set of characters noted above that
2619    are legal Volume names.  Generally, these variable expansion characters
2620    begin with a dollar sign ({\bf \$}) or a left bracket ({\bf [}).  If you
2621    specify variable expansion characters, you should always enclose the
2622    format with double quote characters ({\bf "}).  For more details on
2623    variable expansion, please see the \ilink{Variable
2624    Expansion}{VarsChapter} Chapter of this manual.
2625
2626    If no variable expansion characters are found in the string, the Volume
2627    name will be formed from the {\bf format} string appended with the
2628    number of volumes in the pool plus one, which will be edited as four
2629    digits with leading zeros.  For example, with a {\bf Label Format =
2630    "File-"}, the first volumes will be named {\bf File-0001}, {\bf
2631    File-0002}, ...
2632
2633    With the exception of Job specific variables, you can test your {\bf
2634    LabelFormat} by using the \ilink{ var command}{var} the Console Chapter
2635    of this manual.
2636
2637    In almost all cases, you should enclose the format specification (part
2638    after the equal sign) in double quotes.  Please note that this directive
2639    is deprecated and is replaced in version 1.37 and greater with a Python
2640    script for creating volume names.
2641
2642 \end{description}
2643
2644 In order for a Pool to be used during a Backup Job, the Pool must have at
2645 least one Volume associated with it.  Volumes are created for a Pool using
2646 the {\bf label} or the {\bf add} commands in the {\bf Bacula Console},
2647 program.  In addition to adding Volumes to the Pool (i.e.  putting the
2648 Volume names in the Catalog database), the physical Volume must be labeled
2649 with a valid Bacula software volume label before {\bf Bacula} will accept
2650 the Volume.  This will be automatically done if you use the {\bf label}
2651 command.  Bacula can automatically label Volumes if instructed to do so,
2652 but this feature is not yet fully implemented.
2653
2654 The following is an example of a valid Pool resource definition: 
2655
2656 \footnotesize
2657 \begin{verbatim}
2658  
2659 Pool {
2660   Name = Default
2661   Pool Type = Backup
2662 }
2663 \end{verbatim}
2664 \normalsize
2665
2666 \subsection{The Scratch Pool}
2667 \index[general]{Scratch Pool}
2668 In general, you can give your Pools any name you wish, but there is one 
2669 important restriction: the Pool named {\bf Scratch}, if it exists behaves 
2670 like a scratch pool of Volumes in that when Bacula needs a new Volume for 
2671 writing and it cannot find one, it will look in the Scratch pool, and if
2672 it finds an available Volume, it will move it out of the Scratch pool into
2673 the Pool currently being used by the job.
2674
2675
2676 \section{The Catalog Resource}
2677 \label{CatalogResource}
2678 \index[general]{Resource!Catalog}
2679 \index[general]{Catalog Resource}
2680
2681 The Catalog Resource defines what catalog to use for the current job.
2682 Currently, Bacula can only handle a single database server (SQLite, MySQL,
2683 PostgreSQL) that is defined when configuring {\bf Bacula}.  However, there
2684 may be as many Catalogs (databases) defined as you wish.  For example, you
2685 may want each Client to have its own Catalog database, or you may want
2686 backup jobs to use one database and verify or restore jobs to use another
2687 database.
2688
2689 \begin{description}
2690
2691 \item [Catalog]
2692    \index[dir]{Catalog}
2693    \index[dir]{Directive!Catalog}
2694    Start of the Catalog resource.  At least one Catalog resource must be
2695 defined.
2696
2697
2698 \item [Name = \lt{}name\gt{}]
2699    \index[dir]{Name}
2700    \index[dir]{Directive!Name}
2701    The name of the Catalog.  No necessary relation to the database server
2702    name.  This name will be specified in the Client resource directive
2703    indicating that all catalog data for that Client is maintained in this
2704    Catalog.  This directive is required.
2705
2706 \item [password = \lt{}password\gt{}]
2707    \index[dir]{password}
2708    \index[dir]{Directive!password}
2709    This specifies the password to use when logging into the database.  This
2710    directive is required.
2711
2712 \item [DB Name = \lt{}name\gt{}]
2713    \index[dir]{DB Name}
2714    \index[dir]{Directive!DB Name}
2715    This specifies the name of the database.  If you use multiple catalogs
2716    (databases), you specify which one here.  If you are using an external
2717    database server rather than the internal one, you must specify a name
2718    that is known to the server (i.e.  you explicitly created the Bacula
2719    tables using this name.  This directive is required.
2720
2721 \item [user = \lt{}user\gt{}]
2722    \index[dir]{user}
2723    \index[dir]{Directive!user}
2724    This specifies what user name to use to log into the database.  This
2725    directive is required.
2726
2727 \item [DB Socket = \lt{}socket-name\gt{}]
2728    \index[dir]{DB Socket}
2729    \index[dir]{Directive!DB Socket}
2730    This is the name of  a socket to use on the local host to connect to the
2731 database.  This directive is used only by MySQL and is ignored by  SQLite.
2732 Normally, if neither {\bf DB Socket} or {\bf DB Address}  are specified, MySQL
2733 will use the default socket.  
2734
2735 \item [DB Address = \lt{}address\gt{}]
2736    \index[dir]{DB Address}
2737    \index[dir]{Directive!DB Address}
2738    This is the host address  of the database server. Normally, you would specify
2739 this instead  of {\bf DB Socket} if the database server is on another machine.
2740 In that case, you will also specify {\bf DB Port}. This directive  is used
2741 only by MySQL and is ignored by SQLite if provided.  This directive is
2742 optional.  
2743
2744 \item [DB Port = \lt{}port\gt{}]
2745    \index[dir]{DB Port}
2746    \index[dir]{Directive!DB Port}
2747    This defines the port to  be used in conjunction with {\bf DB Address} to
2748 access the  database if it is on another machine. This directive is used  only
2749 by MySQL and is ignored by SQLite if provided. This  directive is optional.  
2750
2751 %% \item [Multiple Connections = \lt{}yes|no\gt{}]
2752 %% \index[dir]{Multiple Connections}
2753 %% \index[dir]{Directive!Multiple Connections}
2754 %% By default, this  directive is set to no. In that case, each job that uses
2755 the
2756 %% same Catalog will use a single connection to the catalog. It will  be shared,
2757 %% and Bacula will allow only one Job at a time to  communicate. If you set this
2758 %% directive to yes, Bacula will  permit multiple connections to the database,
2759 %% and the database  must be multi-thread capable. For SQLite and PostgreSQL,
2760 %% this is  no problem. For MySQL, you must be *very* careful to have the 
2761 %% multi-thread version of the client library loaded on your system.  When this
2762 %% directive is set yes, each Job will have a separate  connection to the
2763 %% database, and the database will control the  interaction between the
2764 different
2765 %% Jobs. This can significantly  speed up the database operations if you are
2766 %% running multiple  simultaneous jobs. In addition, for SQLite and PostgreSQL,
2767 %% Bacula  will automatically enable transactions. This can significantly  speed
2768 %% up insertion of attributes in the database either for  a single Job or
2769 %% multiple simultaneous Jobs.  
2770
2771 %% This directive has not been tested. Please test carefully  before running it
2772 %% in production and report back your results.  
2773
2774 \end{description}
2775
2776 The following is an example of a valid Catalog resource definition: 
2777
2778 \footnotesize
2779 \begin{verbatim}
2780 Catalog
2781 {
2782   Name = SQLite
2783   dbname = bacula;
2784   user = bacula;
2785   password = ""                       # no password = no security
2786 }
2787 \end{verbatim}
2788 \normalsize
2789
2790 or for a Catalog on another machine: 
2791
2792 \footnotesize
2793 \begin{verbatim}
2794 Catalog
2795 {
2796   Name = MySQL
2797   dbname = bacula
2798   user = bacula
2799   password = ""
2800   DB Address = remote.acme.com
2801   DB Port = 1234
2802 }
2803 \end{verbatim}
2804 \normalsize
2805
2806 \section{The Messages Resource}
2807 \label{MessagesResource2}
2808 \index[general]{Resource!Messages}
2809 \index[general]{Messages Resource}
2810
2811 For the details of the Messages Resource, please see the 
2812 \ilink{Messages Resource Chapter}{MessagesChapter} of this
2813 manual. 
2814
2815 \section{The Console Resource}
2816 \label{ConsoleResource1}
2817 \index[general]{Console Resource}
2818 \index[general]{Resource!Console}
2819
2820 As of Bacula version 1.33 and higher, there are three different kinds of
2821 consoles, which the administrator or user can use to interact with the
2822 Director. These three kinds of consoles comprise three different security
2823 levels. 
2824
2825 \begin{itemize}
2826 \item The first console type is an {\bf anonymous} or {\bf default}  console,
2827    which has full privileges.  There is no console resource necessary for
2828    this type since the password is specified in the Director's resource and
2829    consequently such consoles do not have a name as defined on a {\bf Name
2830    =} directive.  This is the kind of console that was initially
2831    implemented in versions prior to 1.33 and remains valid.  Typically you
2832    would use it only for  administrators.  
2833
2834 \item The second type of console, and new to version 1.33 and  higher is a
2835    "named" console defined within a Console resource in both the Director's
2836    configuration file and in the Console's configuration file.  Both the
2837    names and the passwords in these two entries must match much as is the
2838    case for Client programs.
2839
2840    This second type of console begins with absolutely no privileges except
2841    those explicitly specified in the Director's Console resource.  Thus you
2842    can have multiple Consoles with different names and passwords, sort of
2843    like multiple users, each with different privileges.  As a default,
2844    these consoles can do absolutely nothing -- no commands whatsoever.  You
2845    give them privileges or rather access to commands and resources by
2846    specifying access control lists in the Director's Console resource.  The
2847    ACLs are specified by a directive followed by a list of access names.
2848    Examples of this are shown below.
2849
2850 \item The third type of console is similar to the above mentioned  one in that
2851    it requires a Console resource definition in both the Director and the
2852    Console.  In addition, if the console name, provided on the {\bf Name =}
2853    directive, is the same as a Client name, that console is permitted to
2854    use the {\bf SetIP} command to change the Address directive in the
2855    Director's client resource to the IP address of the Console.  This
2856    permits portables or other machines using DHCP (non-fixed IP addresses)
2857    to "notify" the Director of their current IP address.
2858 \end{itemize}
2859
2860 The Console resource is optional and need not be specified. The following
2861 directives are permitted within the Director's configuration resource: 
2862
2863 \begin{description}
2864
2865 \item [Name = \lt{}name\gt{}]
2866    \index[dir]{Name}
2867    \index[dir]{Directive!Name}
2868    The name of the console. This  name must match the name specified in the
2869 Console's configuration  resource (much as is the case with Client
2870 definitions).  
2871
2872 \item [Password = \lt{}password\gt{}]
2873    \index[dir]{Password}
2874    \index[dir]{Directive!Password}
2875    Specifies the password that must be supplied for a named Bacula Console
2876    to be authorized.  The same password must appear in the {\bf Console}
2877    resource of the Console configuration file.  For added security, the
2878    password is never actually passed across the network but rather a
2879    challenge response hash code created with the password.  This directive
2880    is required.  If you have either {\bf /dev/random} {\bf bc} on your
2881    machine, Bacula will generate a random password during the configuration
2882    process, otherwise it will be left blank.
2883
2884 \item [JobACL = \lt{}name-list\gt{}]
2885    \index[dir]{JobACL}
2886    \index[dir]{Directive!JobACL}
2887    This directive is used to specify a list of Job resource names that can
2888    be accessed by the console.  Without this directive, the console cannot
2889    access any of the Director's Job resources.  Multiple Job resource names
2890    may be specified by separating them with commas, and/or by specifying
2891    multiple JobACL directives.  For example, the directive may be specified
2892    as:
2893
2894 \footnotesize
2895 \begin{verbatim}
2896     JobACL = kernsave, "Backup client 1", "Backup client 2"
2897     JobACL = "RestoreFiles"
2898     
2899 \end{verbatim}
2900 \normalsize
2901
2902 With the above specification, the console can access the Director's  resources
2903 for the four jobs named on the JobACL directives,  but for no others.  
2904
2905 \item [ClientACL = \lt{}name-list\gt{}]
2906    \index[dir]{ClientACL}
2907    \index[dir]{Directive!ClientACL}
2908    This directive is used to  specify a list of Client resource names that can
2909 be
2910 accessed by  the console.  
2911
2912 \item [StorageACL = \lt{}name-list\gt{}]
2913    \index[dir]{StorageACL}
2914    \index[dir]{Directive!StorageACL}
2915    This directive is used to  specify a list of Storage resource names that can
2916 be accessed by  the console.  
2917
2918 \item [ScheduleACL = \lt{}name-list\gt{}]
2919    \index[dir]{ScheduleACL}
2920    \index[dir]{Directive!ScheduleACL}
2921    This directive is used to  specify a list of Schedule resource names that can
2922    be accessed by the console.
2923
2924 \item [PoolACL = \lt{}name-list\gt{}]
2925    \index[dir]{PoolACL}
2926    \index[dir]{Directive!PoolACL}
2927    This directive is used to  specify a list of Pool resource names that can be
2928    accessed by the console.
2929
2930 \item [FileSetACL = \lt{}name-list\gt{}]
2931    \index[dir]{FileSetACL}
2932    \index[dir]{Directive!FileSetACL}
2933    This directive is used to specify a list of FileSet resource names that
2934    can be accessed by the console.
2935
2936 \item [CatalogACL = \lt{}name-list\gt{}]
2937    \index[dir]{CatalogACL}
2938    \index[dir]{Directive!CatalogACL}
2939    This directive is used to specify a list of Catalog resource names that
2940    can be accessed by the console.
2941
2942 \item [CommandACL = \lt{}name-list\gt{}]
2943    \index[dir]{CommandACL}
2944    \index[dir]{Directive!CommandACL}
2945    This directive is used to specify a list of of console commands that can
2946    be executed by the console.
2947
2948 \item [WhereACL = \lt{}string\gt{}]
2949    \index[dir]{WhereACL}
2950    \index[dir]{Directive!WhereACL}
2951    This directive permits you to specify where a restricted console
2952    can restore files. If this directive is not specified, only the
2953    default restore location is permitted (normally {\bf
2954    /tmp/bacula-restores}. If {\bf *all*} is specified any path the
2955    user enters will be accepted (not very secure), any other
2956    value specified (there may be multiple WhereACL directives) will
2957    restrict the user to use that path. For example, on a Unix system,
2958    if you specify "/", the file will be restored to the original 
2959    location.  This directive is untested.
2960
2961 \end{description}
2962
2963 Aside from Director resource names and console command names, the special
2964 keyword {\bf *all*} can be specified in any of the above access control lists.
2965 When this keyword is present, any resource or command name (which ever is
2966 appropriate) will be accepted. For an example configuration file, please see
2967 the 
2968 \ilink{Console Configuration}{ConsoleConfChapter} chapter of this
2969 manual. 
2970
2971 \section{The Counter Resource}
2972 \label{CounterResource}
2973 \index[general]{Resource!Counter}
2974 \index[general]{Counter Resource}
2975
2976 The Counter Resource defines a counter variable that can be accessed by
2977 variable expansion used for creating Volume labels with the {\bf LabelFormat}
2978 directive. See the 
2979 \ilink{LabelFormat}{Label} directive in this chapter for more
2980 details. 
2981
2982 \begin{description}
2983
2984 \item [Counter] 
2985    \index[dir]{Counter}
2986    \index[dir]{Directive!Counter}
2987    Start of the Counter resource.  Counter directives are optional. 
2988
2989 \item [Name = \lt{}name\gt{}]
2990    \index[dir]{Name}
2991    \index[dir]{Directive!Name}
2992    The name of the Counter.  This is the name you will use in the variable
2993 expansion  to reference the counter value.  
2994
2995 \item [Minimum = \lt{}integer\gt{}]
2996    \index[dir]{Minimum}
2997    \index[dir]{Directive!Minimum}
2998    This specifies the minimum  value that the counter can have. It also becomes
2999 the default.  If not supplied, zero is assumed.  
3000
3001 \item [Maximum = \lt{}integer\gt{}]
3002    \index[dir]{Maximum}
3003    \index[dir]{Directive!Maximum}
3004    \index[dir]{Directive!Maximum}
3005    This is the maximum value  value that the counter can have. If not specified
3006 or set to  zero, the counter can have a maximum value of 2,147,483,648  (2 to
3007 the 31 power). When the counter is incremented past  this value, it is reset
3008 to the Minimum.  
3009
3010 \item [*WrapCounter = \lt{}counter-name\gt{}]
3011    \index[dir]{*WrapCounter}
3012    \index[dir]{Directive!*WrapCounter}
3013    If this value  is specified, when the counter is incremented past the
3014 maximum 
3015 and thus reset to the minimum, the counter specified on the  {\bf WrapCounter}
3016 is incremented. (This is not currently  implemented). 
3017
3018 \item [Catalog = \lt{}catalog-name\gt{}]
3019    \index[dir]{Catalog}
3020    \index[dir]{Directive!Catalog}
3021    If this directive is  specified, the counter and its values will be saved in 
3022 the specified catalog. If this directive is not present, the  counter will be
3023 redefined each time that Bacula is started. 
3024 \end{description}
3025
3026 \section{Example Director Configuration File}
3027 \label{SampleDirectorConfiguration}
3028 \index[general]{File!Example Director Configuration}
3029 \index[general]{Example Director Configuration File}
3030
3031 An example Director configuration file might be the following: 
3032
3033 \footnotesize
3034 \begin{verbatim}
3035 #
3036 # Default Bacula Director Configuration file
3037 #
3038 #  The only thing that MUST be changed is to add one or more
3039 #   file or directory names in the Include directive of the
3040 #   FileSet resource.
3041 #
3042 #  For Bacula release 1.15 (5 March 2002) -- redhat
3043 #
3044 #  You might also want to change the default email address
3045 #   from root to your address.  See the "mail" and "operator"
3046 #   directives in the Messages resource.
3047 #
3048 Director {                            # define myself
3049   Name = rufus-dir
3050   QueryFile = "/home/kern/bacula/bin/query.sql"
3051   WorkingDirectory = "/home/kern/bacula/bin/working"
3052   PidDirectory = "/home/kern/bacula/bin/working"
3053   Password = "XkSfzu/Cf/wX4L8Zh4G4/yhCbpLcz3YVdmVoQvU3EyF/"
3054 }
3055 # Define the backup Job
3056 Job {
3057   Name = "NightlySave"
3058   Type = Backup
3059   Level = Incremental                 # default
3060   Client=rufus-fd
3061   FileSet="Full Set"
3062   Schedule = "WeeklyCycle"
3063   Storage = DLTDrive
3064   Messages = Standard
3065   Pool = Default
3066 }
3067 Job {
3068   Name = "Restore"
3069   Type = Restore
3070   Client=rufus-fd
3071   FileSet="Full Set"
3072   Where = /tmp/bacula-restores
3073   Storage = DLTDrive
3074   Messages = Standard
3075   Pool = Default
3076 }
3077    
3078 # List of files to be backed up
3079 FileSet {
3080   Name = "Full Set"
3081   Include {
3082     Options { signature=SHA1}
3083 #
3084 #  Put your list of files here, one per line or include an
3085 #    external list with:
3086 #
3087 #    @file-name
3088 #
3089 #  Note: / backs up everything
3090   File = /
3091 }
3092   Exclude {}
3093 }
3094 # When to do the backups
3095 Schedule {
3096   Name = "WeeklyCycle"
3097   Run = level=Full sun at 1:05
3098   Run = level=Incremental mon-sat at 1:05
3099 }
3100 # Client (File Services) to backup
3101 Client {
3102   Name = rufus-fd
3103   Address = rufus
3104   Catalog = MyCatalog
3105   Password = "MQk6lVinz4GG2hdIZk1dsKE/LxMZGo6znMHiD7t7vzF+"
3106   File Retention = 60d      # sixty day file retention
3107   Job Retention = 1y        # 1 year Job retention
3108   AutoPrune = yes           # Auto apply retention periods
3109 }
3110 # Definition of DLT tape storage device
3111 Storage {
3112   Name = DLTDrive
3113   Address = rufus
3114   Password = "jMeWZvfikUHvt3kzKVVPpQ0ccmV6emPnF2cPYFdhLApQ"
3115   Device = "HP DLT 80"      # same as Device in Storage daemon
3116   Media Type = DLT8000      # same as MediaType in Storage daemon
3117 }
3118 # Definition for a DLT autochanger device
3119 Storage {
3120   Name = Autochanger
3121   Address = rufus
3122   Password = "jMeWZvfikUHvt3kzKVVPpQ0ccmV6emPnF2cPYFdhLApQ"
3123   Device = "Autochanger"    # same as Device in Storage daemon
3124   Media Type = DLT-8000     # Different from DLTDrive
3125   Autochanger = yes
3126 }
3127 # Definition of DDS tape storage device
3128 Storage {
3129   Name = SDT-10000
3130   Address = rufus
3131   Password = "jMeWZvfikUHvt3kzKVVPpQ0ccmV6emPnF2cPYFdhLApQ"
3132   Device = SDT-10000        # same as Device in Storage daemon
3133   Media Type = DDS-4        # same as MediaType in Storage daemon
3134 }
3135 # Definition of 8mm tape storage device
3136 Storage {
3137   Name = "8mmDrive"
3138   Address = rufus
3139   Password = "jMeWZvfikUHvt3kzKVVPpQ0ccmV6emPnF2cPYFdhLApQ"
3140   Device = "Exabyte 8mm"
3141   MediaType = "8mm"
3142 }
3143 # Definition of file storage device
3144 Storage {
3145   Name = File
3146   Address = rufus
3147   Password = "jMeWZvfikUHvt3kzKVVPpQ0ccmV6emPnF2cPYFdhLApQ"
3148   Device = FileStorage
3149   Media Type = File
3150 }
3151 # Generic catalog service
3152 Catalog {
3153   Name = MyCatalog
3154   dbname = bacula; user = bacula; password = ""
3155 }
3156 # Reasonable message delivery -- send most everything to
3157 #   the email address and to the console
3158 Messages {
3159   Name = Standard
3160   mail = root@localhost = all, !skipped, !terminate
3161   operator = root@localhost = mount
3162   console = all, !skipped, !saved
3163 }
3164     
3165 # Default pool definition
3166 Pool {
3167   Name = Default
3168   Pool Type = Backup
3169   AutoPrune = yes
3170   Recycle = yes
3171 }
3172 #
3173 # Restricted console used by tray-monitor to get the status of the director
3174 #
3175 Console {
3176   Name = Monitor
3177   Password = "GN0uRo7PTUmlMbqrJ2Gr1p0fk0HQJTxwnFyE4WSST3MWZseR"
3178   CommandACL = status, .status
3179 }
3180 \end{verbatim}
3181 \normalsize