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