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