]> git.sur5r.net Git - bacula/docs/blob - docs/manuals/en/main/fileset.tex
Update documentation for AllowCompression feature
[bacula/docs] / docs / manuals / en / main / fileset.tex
1 -%
2 %%
3
4 \section{The FileSet Resource}
5 \label{FileSetResource}
6 \index[general]{Resource!FileSet}
7 \index[general]{FileSet Resource}
8
9 The FileSet resource defines what files are to be included or excluded in a
10 backup job.  A {\bf FileSet} resource is required for each backup Job.  It
11 consists of a list of files or directories to be included, a list of files
12 or directories to be excluded and the various backup options such as
13 compression, encryption, and signatures that are to be applied to each
14 file.
15
16 Any change to the list of the included files will cause Bacula to
17 automatically create a new FileSet (defined by the name and an MD5 checksum
18 of the Include/Exclude contents).  Each time a new FileSet is created,
19 Bacula will ensure that the next backup is always a Full save.
20
21 Bacula is designed to handle most character sets of the world,
22 US ASCII, German, French, Chinese, ...  However, it does this by
23 encoding everything in UTF-8, and it expects all configuration files
24 (including those read on Win32 machines) to be in UTF-8 format.
25 UTF-8 is typically the default on Linux machines, but not on all
26 Unix machines, nor on Windows, so you must take some care to ensure
27 that your locale is set properly before starting Bacula.  
28 On most modern Win32 machines, you can edit the conf files with {\bf
29 notebook} and choose output encoding UTF-8.
30
31 To ensure that Bacula configuration files can be correctly read including
32 foreign characters the {bf LANG} environment variable
33 must end in {\bf .UTF-8}. An full example is {\bf en\_US.UTF-8}. The
34 exact syntax may vary a bit from OS to OS, and exactly how you define
35 it will also vary.
36
37 Bacula assumes that all filenames are in UTF-8 format on Linux and
38 Unix machines. On Win32 they are in Unicode (UTF-16), and will
39 be automatically converted to UTF-8 format.
40
41
42 \begin{description}
43
44 \item [FileSet]
45 \index[dir]{FileSet}
46 \index[dir]{Directive!FileSet}
47 Start of the FileSet resource. One {\bf FileSet}  resource must be
48 defined for each Backup job.
49
50 \item [Name = \lt{}name\gt{}]
51 \index[dir]{Name}
52 \index[dir]{Directive!Name}
53    The name of the FileSet resource.  This directive is required. 
54
55 \item [Ignore FileSet Changes = \lt{}yes\vb{}no\gt{}]
56 \index[dir]{Ignore FileSet Changes}
57 \index[dir]{Directive!Ignore FileSet Changes}
58    Normally, if you modify the FileSet Include or Exclude lists,
59    the next backup will be forced to a Full so that Bacula can
60    guarantee that any additions or deletions are properly saved.
61
62    We strongly recommend against setting this directive to yes, 
63    since doing so may cause you to have an incomplete set of backups.
64
65    If this directive is set to {\bf yes}, any changes you make to the
66    FileSet Include or Exclude lists, will not force a Full during 
67    subsequent backups.
68
69    The default is {\bf no}, in which case, if you change the Include or
70    Exclude, Bacula will force a Full backup to ensure that everything is
71    properly backed up.
72
73 \item [Enable VSS = \lt{}yes\vb{}no\gt{}]
74 \index[dir]{Enable VSS}
75 \index[dir]{Directive!Enable VSS}
76   If this directive is set to {\bf yes} the File daemon will be notified
77   that the user wants to use a Volume Shadow Copy Service (VSS) backup
78   for this job. The default is {\bf yes}. This directive is effective
79   only for VSS enabled Win32 File daemons. It permits a consistent copy
80   of open files to be made for cooperating writer applications, and for
81   applications that are not VSS away, Bacula can at least copy open files.
82   For more information, please see the
83   \ilink{Windows}{VSS} chapter of this manual.
84
85
86 \item [Include \{ Options \{\lt{}file-options\gt{}\} ...;
87    \lt{}file-list\gt{} \} ]
88 \index[dir]{Include \{ [ Options \{\lt{}file-options\gt{}\} ...]
89    \lt{}file-list\gt{} \}  }
90 \index[dir]{Directive!Include}
91
92 \item [Options \{ \lt{}file-options\gt{} \} ]
93 \index[dir]{Options  \{ \lt{}file-options\gt{} \}  }
94
95 \item [Exclude \{ \lt{}file-list\gt{} \}]
96 \index[dir]{Exclude \{ \lt{}file-list\gt{} \} }
97 \index[dir]{Directive!Exclude}
98
99
100 \end{description}
101
102 The Include resource must contain a list of directories and/or files to be
103 processed in the backup job.  Normally, all files found in all
104 subdirectories of any directory in the Include File list will be backed up.
105 Note, see below for the definition of \lt{}file-list\gt{}.
106 The Include resource may also contain one or more Options resources that
107 specify options such as compression to be applied to all or any subset of
108 the files found when processing the file-list for backup. Please see
109 below for more details concerning Options resources.
110
111 There can be any number of {\bf Include} resources within the FileSet, each
112 having its own list of directories or files to be backed up and the backup
113 options defined by one or more Options resources.  The {\bf file-list}
114 consists of one file or directory name per line.  Directory names should be
115 specified without a trailing slash with Unix path notation.
116
117 Windows users, please take note to specify directories (even c:/...) in
118 Unix path notation. If you use Windows conventions, you will most likely
119 not be able to restore your files due to the fact that the Windows
120 path separator was defined as an escape character long before Windows
121 existed, and Bacula adheres to that convention (i.e. \\  means the next character
122 appears as itself).
123
124 You should always specify a full path for every directory and file that you
125 list in the FileSet.  In addition, on Windows machines, you should {\bf
126 always} prefix the directory or filename with the drive specification
127 (e.g.  {\bf c:/xxx}) using Unix directory name separators
128 (forward slash).  The drive letter itself can be upper or lower case (e.g.
129 c:/xxx or C:/xxx).
130
131 Bacula's default for processing directories is to recursively descend in
132 the directory saving all files and subdirectories.  Bacula will not by
133 default cross filesystems (or mount points in Unix parlance).  This means
134 that if you specify the root partition (e.g.  {\bf /}), Bacula will save
135 only the root partition and not any of the other mounted filesystems.
136 Similarly on Windows systems, you must explicitly specify each of the
137 drives you want saved (e.g.
138 {\bf c:/} and {\bf d:/} ...). In addition, at least for Windows systems, you
139 will most likely want to enclose each specification within double quotes
140 particularly if the directory (or file) name contains spaces. The {\bf df}
141 command on Unix systems will show you which mount points you must specify to
142 save everything. See below for an example. 
143
144 Take special care not to include a directory twice or Bacula will backup
145 the same files two times wasting a lot of space on your archive device.
146 Including a directory twice is very easy to do.  For example:
147
148 \footnotesize
149 \begin{verbatim}
150   Include {
151     File = /
152     File = /usr
153     Options { compression=GZIP }
154   }
155 \end{verbatim}
156 \normalsize
157
158 on a Unix system where /usr is a subdirectory (rather than a mounted
159 filesystem) will cause /usr to be backed up twice. In this case, on Bacula
160 versions prior to 1.32f-5-09Mar04 due to a bug, you will not be able to
161 restore hard linked files that were backed up twice. 
162
163 If you have used Bacula prior to version 1.36.3, you will note three things in
164 the new FileSet syntax: 
165
166 \begin{enumerate}
167 \item There is no equal sign (=) after the Include and before the opening
168    brace (\{). The same is true for the Exclude. 
169 \item Each directory (or filename) to be included or excluded is preceded by a {\bf File
170    =}.  Previously they were simply listed on separate lines. 
171 \item The options that previously appeared on the Include line now must be
172    specified within their own Options resource.
173 \item The Exclude resource does not accept Options. 
174 \item When using wild-cards or regular expressions, directory names are
175    always terminated with a slash (/) and filenames have no trailing slash.
176 \end{enumerate}
177
178 The Options resource is optional, but when specified, it will contain a
179 list of {\bf keyword=value} options to be applied to the file-list.
180 See below for the definition of file-list.    
181 Multiple Options resources may be specified one after another.  As the
182 files are found in the specified directories, the Options will applied to
183 the filenames to determine if and how the file should be backed up.  The
184 wildcard and regular expression pattern matching parts of the
185 Options resources are checked in the order they are specified in the
186 FileSet until the first one that matches. Once one matches, the
187 compression and other flags within the Options specification will
188 apply to the pattern matched.
189
190 A key point is that in the absence of an Option or no other Option is
191 matched, every file is accepted for backing up. This means that if
192 you want to exclude something, you must explicitly specify an Option
193 with an {\bf exclude = yes} and some pattern matching.
194
195 Once Bacula determines that the Options resource matches the file under
196 consideration, that file will be saved without looking at any other Options
197 resources that may be present.  This means that any wild cards must appear
198 before an Options resource without wild cards.
199
200 If for some reason, Bacula checks all the Options resources to a file under
201 consideration for backup, but there are no matches (generally because of wild
202 cards that don't match), Bacula as a default will then backup the file.  This
203 is quite logical if you consider the case of no Options clause is specified,
204 where you want everything to be backed up, and it is important to keep in mind
205 when excluding as mentioned above.
206
207 However, one additional point is that in the case that no match was found,
208 Bacula will use the options found in the last Options resource.  As a
209 consequence, if you want a particular set of "default" options, you should put
210 them in an Options resource after any other Options.
211
212 It is a good idea to put all your wild-card and regex expressions inside
213 double quotes to prevent conf file scanning problems.
214
215 This is perhaps a bit overwhelming, so there are a number of examples included 
216 below to illustrate how this works.
217
218 You find yourself using a lot of Regex statements, which will cost quite a lot
219 of CPU time, we recommend you simplify them if you can, or better yet
220 convert them to Wild statements which are much more efficient.
221
222 The directives within an Options resource may be one of the following: 
223
224 \begin{description}
225
226 \item [compression=GZIP]
227 \index[dir]{compression}
228 \index[dir]{Directive!compression}
229    All files saved will be software compressed using the GNU ZIP
230    compression format.  The compression is done on a file by file basis by
231    the File daemon.  If there is a problem reading the tape in a single
232    record of a file, it will at most affect that file and none of the other
233    files on the tape.  Normally this option is {\bf not} needed if you have
234    a modern tape drive as the drive will do its own compression.  In fact,
235    if you specify software compression at the same time you have hardware
236    compression turned on, your files may actually take more space on the
237    volume.
238
239    Software compression is very important if you are writing your Volumes
240    to a file, and it can also be helpful if you have a fast computer but a
241    slow network, otherwise it is generally better to rely your tape drive's
242    hardware compression.  As noted above, it is not generally a good idea
243    to do both software and hardware compression.
244
245    Specifying {\bf GZIP} uses the default compression level 6 (i.e.  {\bf
246    GZIP} is identical to {\bf GZIP6}).  If you want a different compression
247    level (1 through 9), you can specify it by appending the level number
248    with no intervening spaces to {\bf GZIP}.  Thus {\bf compression=GZIP1}
249    would give minimum compression but the fastest algorithm, and {\bf
250    compression=GZIP9} would give the highest level of compression, but
251    requires more computation.  According to the GZIP documentation,
252    compression levels greater than six generally give very little extra
253    compression and are rather CPU intensive.
254
255    You can overwrite this option per Storage resource with
256    \ilink{AllowCompression}{AllowCompression} option.
257
258 \item [signature=SHA1]
259 \index[dir]{signature}
260 \index[dir]{SHA1}
261 \index[dir]{Directive!signature}
262    An SHA1 signature will be computed for all The SHA1 algorithm is
263    purported to be some what slower than the MD5 algorithm, but at the same
264    time is significantly better from a cryptographic point of view (i.e.
265    much fewer collisions, much lower probability of being hacked.) It adds
266    four more bytes than the MD5 signature.  We strongly recommend that
267    either this option or MD5 be specified as a default for all files.
268    Note, only one of the two options MD5 or SHA1 can be computed for any
269    file.
270
271 \item [signature=MD5]
272 \index[dir]{signature}
273 \index[dir]{MD5}
274 \index[dir]{Directive!signature}
275    An MD5 signature will be computed for all files saved.  Adding this
276    option generates about 5\% extra overhead for each file saved.  In
277    addition to the additional CPU time, the MD5 signature adds 16 more
278    bytes per file to your catalog.  We strongly recommend that this option
279    or the SHA1 option be specified as a default for all files.
280
281
282 \item[basejob=\lt{}options\gt{}] 
283 \index[dir]{basejob}
284 \index[dir]{Directive!basejob}
285
286 The options letters specified are used when running a {\bf Backup Level=Full}
287 with BaseJobs. The options letters are the same than in the \textbf{verify=}
288 option below.
289
290 \item[accurate=\lt{}options\gt{}] 
291 \index[dir]{accurate}
292 \index[dir]{Directive!accurate}
293    The options letters specified are used  when running a {\bf Backup
294    Level=Incremental/Differential} in Accurate mode. The options
295    letters are the same than in the \textbf{verify=} option below.  
296
297 \item [verify=\lt{}options\gt{}]
298 \index[dir]{verify}
299 \index[dir]{Directive!verify}
300    The options letters specified are used  when running a {\bf Verify
301    Level=Catalog} as well as the  {\bf DiskToCatalog} level job. The options
302    letters may be any  combination of the following:  
303
304       \begin{description}
305
306       \item {\bf i}
307       compare the inodes  
308
309       \item {\bf p}
310       compare the permission bits  
311
312       \item {\bf n}
313       compare the number of links  
314
315       \item {\bf u}
316       compare the user id  
317
318       \item {\bf g}
319       compare the group id  
320
321       \item {\bf s}
322       compare the size  
323
324       \item {\bf a}
325       compare the access time  
326
327       \item {\bf m}
328       compare the modification time (st\_mtime)  
329
330       \item {\bf c}
331       compare the change time (st\_ctime)  
332
333       \item {\bf d}
334       report file size decreases  
335
336       \item {\bf 5}
337       compare the MD5 signature  
338
339       \item {\bf 1}
340       compare the SHA1 signature  
341       \end{description}
342
343    A useful set of general options on the {\bf Level=Catalog}  or {\bf
344    Level=DiskToCatalog}  verify is {\bf pins5} i.e. compare permission bits,
345    inodes, number  of links, size, and MD5 changes. 
346
347 \item [onefs=yes\vb{}no]
348 \index[dir]{onefs}
349 \index[dir]{Directive!onefs}
350    If set to {\bf yes} (the default), {\bf Bacula} will remain on a single
351    file system.  That is it will not backup file systems that are mounted
352    on a subdirectory.  If you are using a *nix system, you may not even be
353    aware that there are several different filesystems as they are often
354    automatically mounted by the OS (e.g.  /dev, /net, /sys, /proc, ...).
355    With Bacula 1.38.0 or later, it will inform you when it decides not to
356    traverse into another filesystem.  This can be very useful if you forgot
357    to backup a particular partition.  An example of the informational
358    message in the job report is:
359
360 \footnotesize
361 \begin{verbatim}
362 rufus-fd: /misc is a different filesystem. Will not descend from / into /misc
363 rufus-fd: /net is a different filesystem. Will not descend from / into /net
364 rufus-fd: /var/lib/nfs/rpc_pipefs is a different filesystem. Will not descend from /var/lib/nfs into /var/lib/nfs/rpc_pipefs
365 rufus-fd: /selinux is a different filesystem. Will not descend from / into /selinux
366 rufus-fd: /sys is a different filesystem. Will not descend from / into /sys
367 rufus-fd: /dev is a different filesystem. Will not descend from / into /dev
368 rufus-fd: /home is a different filesystem. Will not descend from / into /home
369 \end{verbatim}
370 \normalsize
371
372    Note: in previous versions of Bacula, the above message was of the form: 
373
374 \footnotesize
375 \begin{verbatim}
376 Filesystem change prohibited. Will not descend into /misc
377 \end{verbatim}
378 \normalsize
379
380    If you wish to backup multiple filesystems, you can  explicitly
381    list each filesystem you want saved.  Otherwise, if you set the onefs option
382    to {\bf no}, Bacula will backup  all mounted file systems (i.e. traverse mount
383    points) that  are found within the {\bf FileSet}. Thus if  you have NFS or
384    Samba file systems mounted on a directory listed  in your FileSet, they will
385    also be backed up. Normally, it is  preferable to set {\bf onefs=yes} and to
386    explicitly name  each filesystem you want backed up. Explicitly naming  the
387    filesystems you want backed up avoids the possibility  of getting into a
388    infinite loop recursing filesystems.  Another possibility is to 
389    use {\bf onefs=no} and to set {\bf fstype=ext2, ...}.             
390    See the example below for more details. 
391
392    If you think that Bacula should be backing up a particular directory
393    and it is not, and you have {\bf onefs=no} set, before you complain,
394    please do:
395
396 \footnotesize
397 \begin{verbatim}
398   stat /
399   stat <filesystem>
400 \end{verbatim}
401 \normalsize
402
403 where you replace {\bf filesystem} with the one in question.  If the 
404 {\bf Device:} number is different for / and for your filesystem, then they
405 are on different filesystems.  E.g.
406 \footnotesize
407 \begin{verbatim}
408 stat /
409   File: `/'
410   Size: 4096            Blocks: 16         IO Block: 4096   directory
411 Device: 302h/770d       Inode: 2           Links: 26
412 Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
413 Access: 2005-11-10 12:28:01.000000000 +0100
414 Modify: 2005-09-27 17:52:32.000000000 +0200
415 Change: 2005-09-27 17:52:32.000000000 +0200
416
417 stat /net
418   File: `/home'
419   Size: 4096            Blocks: 16         IO Block: 4096   directory
420 Device: 308h/776d       Inode: 2           Links: 7
421 Access: (0755/drwxr-xr-x)  Uid: (    0/    root)   Gid: (    0/    root)
422 Access: 2005-11-10 12:28:02.000000000 +0100
423 Modify: 2005-11-06 12:36:48.000000000 +0100
424 Change: 2005-11-06 12:36:48.000000000 +0100
425 \end{verbatim}
426 \normalsize
427
428    Also be aware that even if you include {\bf /home} in your list
429    of files to backup, as you most likely should, you will get the
430    informational message that  "/home is a different filesystem" when 
431    Bacula is processing the {\bf /} directory.  This message does not
432    indicate an error. This message means that while examining the 
433    {\bf File =} referred to in the second part of the message, Bacula will 
434    not descend into the directory mentioned in the first part of the message.
435    However, it is possible that the separate filesystem will be backed up 
436    despite the message. For example, consider the following FileSet:
437
438 \footnotesize
439 \begin{verbatim}
440   File = /
441   File = /var
442 \end{verbatim}
443 \normalsize
444
445    where {\bf /var} is a separate filesystem.  In this example, you will get a
446    message saying that Bacula will not decend from {\bf /} into {\bf /var}.  But 
447    it is important to realise that Bacula will descend into {\bf /var} from the 
448    second File directive shown above.  In effect, the warning is bogus,
449    but it is supplied to alert you to possible omissions from your FileSet. In 
450    this example, {\bf /var} will be backed up.  If you changed the FileSet such 
451    that it did not specify {\bf /var}, then {\bf /var} will not be backed up.
452
453    
454 \item [honor nodump flag=\lt{}yes\vb{}no\gt{}]
455 \index[dir]{honornodumpflag}
456 \index[dir]{Directive!honornodumpflag}
457         If your file system supports the {\bf nodump} flag (e. g. most
458         BSD-derived systems) Bacula will honor the setting of the flag
459         when this option is set to {\bf yes}. Files having this flag set
460         will not be included in the backup and will not show up in the
461         catalog. For directories with the {\bf nodump} flag set recursion
462         is turned off and the directory will be listed in the catalog.
463         If the {\bf honor nodump flag} option is not defined
464         or set to {\bf no} every file and directory will be eligible for
465         backup.
466
467
468 \label{portable}
469 \item [portable=yes\vb{}no]
470 \index[dir]{portable}
471 \index[dir]{Directive!portable}
472    If set to {\bf yes} (default is {\bf no}), the Bacula File daemon will
473    backup Win32 files in a portable format, but not all Win32 file
474    attributes will be saved and restored.  By default, this option is set
475    to {\bf no}, which means that on Win32 systems, the data will be backed
476    up using Windows API calls and on WinNT/2K/XP, all the security and
477    ownership attributes will be properly backed up (and restored).  However
478    this format is not portable to other systems -- e.g.  Unix, Win95/98/Me.
479    When backing up Unix systems, this option is ignored, and unless you
480    have a specific need to have portable backups, we recommend accept the
481    default ({\bf no}) so that the maximum information concerning your files
482    is saved.
483
484 \item [recurse=yes\vb{}no]
485 \index[dir]{recurse}
486 \index[dir]{Directive!recurse}
487    If set to {\bf yes} (the default), Bacula will recurse (or descend) into
488    all subdirectories found unless the directory is explicitly excluded
489    using an {\bf exclude} definition.  If you set {\bf recurse=no}, Bacula
490    will save the subdirectory entries, but not descend into the
491    subdirectories, and thus will not save the files or directories
492    contained in the subdirectories.  Normally, you will want the default
493    ({\bf yes}).
494
495 \item [sparse=yes\vb{}no]
496 \index[dir]{sparse}
497 \index[dir]{Directive!sparse}
498    Enable special code that checks for sparse files such as created by
499    ndbm.  The default is {\bf no}, so no checks are made for sparse files.
500    You may specify {\bf sparse=yes} even on files that are not sparse file.
501    No harm will be done, but there will be a small additional overhead to
502    check for buffers of all zero, and a small additional amount of space on
503    the output archive will be used to save the seek address of each
504    non-zero record read.
505
506    {\bf Restrictions:} Bacula reads files in 32K buffers.  If the whole
507    buffer is zero, it will be treated as a sparse block and not written to
508    tape.  However, if any part of the buffer is non-zero, the whole buffer
509    will be written to tape, possibly including some disk sectors (generally
510    4098 bytes) that are all zero.  As a consequence, Bacula's detection of
511    sparse blocks is in 32K increments rather than the system block size.
512    If anyone considers this to be a real problem, please send in a request
513    for change with the reason.
514
515    If you are not familiar with sparse files, an example is say a file
516    where you wrote 512 bytes at address zero, then 512 bytes at address 1
517    million.  The operating system will allocate only two blocks, and the
518    empty space or hole will have nothing allocated.  However, when you read
519    the sparse file and read the addresses where nothing was written, the OS
520    will return all zeros as if the space were allocated, and if you backup
521    such a file, a lot of space will be used to write zeros to the volume.
522    Worse yet, when you restore the file, all the previously empty space
523    will now be allocated using much more disk space.  By turning on the
524    {\bf sparse} option, Bacula will specifically look for empty space in
525    the file, and any empty space will not be written to the Volume, nor
526    will it be restored.  The price to pay for this is that Bacula must
527    search each block it reads before writing it.  On a slow system, this
528    may be important.  If you suspect you have sparse files, you should
529    benchmark the difference or set sparse for only those files that are
530    really sparse.
531
532 \label{readfifo}
533 \item [readfifo=yes\vb{}no]
534 \index[dir]{readfifo}
535 \index[dir]{Directive!readfifo}
536    If enabled, tells the Client to read the data on a backup and write the
537    data on a restore to any FIFO (pipe) that is explicitly mentioned in the
538    FileSet.  In this case, you must have a program already running that
539    writes into the FIFO for a backup or reads from the FIFO on a restore.
540    This can be accomplished with the {\bf RunBeforeJob} directive.  If this
541    is not the case, Bacula will hang indefinitely on reading/writing the
542    FIFO. When this is not enabled (default), the Client simply saves the
543    directory entry for the FIFO.
544
545    Unfortunately, when Bacula runs a RunBeforeJob, it waits until that
546    script terminates, and if the script accesses the FIFO to write   
547    into the it, the Bacula job will block and everything will stall.
548    However, Vladimir Stavrinov as supplied tip that allows this feature   
549    to work correctly.  He simply adds the following to the beginning
550    of the RunBeforeJob script:
551
552 \begin{verbatim}
553    exec > /dev/null
554 \end{verbatim}
555
556 \item [noatime=yes\vb{}no]
557 \index[dir]{noatime}
558 \index[dir]{Directive!noatime}
559    If enabled, and if your Operating System supports the O\_NOATIME file
560    open flag, Bacula will open all files to be backed up with this option.
561    It makes it possible to read a file without updating the inode atime
562    (and also without the inode ctime update which happens if you try to set
563    the atime back to its previous value).  It also prevents a race
564    condition when two programs are reading the same file, but only one does
565    not want to change the atime.  It's most useful for backup programs and
566    file integrity checkers (and bacula can fit on both categories).
567
568    This option is particularly useful for sites where users are sensitive
569    to their MailBox file access time.  It replaces both the {\bf keepatime}
570    option without the inconveniences of that option (see below).
571
572    If your Operating System does not support this option, it will be
573    silently ignored by Bacula.
574
575
576 \item [mtimeonly=yes\vb{}no]
577 \index[dir]{mtimeonly}
578 \index[dir]{Directive!mtimeonly}
579    If enabled, tells the Client that the selection of files during
580    Incremental and Differential backups should based only on the st\_mtime
581    value in the stat() packet.  The default is {\bf no} which means that
582    the selection of files to be backed up will be based on both the
583    st\_mtime and the st\_ctime values.  In general, it is not recommended
584    to use this option.
585
586 \item [keepatime=yes\vb{}no]
587 \index[dir]{keepatime}
588 \index[dir]{Directive!keepatime}
589    The default is {\bf no}.  When enabled, Bacula will reset the st\_atime
590    (access time) field of files that it backs up to their value prior to
591    the backup.  This option is not generally recommended as there are very
592    few programs that use st\_atime, and the backup overhead is increased
593    because of the additional system call necessary to reset the times.
594    However, for some files, such as mailboxes, when Bacula backs up the
595    file, the user will notice that someone (Bacula) has accessed the
596    file. In this, case keepatime can be useful.
597    (I'm not sure this works on Win32).
598
599    Note, if you use this feature, when Bacula resets the access time, the
600    change time (st\_ctime) will automatically be modified by the system,
601    so on the next incremental job, the file will be backed up even if
602    it has not changed. As a consequence, you will probably also want
603    to use {\bf mtimeonly = yes} as well as keepatime (thanks to
604    Rudolf Cejka for this tip).
605
606 \item [checkfilechanges=yes\vb{}no]
607 \index[dir]{checkfilechanges}
608 \index[dir]{Directive!checkfilechanges}
609    On versions 2.0.4 or greater, 
610    if enabled, the Client will checks size, age of each file after 
611    their backup to see if they have changed during backup. If time 
612    or size mismatch, an error will raise.
613
614 \begin{verbatim}
615  zog-fd: Client1.2007-03-31_09.46.21 Error: /tmp/test mtime changed during backup.
616 \end{verbatim}
617
618    In general, it is recommended to use this option.
619
620 \item [hardlinks=yes\vb{}no]
621 \index[dir]{hardlinks}
622 \index[dir]{Directive!hardlinks}
623    When enabled (default), this directive will cause hard links to be 
624    backed up. However, the File daemon keeps track of hard linked files and
625    will backup the data only once. The process of keeping track of the 
626    hard links can be quite expensive if you have lots of them (tens of
627    thousands or more). This doesn't occur on normal Unix systems, but if
628    you use a program like BackupPC, it can create hundreds of thousands, or
629    even millions of hard links. Backups become very long and the File daemon
630    will consume a lot of CPU power checking hard links.  In such a case,
631    set {\bf hardlinks=no} and hard links will not be backed up.  Note, using
632    this option will most likely backup more data and on a restore the file
633    system will not be restored identically to the original.
634
635 \item [wild=\lt{}string\gt{}]
636 \index[dir]{wild}
637 \index[dir]{Directive!wild}
638    Specifies a wild-card string to be applied to the filenames and
639    directory names.  Note, if {\bf Exclude} is not enabled, the wild-card
640    will select which files are to be included.  If {\bf Exclude=yes} is
641    specified, the wild-card will select which files are to be excluded.
642    Multiple wild-card directives may be specified, and they will be applied
643    in turn until the first one that matches.  Note, if you exclude a
644    directory, no files or directories below it will be matched.
645
646    You may want to test your expressions prior to running your
647    backup by using the bwild program. Please see the
648    \ilink{Utilities}{bwild} chapter of this manual for
649    more. You can also test your full FileSet definition by using
650    the \ilink{estimate}{estimate} command in the Console        
651    chapter of this manual.
652    It is recommended to enclose the string in double quotes.
653
654 \item [wilddir=\lt{}string\gt{}]
655 \index[dir]{wilddir}
656 \index[dir]{Directive!wilddir}
657    Specifies a wild-card string to be applied to directory names only.  No
658    filenames will be matched by this directive.  Note, if {\bf Exclude} is
659    not enabled, the wild-card will select directories to be
660    included.  If {\bf Exclude=yes} is specified, the wild-card will select
661    which directories are to be excluded.  Multiple wild-card directives may be
662    specified, and they will be applied in turn until the first one that
663    matches.  Note, if you exclude a directory, no files or directories
664    below it will be matched.
665
666    It is recommended to enclose the string in double quotes.
667
668    You may want to test your expressions prior to running your
669    backup by using the bwild program. Please see the
670    \ilink{Utilities}{bwild} chapter of this manual for
671    more. You can also test your full FileSet definition by using
672    the \ilink{estimate}{estimate} command in the Console        
673    chapter of this manual.
674    An example of excluding with the WildDir option on Win32 machines is    
675    presented below.
676
677 \item [wildfile=\lt{}string\gt{}]
678 \index[dir]{wildfile}
679 \index[dir]{Directive!wildfile}
680    Specifies a wild-card string to be applied to non-directories. That
681    is no directory entries will be matched by this directive.
682    However, note that the match is done against the full path and filename,
683    so your wild-card string must take into account that filenames
684    are preceded by the full path.
685    If {\bf Exclude}
686    is not enabled, the wild-card will select which files are to be
687    included.  If {\bf Exclude=yes} is specified, the wild-card will select
688    which files are to be excluded.  Multiple wild-card directives may be
689    specified, and they will be applied in turn until the first one that
690    matches.
691
692    It is recommended to enclose the string in double quotes.
693
694    You may want to test your expressions prior to running your
695    backup by using the bwild program. Please see the
696    \ilink{Utilities}{bwild} chapter of this manual for
697    more. You can also test your full FileSet definition by using
698    the \ilink{estimate}{estimate} command in the Console        
699    chapter of this manual.
700    An example of excluding with the WildFile option on Win32 machines is    
701    presented below.
702
703
704 \item [regex=\lt{}string\gt{}]
705 \index[dir]{regex}
706 \index[dir]{Directive!regex}
707    Specifies a POSIX extended regular expression to be applied to the
708    filenames and directory names, which include the full path.  If {\bf
709    Exclude} is not enabled, the regex will select which files are to be
710    included.  If {\bf Exclude=yes} is specified, the regex will select
711    which files are to be excluded.  Multiple regex directives may be
712    specified within an Options resource, and they will be applied in turn
713    until the first one that matches.  Note, if you exclude a directory, no
714    files or directories below it will be matched.
715
716    It is recommended to enclose the string in double quotes.
717
718    The regex libraries differ from one operating system to
719    another, and in addition, regular expressions are complicated,
720    so you may want to test your expressions prior to running your
721    backup by using the bregex program. Please see the
722    \ilink{Utilities}{bwild} chapter of this manual for
723    more. You can also test your full FileSet definition by using
724    the \ilink{estimate}{estimate} command in the Console        
725    chapter of this manual.
726
727    You find yourself using a lot of Regex statements, which will cost quite a lot
728    of CPU time, we recommend you simplify them if you can, or better yet
729    convert them to Wild statements which are much more efficient.
730
731
732 \item [regexfile=\lt{}string\gt{}]
733 \index[dir]{regexfile}
734 \index[dir]{Directive!regexfile}
735    Specifies a POSIX extended regular expression to be applied to
736    non-directories. No directories will be matched by this directive.  
737    However, note that the match is done against the full path and
738    filename, so your regex string must take into account that filenames
739    are preceded by the full path.
740    If {\bf Exclude} is not enabled, the regex will select which files are
741    to be included.  If {\bf Exclude=yes} is specified, the regex will
742    select which files are to be excluded.  Multiple regex directives may be
743    specified, and they will be applied in turn until the first one that
744    matches.
745
746    It is recommended to enclose the string in double quotes.
747
748    The regex libraries differ from one operating system to
749    another, and in addition, regular expressions are complicated,
750    so you may want to test your expressions prior to running your
751    backup by using the bregex program. Please see the
752    \ilink{Utilities}{bregex} chapter of this manual for
753    more.
754
755
756 \item [regexdir=\lt{}string\gt{}]
757 \index[dir]{regexdir}
758 \index[dir]{Directive!regexdir}
759    Specifies a POSIX extended regular expression to be applied to directory
760    names only.  No filenames will be matched by this directive.  Note, if
761    {\bf Exclude} is not enabled, the regex will select directories
762    files are to be included.  If {\bf Exclude=yes} is specified, the
763    regex will select which files are to be excluded.  Multiple
764    regex directives may be specified, and they will be applied in turn
765    until the first one that matches.  Note, if you exclude a directory, no
766    files or directories below it will be matched.
767
768    It is recommended to enclose the string in double quotes.
769
770    The regex libraries differ from one operating system to
771    another, and in addition, regular expressions are complicated,
772    so you may want to test your expressions prior to running your
773    backup by using the bregex program. Please see the
774    \ilink{Utilities}{bregex} chapter of this manual for
775    more.
776
777
778 \item [exclude=yes\vb{}no]
779 \index[dir]{exclude}
780 \index[dir]{Directive!exclude}
781    The default is {\bf no}.  When enabled, any files matched within the
782    Options will be excluded from the backup.
783
784 \label{ACLSupport}
785 \item [aclsupport=yes\vb{}no]
786 \index[dir]{aclsupport}
787 \index[dir]{Directive!aclsupport}
788    The default is {\bf no}.  If this option is set to yes, and you have the
789    POSIX {\bf libacl} installed on your system, Bacula will backup the file
790    and directory UNIX Access Control Lists (ACL) as defined in IEEE Std
791    1003.1e draft 17 and "POSIX.1e" (abandoned).  This feature is
792    available on UNIX only and depends on the ACL library.  Bacula is
793    automatically compiled with ACL support if the {\bf libacl} library is
794    installed on your system (shown in config.out).  While restoring the
795    files Bacula will try to restore the ACLs, if there is no ACL support
796    available on the system, Bacula restores the files and directories but
797    not the ACL information.  Please note, if you backup an EXT3 or XFS
798    filesystem with ACLs, then you restore them to a different filesystem
799    (perhaps reiserfs) that does not have ACLs, the ACLs will be ignored.
800
801 \item [ignore case=yes\vb{}no]
802 \index[dir]{ignore case}
803 \index[dir]{Directive!ignore case}
804    The default is {\bf no}.  On Windows systems, you will almost surely
805    want to set this to {\bf yes}.  When this directive is set to {\bf yes}
806    all the case of character will be ignored in wild-card and regex
807    comparisons.  That is an uppercase A will match a lowercase a.
808
809 \item [fstype=filesystem-type]
810 \index[dir]{fstype}
811 \index[dir]{Directive!fstype}
812    This option allows you to select files and directories by the
813    filesystem type.  The permitted filesystem-type names are:
814
815    ext2, jfs, ntfs, proc, reiserfs, xfs, usbdevfs, sysfs, smbfs,
816    iso9660.  For ext3 systems, use ext2.
817
818    You may have multiple Fstype directives, and thus permit matching
819    of multiple filesystem types within a single Options resource.  If
820    the type specified on the fstype directive does not match the
821    filesystem for a particular directive, that directory will not be
822    backed up.  This directive can be used to prevent backing up
823    non-local filesystems. Normally, when you use this directive, you
824    would also set {\bf onefs=no} so that Bacula will traverse filesystems.
825
826    This option is not implemented in Win32 systems.
827
828 \item [DriveType=Windows-drive-type]
829 \index[dir]{DriveType}
830 \index[dir]{Directive!DriveType}
831    This option is effective only on Windows machines and is
832    somewhat similar to the Unix/Linux {\bf fstype} described
833    above, except that it allows you to select what Windows
834    drive types you want to allow.  By default all drive
835    types are accepted.
836
837    The permitted drivetype names are:
838
839    removable, fixed, remote, cdrom, ramdisk
840
841    You may have multiple Driveype directives, and thus permit matching
842    of multiple drive types within a single Options resource.  If
843    the type specified on the drivetype directive does not match the
844    filesystem for a particular directive, that directory will not be
845    backed up.  This directive can be used to prevent backing up
846    non-local filesystems. Normally, when you use this directive, you
847    would also set {\bf onefs=no} so that Bacula will traverse filesystems.
848
849    This option is not implemented in Unix/Linux systems.
850
851
852 \item [hfsplussupport=yes\vb{}no]
853 \index[dir]{hfsplussupport}
854 \index[dir]{Directive!hfsplussupport}
855    This option allows you to turn on support for Mac OSX HFS plus 
856    finder information.
857
858 \item [strippath=\lt{}integer\gt{}]
859 \index[dir]{strippath}
860 \index[dir]{Directive!strippath}
861    This option will cause {\bf integer} paths to be stripped from
862    the front of the full path/filename being backed up. This can
863    be useful if you are migrating data from another vendor or if
864    you have taken a snapshot into some subdirectory.  This directive
865    can cause your filenames to be overlayed with regular backup data,
866    so should be used only by experts and with great care.
867 \end{description}
868
869 {\bf \lt{}file-list\gt{}} is a list of directory and/or filename names
870 specified with a {\bf File =} directive. To include names containing spaces,
871 enclose the name between double-quotes. Wild-cards are not interpreted
872 in file-lists. They can only be specified in Options resources.
873
874 There are a number of special cases when specifying directories and files in a
875 {\bf file-list}. They are: 
876
877 \begin{itemize}
878 \item Any name preceded by an at-sign (@) is assumed to be the  name of a
879    file, which contains a list of files each preceded by a "File =".  The
880    named file is read once when the configuration file is parsed during the
881    Director startup.  Note, that the file is read on the Director's machine
882    and not on the Client's.  In fact, the @filename can appear anywhere
883    within the conf file where a token would be read, and the contents of
884    the named file will be logically inserted in the place of the @filename.
885    What must be in the file depends on the location the @filename is
886    specified in the conf file.  For example:
887
888 \footnotesize
889 \begin{verbatim}
890 Include {
891   Options { compression=GZIP }
892   @/home/files/my-files
893 }
894 \end{verbatim}
895 \normalsize
896
897 \item Any name beginning with a vertical bar (\vb) is  assumed to be the name of
898    a program.  This program will be executed on the Director's machine at
899    the time the Job starts (not when the Director reads the configuration
900    file), and any output from that program will be assumed to be a list of
901    files or directories, one per line, to be included. Before submitting the 
902    specified command bacula will performe 
903    \ilink{character substitution}{character substitution}.
904
905    This allows you to have a job that, for example, includes all the local
906    partitions even if you change the partitioning by adding a disk.  The
907    examples below show you how to do this.  However, please note two
908    things: \\
909    1.  if you want the local filesystems, you probably should be
910    using the new {\bf fstype} directive, which was added in version 1.36.3 
911    and set {\bf onefs=no}.
912    \\
913
914    2.  the exact syntax of the command needed in the examples below is very
915    system dependent.  For example, on recent Linux systems, you may need to
916    add the -P option, on FreeBSD systems, the options will be different as
917    well.
918
919    In general, you will need to prefix your command or commands with a {\bf
920    sh -c} so that they are invoked by a shell.  This will not be the case
921    if you are invoking a script as in the second example below.  Also, you
922    must take care to escape (precede with a \textbackslash{}) wild-cards,
923    shell character, and to ensure that any spaces in your command are
924    escaped as well.  If you use a single quotes (') within a double quote
925    ("), Bacula will treat everything between the single quotes as one field
926    so it will not be necessary to escape the spaces.  In general, getting
927    all the quotes and escapes correct is a real pain as you can see by the
928    next example.  As a consequence, it is often easier to put everything in
929    a file and simply use the file name within Bacula.  In that case the
930    {\bf sh -c} will not be necessary providing the first line of the file
931    is {\bf \#!/bin/sh}.
932
933    As an  example: 
934
935 \footnotesize
936 \begin{verbatim}
937  
938 Include {
939    Options { signature = SHA1 }
940    File = "|sh -c 'df -l | grep \"^/dev/hd[ab]\" | grep -v \".*/tmp\" \
941       | awk \"{print \\$6}\"'"
942 }
943 \end{verbatim}
944 \normalsize
945
946    will produce a list of all the local partitions on a Red Hat Linux system.
947    Note, the above line was split, but should normally  be written on one line. 
948    Quoting is a real problem because you must quote for Bacula  which consists of
949    preceding every \textbackslash{} and every " with a \textbackslash{}, and 
950    you must also quote for the shell command. In the end, it is probably  easier
951    just to execute a small file with: 
952
953
954 \footnotesize
955 \begin{verbatim}
956 Include {
957   Options {
958     signature=MD5
959   }
960   File = "|my_partitions"
961 }
962 \end{verbatim}
963 \normalsize
964
965    where my\_partitions has: 
966
967 \footnotesize
968 \begin{verbatim}
969 #!/bin/sh
970 df -l | grep "^/dev/hd[ab]" | grep -v ".*/tmp" \
971       | awk "{print \$6}"
972 \end{verbatim}
973 \normalsize
974
975    If the vertical bar (|) in front of my\_partitions is preceded by a
976    backslash as in \textbackslash{}|, the program will be executed on the
977    Client's machine instead of on the Director's machine.
978    Please note that if the filename is given within quotes, you
979    will need to use two slashes.  An example, provided by John Donagher,
980    that backs up all the local UFS partitions on a remote system is:
981
982 \footnotesize
983 \begin{verbatim}
984 FileSet {
985   Name = "All local partitions"
986   Include {
987     Options { signature=SHA1; onefs=yes; }
988     File = "\\|bash -c \"df -klF ufs | tail +2 | awk '{print \$6}'\""
989   }
990 }
991 \end{verbatim}
992 \normalsize
993
994    The above requires two backslash characters after the double quote (one
995    preserves  the next one). If you are a Linux user, just change the {\bf ufs}
996    to  {\bf ext3} (or your preferred filesystem type), and you will be in 
997    business.  
998
999    If you know what filesystems you have mounted on your system, e.g. 
1000    for Red Hat Linux normally only ext2 and ext3, you can backup
1001    all local filesystems using something like:
1002
1003 \footnotesize
1004 \begin{verbatim}
1005  
1006 Include {
1007    Options { signature = SHA1; onfs=no; fstype=ext2 }
1008    File = /
1009 }
1010 \end{verbatim}
1011 \normalsize
1012
1013
1014 \item Any file-list item preceded by a less-than sign (\lt{})  will be taken
1015    to be a file. This file will be read on the Director's machine (see
1016    below for doing it on the Client machine) at the time
1017    the Job starts, and the  data will be assumed to be a list of directories or
1018    files,  one per line, to be included. The names should start in  column 1 and
1019    should not be quoted even if they contain  spaces. This feature allows you to
1020    modify the external  file and change what will be saved without stopping and 
1021    restarting Bacula as would be necessary if using the @  modifier noted above.
1022    For example: 
1023
1024 \footnotesize
1025 \begin{verbatim}
1026 Include {
1027   Options { signature = SHA1 }
1028   File = "</home/files/local-filelist"
1029 }
1030 \end{verbatim}
1031 \normalsize
1032
1033    If you precede the less-than sign (\lt{}) with a backslash as in
1034    \textbackslash{}\lt{}, the file-list will be read on the Client machine
1035    instead of on the Director's machine.  Please note that if the filename
1036    is given within quotes, you will need to use two slashes.
1037
1038 \footnotesize
1039 \begin{verbatim}
1040 Include {
1041   Options { signature = SHA1 }
1042   File = "\\</home/xxx/filelist-on-client"
1043 }
1044 \end{verbatim}
1045 \normalsize
1046
1047 \item If you explicitly specify a block device such as {\bf /dev/hda1},  then
1048    Bacula (starting with version 1.28) will assume that this  is a raw partition
1049    to be backed up. In this case, you are strongly  urged to specify a {\bf
1050    sparse=yes} include option, otherwise, you  will save the whole partition
1051    rather than just the actual data that  the partition contains. For example: 
1052
1053 \footnotesize
1054 \begin{verbatim}
1055 Include {
1056   Options { signature=MD5; sparse=yes }
1057   File = /dev/hd6
1058 }
1059 \end{verbatim}
1060 \normalsize
1061
1062    will backup the data in device /dev/hd6. Note, the {bf /dev/hd6} must be
1063    the raw partition itself. Bacula will not back it up as a raw device if
1064    you specify a symbolic link to a raw device such as my be created by the
1065    LVM Snapshot utilities.
1066
1067    Ludovic Strappazon has pointed out that this feature can be  used to backup a
1068    full Microsoft Windows disk. Simply boot into  the system using a Linux Rescue
1069    disk, then load a statically  linked Bacula as described in the 
1070    \ilink{ Disaster Recovery Using Bacula}{RescueChapter} chapter of
1071    this manual. Then  save the whole disk partition. In the case of a disaster,
1072    you  can then restore the desired partition by again booting with  the rescue
1073    disk and doing a restore of the partition. 
1074    \item If you explicitly specify a FIFO device name (created with mkfifo),  and
1075    you add the option {\bf readfifo=yes} as an option, Bacula  will read the FIFO
1076    and back its data up to the Volume. For  example: 
1077
1078 \footnotesize
1079 \begin{verbatim}
1080 Include {
1081   Options {
1082     signature=SHA1
1083     readfifo=yes
1084   }
1085   File = /home/abc/fifo
1086 }
1087 \end{verbatim}
1088 \normalsize
1089
1090    if {\bf /home/abc/fifo} is a fifo device, Bacula will open the fifo,
1091    read it, and store all data thus obtained on the Volume.  Please note,
1092    you must have a process on the system that is writing into the fifo, or
1093    Bacula will hang, and after one minute of waiting, Bacula will give up
1094    and go on to the next file.  The data read can be anything since Bacula
1095    treats it as a stream.
1096
1097    This feature can be an excellent way to do a "hot" backup of a very
1098    large database.  You can use the {\bf RunBeforeJob} to create the fifo
1099    and to start a program that dynamically reads your database and writes
1100    it to the fifo.  Bacula will then write it to the Volume.  Be sure to
1101    read the \ilink{readfifo section}{readfifo} that gives a
1102    tip to ensure that the RunBeforeJob does not block Bacula.
1103
1104    During the restore operation, the inverse is true, after Bacula creates
1105    the fifo if there was any data stored with it (no need to explicitly
1106    list it or add any options), that data will be written back to the fifo.
1107    As a consequence, if any such FIFOs exist in the fileset to be restored,
1108    you must ensure that there is a reader program or Bacula will block, and
1109    after one minute, Bacula will time out the write to the fifo and move on
1110    to the next file.
1111
1112 \item A file-list may not contain wild-cards. Use directives in the
1113    Options resource if you wish to specify wild-cards or regular expression
1114    matching.
1115
1116 \item
1117 \index[general]{IgnoreDir}
1118 The {\bf ExcludeDirContaining = \lt{}filename\gt{}} is a directive that
1119 can be added to the Include section of the FileSet resource.  If the specified
1120 filename ({\bf filename-string}) is found on the Client in any directory to be
1121 backed up, the whole directory will be ignored (not backed up).  For example:
1122
1123 \begin{verbatim}
1124   # List of files to be backed up
1125   FileSet {
1126     Name = "MyFileSet"
1127     Include {
1128       Options {
1129         signature = MD5
1130       }
1131       File = /home
1132       Exclude Dir Containing = .excludeme
1133     }
1134   }
1135 \end{verbatim}
1136
1137 But in /home, there may be hundreds of directories of users and some
1138 people want to indicate that they don't want to have certain
1139 directories backed up. For example, with the above FileSet, if
1140 the user or sysadmin creates a file named {\bf .excludeme} in 
1141 specific directories, such as
1142
1143 \begin{verbatim}
1144    /home/user/www/cache/.excludeme
1145    /home/user/temp/.excludeme
1146 \end{verbatim}
1147
1148 then Bacula will not backup the two directories named:
1149
1150 \begin{verbatim}
1151    /home/user/www/cache
1152    /home/user/temp
1153 \end{verbatim}
1154
1155 NOTE: subdirectories will not be backed up.  That is, the directive
1156 applies to the two directories in question and any children (be they
1157 files, directories, etc).
1158
1159 \end{itemize}
1160
1161 \section{FileSet Examples}
1162 \index[general]{Examples!FileSet }
1163 \index[general]{FileSet Examples}
1164
1165 The following is an example of a valid FileSet resource definition.  Note,
1166 the first Include pulls in the contents of the file {\bf /etc/backup.list}
1167 when Bacula is started (i.e.  the @), and that file must have each filename
1168 to be backed up preceded by a {\bf File =} and on a separate line.
1169
1170 \footnotesize
1171 \begin{verbatim}
1172 FileSet {
1173   Name = "Full Set"
1174   Include {
1175     Options {
1176       Compression=GZIP
1177       signature=SHA1
1178       Sparse = yes
1179     }
1180     @/etc/backup.list
1181   }
1182   Include {
1183      Options {
1184         wildfile = "*.o"
1185         wildfile = "*.exe"
1186         Exclude = yes
1187      }
1188      File = /root/myfile
1189      File = /usr/lib/another_file
1190   }
1191 }
1192 \end{verbatim}
1193 \normalsize
1194
1195 In the above example, all the files contained in /etc/backup.list will
1196 be compressed with GZIP compression, an SHA1 signature will be computed on the
1197 file's contents (its data), and sparse file handling will apply. 
1198
1199 The two directories /root/myfile and /usr/lib/another\_file will also be saved
1200 without any options, but all files in those directories with the extensions
1201 {\bf .o} and {\bf .exe} will be excluded. 
1202
1203 Let's say that you now want to exclude the directory /tmp. The simplest way
1204 to do so is to add an exclude directive that lists /tmp.  The example
1205 above would then become:
1206
1207 \footnotesize 
1208 \begin{verbatim}
1209 FileSet {
1210   Name = "Full Set"
1211   Include {
1212     Options {
1213       Compression=GZIP
1214       signature=SHA1
1215       Sparse = yes
1216     }
1217     @/etc/backup.list
1218   }
1219   Include {
1220      Options {
1221         wildfile = "*.o"
1222         wildfile = "*.exe"
1223         Exclude = yes
1224      }
1225      File = /root/myfile
1226      File = /usr/lib/another_file
1227   }
1228   Exclude {
1229      File = /tmp
1230   }
1231 }
1232 \end{verbatim}
1233 \normalsize
1234
1235
1236 You can add wild-cards to the File directives listed in the Exclude
1237 directory, but you need to take care because if you exclude a directory,
1238 it and all files and directories below it will also be excluded.
1239
1240 Now lets take a slight variation on the above and suppose
1241 you want to save all your whole filesystem except {\bf /tmp}. 
1242 The problem that comes up is that Bacula will not normally
1243 cross from one filesystem to another.
1244 Doing a {\bf df} command, you get the following output: 
1245
1246 \footnotesize
1247 \begin{verbatim}
1248 [kern@rufus k]$ df
1249 Filesystem      1k-blocks      Used Available Use% Mounted on
1250 /dev/hda5         5044156    439232   4348692  10% /
1251 /dev/hda1           62193      4935     54047   9% /boot
1252 /dev/hda9        20161172   5524660  13612372  29% /home
1253 /dev/hda2           62217      6843     52161  12% /rescue
1254 /dev/hda8         5044156     42548   4745376   1% /tmp
1255 /dev/hda6         5044156   2613132   2174792  55% /usr
1256 none               127708         0    127708   0% /dev/shm
1257 //minimatou/c$   14099200   9895424   4203776  71% /mnt/mmatou
1258 lmatou:/          1554264    215884   1258056  15% /mnt/matou
1259 lmatou:/home      2478140   1589952    760072  68% /mnt/matou/home
1260 lmatou:/usr       1981000   1199960    678628  64% /mnt/matou/usr
1261 lpmatou:/          995116    484112    459596  52% /mnt/pmatou
1262 lpmatou:/home    19222656   2787880  15458228  16% /mnt/pmatou/home
1263 lpmatou:/usr      2478140   2038764    311260  87% /mnt/pmatou/usr
1264 deuter:/          4806936     97684   4465064   3% /mnt/deuter
1265 deuter:/home      4806904    280100   4282620   7% /mnt/deuter/home
1266 deuter:/files    44133352  27652876  14238608  67% /mnt/deuter/files
1267 \end{verbatim}
1268 \normalsize
1269
1270 And we see that there are a number of separate filesystems (/ /boot
1271 /home /rescue /tmp and /usr not to mention mounted systems).
1272 If you specify only {\bf /} in your Include list, Bacula will only save the
1273 Filesystem {\bf /dev/hda5}. To save all filesystems except {\bf /tmp} with
1274 out including any of the Samba or NFS mounted systems, and explicitly
1275 excluding a /tmp, /proc, .journal, and .autofsck, which you will not want to
1276 be saved and restored, you can use the following: 
1277
1278 \footnotesize
1279 \begin{verbatim}
1280 FileSet {
1281   Name = Include_example
1282   Include {
1283     Options {
1284        wilddir = /proc
1285        wilddir = /tmp
1286        wildfile = "/.journal"
1287        wildfile = "/.autofsck"
1288        exclude = yes
1289     }
1290     File = /
1291     File = /boot
1292     File = /home
1293     File = /rescue
1294     File = /usr
1295   }
1296 }
1297 \end{verbatim}
1298 \normalsize
1299
1300 Since /tmp is on its own filesystem and it was not explicitly named in the
1301 Include list, it is not really needed in the exclude list. It is better to
1302 list it in the Exclude list for clarity, and in case the disks are changed so
1303 that it is no longer in its own partition. 
1304
1305 Now, lets assume you only want to backup .Z and .gz files and nothing 
1306 else. This is a bit trickier because Bacula by default will select 
1307 everything to backup, so we must exclude everything but .Z and .gz files.
1308 If we take the first example above and make the obvious modifications
1309 to it, we might come up with a FileSet that looks like this:
1310
1311 \footnotesize 
1312 \begin{verbatim}
1313 FileSet {
1314   Name = "Full Set"
1315   Include {                    !!!!!!!!!!!!
1316      Options {                    This
1317         wildfile = "*.Z"          example
1318         wildfile = "*.gz"         doesn't
1319                                   work
1320      }                          !!!!!!!!!!!!
1321      File = /myfile
1322   }
1323 }
1324 \end{verbatim}
1325 \normalsize
1326
1327 The *.Z and *.gz files will indeed be backed up, but all other files
1328 that are not matched by the Options directives will automatically
1329 be backed up too (i.e. that is the default rule).
1330
1331 To accomplish what we want, we must explicitly exclude all other files.
1332 We do this with the following:
1333
1334 \footnotesize
1335 \begin{verbatim}
1336 FileSet {
1337   Name = "Full Set"
1338   Include {
1339      Options {
1340         wildfile = "*.Z"
1341         wildfile = "*.gz"
1342      }
1343      Options {
1344         Exclude = yes
1345         RegexFile = ".*"
1346      }
1347      File = /myfile
1348   }
1349 }
1350 \end{verbatim}
1351 \normalsize
1352
1353 The "trick" here was to add a RegexFile expression that matches
1354 all files. It does not match directory names, so all directories in
1355 /myfile will be backed up (the directory entry) and any *.Z and *.gz
1356 files contained in them. If you know that certain directories do
1357 not contain any *.Z or *.gz files and you do not want the directory
1358 entries backed up, you will need to explicitly exclude those directories.
1359 Backing up a directory entries is not very expensive.
1360
1361 Bacula uses the system regex library and some of them are
1362 different on different OSes. The above has been reported not to work
1363 on FreeBSD. This can be tested by using the {\bf estimate job=job-name
1364 listing} command in the console and adapting the RegexFile expression
1365 appropriately. In a future version of Bacula, we will supply our own
1366 Regex code to avoid such system dependencies.
1367
1368 Please be aware that allowing Bacula to traverse or change file systems can be
1369 {\bf very} dangerous. For example, with the following: 
1370
1371 \footnotesize
1372 \begin{verbatim}
1373 FileSet {
1374   Name = "Bad example"
1375   Include {
1376     Options { onefs=no }
1377     File = /mnt/matou
1378   }
1379 }
1380 \end{verbatim}
1381 \normalsize
1382
1383 you will be backing up an NFS mounted partition ({\bf /mnt/matou}), and since
1384 {\bf onefs} is set to {\bf no}, Bacula will traverse file systems. Now if {\bf
1385 /mnt/matou} has the current machine's file systems mounted, as is often the
1386 case, you will get yourself into a recursive loop and the backup will never
1387 end. 
1388
1389 As a final example, let's say that you have only one or two 
1390 subdirectories of /home that you want to backup.  For example,
1391 you want to backup only subdirectories beginning with the letter
1392 a and the letter b -- i.e. /home/a* and /home/b*.  Now, you might first
1393 try:
1394 \footnotesize
1395 \begin{verbatim}
1396 FileSet {
1397   Name = "Full Set"
1398   Include {
1399      Options {
1400         wilddir = "/home/a*"
1401         wilddir = "/home/b*"
1402      }
1403      File = /home
1404   }
1405 }
1406 \end{verbatim}
1407 \normalsize
1408
1409 The problem is that the above will include everything in /home.  To get
1410 things to work correctly, you need to start with the idea of exclusion
1411 instead of inclusion.  So, you could simply exclude all directories
1412 except the two you want to use:
1413 \footnotesize
1414 \begin{verbatim}
1415 FileSet {
1416   Name = "Full Set"
1417   Include {
1418      Options {
1419         RegexDir = "^/home/[c-z]"
1420         exclude = yes
1421      }
1422      File = /home
1423   }
1424 }
1425 \end{verbatim}
1426 \normalsize
1427
1428 And assuming that all subdirectories start with a lowercase letter, this
1429 would work.
1430
1431 An alternative would be to include the two subdirectories desired and
1432 exclude everything else:
1433 \footnotesize
1434 \begin{verbatim}
1435 FileSet {
1436   Name = "Full Set"
1437   Include {
1438      Options {
1439         wilddir = "/home/a*"
1440         wilddir = "/home/b*"
1441      }
1442      Options {
1443         RegexDir = ".*"
1444         exclude = yes
1445      }
1446      File = /home
1447   }
1448 }
1449 \end{verbatim}
1450 \normalsize
1451
1452
1453 The following example shows how to back up only the My Pictures directory inside
1454 the My Documents directory for all users in C:/Documents and Settings, i.e.
1455 everything matching the pattern:
1456
1457 C:/Documents and Settings/*/My Documents/My Pictures/*
1458
1459 To understand how this can be achieved, there are two important points to
1460 remember:
1461
1462 Firstly, Bacula walks over the filesystem depth-first starting from the File =
1463 lines.  It stops descending when a directory is excluded, so you must include
1464 all ancestor directories of each directory containing files to be included.
1465
1466 Secondly, each directory and file is compared to the Options clauses in the
1467 order they appear in the FileSet.  When a match is found, no further clauses
1468 are compared and the directory or file is either included or excluded.
1469
1470 The FileSet resource definition below implements this by including specifc
1471 directories and files and excluding everything else.
1472
1473 \footnotesize
1474 \begin{verbatim}
1475 FileSet {
1476   Name = "AllPictures"
1477
1478   Include {
1479
1480     File  = "C:/Documents and Settings"
1481
1482     Options {
1483       signature = SHA1
1484       verify = s1
1485       IgnoreCase = yes
1486
1487       # Include all users' directories so we reach the inner ones.  Unlike a
1488       # WildDir pattern ending in *, this RegExDir only matches the top-level
1489       # directories and not any inner ones.
1490       RegExDir = "^C:/Documents and Settings/[^/]+$"
1491
1492       # Ditto all users' My Documents directories.
1493       WildDir = "C:/Documents and Settings/*/My Documents"
1494
1495       # Ditto all users' My Documents/My Pictures directories.
1496       WildDir = "C:/Documents and Settings/*/My Documents/My Pictures"
1497
1498       # Include the contents of the My Documents/My Pictures directories and
1499       # any subdirectories.
1500       Wild = "C:/Documents and Settings/*/My Documents/My Pictures/*"
1501     }
1502
1503     Options {
1504       Exclude = yes
1505       IgnoreCase = yes
1506
1507       # Exclude everything else, in particular any files at the top level and
1508       # any other directories or files in the users' directories.
1509       Wild = "C:/Documents and Settings/*"
1510     }
1511   }
1512 }
1513 \end{verbatim}
1514 \normalsize
1515
1516 \section{Backing up Raw Partitions}
1517 \index[general]{Backing up!Partitions }
1518 \index[general]{Backing up Raw Partitions }
1519
1520 The following FileSet definition will backup a raw partition: 
1521
1522 \footnotesize
1523 \begin{verbatim}
1524 FileSet {
1525   Name = "RawPartition"
1526   Include {
1527     Options { sparse=yes }
1528     File = /dev/hda2
1529   }
1530 }
1531 \end{verbatim}
1532 \normalsize
1533
1534 While backing up and restoring a raw partition, you should ensure that no
1535 other process including the system is writing to that partition. As a
1536 precaution, you are strongly urged to ensure that the raw partition is not
1537 mounted or is mounted read-only. If necessary, this can be done using the {\bf
1538 RunBeforeJob} directive. 
1539
1540
1541 \section{Excluding Files and Directories}
1542 \index[general]{Directories!Excluding Files and }
1543 \index[general]{Excluding Files and Directories }
1544
1545 You may also include full filenames or directory names in addition to using
1546 wild-cards and {\bf Exclude=yes} in the Options resource as specified above by
1547 simply including the files to be excluded in an Exclude resource within the
1548 FileSet. For example: 
1549
1550 \footnotesize
1551 \begin{verbatim}
1552 FileSet {
1553   Name = Exclusion_example
1554   Include {
1555     Options {
1556       Signature = SHA1
1557     }
1558     File = /
1559     File = /boot
1560     File = /home
1561     File = /rescue
1562     File = /usr
1563   }
1564   Exclude {
1565     File = /proc
1566     File = /tmp
1567     File = .journal
1568     File = .autofsck
1569   }
1570 }
1571 \end{verbatim}
1572 \normalsize
1573
1574 \label{win32}
1575 \section{Windows FileSets}
1576 \index[general]{Windows FileSets }
1577 \index[general]{FileSets!Windows }
1578 If you are entering Windows file names, the directory path may be preceded by
1579 the drive and a colon (as in c:). However, the path separators must be
1580 specified in Unix convention (i.e. forward slash (/)). If you wish to include
1581 a quote in a file name, precede the quote with a backslash
1582 (\textbackslash{}). For example you might use the following
1583 for a Windows machine to backup the "My Documents" directory: 
1584
1585 \footnotesize
1586 \begin{verbatim}
1587 FileSet {
1588   Name = "Windows Set"
1589   Include {
1590     Options {
1591        WildFile = "*.obj"
1592        WildFile = "*.exe"
1593        exclude = yes
1594      }
1595      File = "c:/My Documents"
1596   }
1597 }
1598 \end{verbatim}
1599 \normalsize
1600
1601 For exclude lists to work correctly on Windows, you must observe the following
1602 rules: 
1603
1604 \begin{itemize}
1605 \item Filenames are case sensitive, so you must use the correct case.  
1606 \item To exclude a directory, you must not have a trailing slash on the 
1607    directory name.  
1608 \item If you have spaces in your filename, you must enclose the entire name 
1609    in double-quote characters ("). Trying to use a backslash before  the space
1610    will not work.  
1611 \item If you are using the old Exclude syntax (noted below), you may not
1612    specify a drive letter in the exclude.  The new syntax noted above
1613    should work fine including driver letters.
1614 \end{itemize}
1615
1616 Thanks to Thiago Lima for summarizing the above items for us. If you are
1617 having difficulties getting includes or excludes to work, you might want to
1618 try using the {\bf estimate job=xxx listing} command documented in the 
1619 \ilink{Console chapter}{estimate} of this manual. 
1620
1621 On Win32 systems, if you move a directory or file or rename a file into the
1622 set of files being backed up, and a Full backup has already been made, Bacula
1623 will not know there are new files to be saved during an Incremental or
1624 Differential backup (blame Microsoft, not me). To avoid this problem, please
1625 {\bf copy} any new directory or files into the backup area. If you do not have
1626 enough disk to copy the directory or files, move them, but then initiate a
1627 Full backup. 
1628
1629
1630 \paragraph*{A Windows Example FileSet}
1631 \index[general]{FileSet!Windows Example }
1632 \index[general]{Windows Example FileSet }
1633
1634 The following example was contributed by Russell Howe. Please note that
1635 for presentation purposes, the lines beginning with Data and Internet 
1636 have been wrapped and should included on the previous line with one
1637 space.
1638
1639 \footnotesize
1640 \begin{verbatim}
1641 This is my Windows 2000 fileset:
1642 FileSet {
1643  Name = "Windows 2000"
1644  Include {
1645   Options {
1646    signature = MD5
1647    Exclude = yes
1648    IgnoreCase = yes
1649    # Exclude Mozilla-based programs' file caches
1650    WildDir = "[A-Z]:/Documents and Settings/*/Application 
1651 Data/*/Profiles/*/*/Cache"
1652    WildDir = "[A-Z]:/Documents and Settings/*/Application 
1653 Data/*/Profiles/*/*/Cache.Trash"
1654    WildDir = "[A-Z]:/Documents and Settings/*/Application
1655 Data/*/Profiles/*/*/ImapMail"
1656
1657    # Exclude user's registry files - they're always in use anyway.
1658    WildFile = "[A-Z]:/Documents and Settings/*/Local Settings/Application
1659 Data/Microsoft/Windows/usrclass.*"
1660    WildFile = "[A-Z]:/Documents and Settings/*/ntuser.*"
1661
1662    # Exclude directories full of lots and lots of useless little files
1663    WildDir = "[A-Z]:/Documents and Settings/*/Cookies"
1664    WildDir = "[A-Z]:/Documents and Settings/*/Recent"
1665    WildDir = "[A-Z]:/Documents and Settings/*/Local Settings/History"
1666    WildDir = "[A-Z]:/Documents and Settings/*/Local Settings/Temp"
1667    WildDir = "[A-Z]:/Documents and Settings/*/Local Settings/Temporary
1668 Internet Files"
1669
1670    # These are always open and unable to be backed up
1671    WildFile = "[A-Z]:/Documents and Settings/All Users/Application
1672 Data/Microsoft/Network/Downloader/qmgr[01].dat"
1673
1674    # Some random bits of Windows we want to ignore
1675    WildFile = "[A-Z]:/WINNT/security/logs/scepol.log"
1676    WildDir = "[A-Z]:/WINNT/system32/config"
1677    WildDir = "[A-Z]:/WINNT/msdownld.tmp"
1678    WildDir = "[A-Z]:/WINNT/Internet Logs"
1679    WildDir = "[A-Z]:/WINNT/$Nt*Uninstall*"
1680    WildDir = "[A-Z]:/WINNT/sysvol"
1681    WildFile = "[A-Z]:/WINNT/cluster/CLUSDB"
1682    WildFile = "[A-Z]:/WINNT/cluster/CLUSDB.LOG"
1683    WildFile = "[A-Z]:/WINNT/NTDS/edb.log"
1684    WildFile = "[A-Z]:/WINNT/NTDS/ntds.dit"
1685    WildFile = "[A-Z]:/WINNT/NTDS/temp.edb"
1686    WildFile = "[A-Z]:/WINNT/ntfrs/jet/log/edb.log"
1687    WildFile = "[A-Z]:/WINNT/ntfrs/jet/ntfrs.jdb"
1688    WildFile = "[A-Z]:/WINNT/ntfrs/jet/temp/tmp.edb"
1689    WildFile = "[A-Z]:/WINNT/system32/CPL.CFG"
1690    WildFile = "[A-Z]:/WINNT/system32/dhcp/dhcp.mdb"
1691    WildFile = "[A-Z]:/WINNT/system32/dhcp/j50.log"
1692    WildFile = "[A-Z]:/WINNT/system32/dhcp/tmp.edb"
1693    WildFile = "[A-Z]:/WINNT/system32/LServer/edb.log"
1694    WildFile = "[A-Z]:/WINNT/system32/LServer/TLSLic.edb"
1695    WildFile = "[A-Z]:/WINNT/system32/LServer/tmp.edb"
1696    WildFile = "[A-Z]:/WINNT/system32/wins/j50.log"
1697    WildFile = "[A-Z]:/WINNT/system32/wins/wins.mdb"
1698    WildFile = "[A-Z]:/WINNT/system32/wins/winstmp.mdb"
1699
1700    # Temporary directories & files
1701    WildDir = "[A-Z]:/WINNT/Temp"
1702    WildDir = "[A-Z]:/temp"
1703    WildFile = "*.tmp"
1704    WildDir = "[A-Z]:/tmp"
1705    WildDir = "[A-Z]:/var/tmp"
1706
1707    # Recycle bins
1708    WildDir = "[A-Z]:/RECYCLER"
1709
1710    # Swap files
1711    WildFile = "[A-Z]:/pagefile.sys"
1712
1713    # These are programs and are easier to reinstall than restore from
1714    # backup
1715    WildDir = "[A-Z]:/cygwin"
1716    WildDir = "[A-Z]:/Program Files/Grisoft"
1717    WildDir = "[A-Z]:/Program Files/Java"
1718    WildDir = "[A-Z]:/Program Files/Java Web Start"
1719    WildDir = "[A-Z]:/Program Files/JavaSoft"
1720    WildDir = "[A-Z]:/Program Files/Microsoft Office"
1721    WildDir = "[A-Z]:/Program Files/Mozilla Firefox"
1722    WildDir = "[A-Z]:/Program Files/Mozilla Thunderbird"
1723    WildDir = "[A-Z]:/Program Files/mozilla.org"
1724    WildDir = "[A-Z]:/Program Files/OpenOffice*"
1725   }
1726
1727   # Our Win2k boxen all have C: and D: as the main hard drives.
1728   File = "C:/"
1729   File = "D:/"
1730  }
1731 }
1732 \end{verbatim}
1733 \normalsize
1734
1735 Note, the three line of the above Exclude were split to fit on the document
1736 page, they should be written on a single line in real use. 
1737
1738 \paragraph*{Windows NTFS Naming Considerations}
1739 \index[general]{Windows NTFS Naming Considerations }
1740 \index[general]{Considerations!Windows NTFS Naming }
1741
1742 NTFS filenames containing Unicode characters should now be supported
1743 as of version 1.37.30 or later.
1744
1745 \section{Testing Your FileSet}
1746 \index[general]{FileSet!Testing Your }
1747 \index[general]{Testing Your FileSet }
1748
1749 If you wish to get an idea of what your FileSet will really backup or if your
1750 exclusion rules will work correctly, you can test it by using the {\bf
1751 estimate} command in the Console program. See the 
1752 \ilink{estimate}{estimate} in the Console chapter of this
1753 manual.
1754
1755 As an example, suppose you add the following test FileSet:
1756
1757 \footnotesize
1758 \begin{verbatim}
1759 FileSet {
1760   Name = Test
1761   Include {
1762     File = /home/xxx/test
1763     Options {
1764        regex = ".*\.c$"
1765     }
1766   }
1767 }
1768 \end{verbatim}
1769 \normalsize
1770
1771 You could then add some test files to the directory {\bf /home/xxx/test}
1772 and use the following command in the console:
1773
1774 \footnotesize
1775 \begin{verbatim}
1776 estimate job=<any-job-name> listing client=<desired-client> fileset=Test
1777 \end{verbatim}
1778 \normalsize
1779
1780 to give you a listing of all files that match.