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