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