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