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