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