FileSet Resource

The FileSet resource defines what files are to be included or excluded in a backup job. A FileSet resource is required for each backup Job. It consists of a list of files or directories to be included, a list of files or directories to be excluded and the various backup options such as compression, encryption, and signatures that are to be applied to each file.

Any change to the list of the included files will cause Bacula to automatically create a new FileSet (defined by the name and an MD5 checksum of the Include/Exclude contents). Each time a new FileSet is created, Bacula will ensure that the next backup is always a Full save.

Bacula is designed to handle most character sets of the world, US ASCII, German, French, Chinese, … However, it does this by encoding everything in UTF-8, and it expects all configuration files (including those read on Windows machines) to be in UTF-8 format. UTF-8 is typically the default on Linux machines, but not on all Unix machines, nor on Windows, so you must take some care to ensure that your locale is set properly before starting Bacula. On most modern Operating Systems, you can edit the conf files and choose output encoding UTF-8.

To ensure that Bacula configuration files can be correctly read including foreign characters the LANG environment variable must end in .UTF-8. A full example is en_US.UTF-8. The exact syntax may vary a bit from OS to OS, and exactly how you define it will also vary.

Bacula assumes that all filenames are in UTF-8 format on Linux and Unix machines. On Win32 they are in Unicode (UTF-16), and will be automatically converted to UTF-8 format.

FileSet Start of the FileSet resource. One FileSet resource must be defined for each Backup job.

Name

Name = <name> The name of the FileSet resource. This directive is required.

Ignore Fileset Changes

Ignore FileSet Changes = <yes|no> Normally, if you modify the FileSet Include or Exclude lists, the next backup will be forced to a Full so that Bacula can guarantee that any additions or deletions are properly saved.

We strongly recommend against setting this directive to yes, since doing so may cause you to have an incomplete set of backups.

If this directive is set to yes, any changes you make to the FileSet Include or Exclude lists, will not force a Full during subsequent backups. Note that any changes to Options resources in the FileSet are not considered by this directive. You can use the Accurate mode for this to be treated correctly, or schedule a new Full backup manually.

The default is no, in which case, if you change the Include or Exclude lists, Bacula will force a Full backup to ensure that everything is properly backed up.

Enable VSS

EnableVSS = <yes|no> If this directive is set to yes the File daemon will be notified that the user wants to use a VSS backup for this Job. The default is yes.

This directive is effective only for VSS enabled Win32 File daemons. It permits a consistent copy of open files to be made for cooperating writer applications, and for applications that are not VSS aware, Bacula can at least access open files.

As of Bacula version 10.2, only the VSS snapshot will be used to identify files to back up. In prior versions, files were searched in the “regular” file system and backed up from the snapshot.

In earlier versions of Bacula, a VSS snapshot was only created on Windows drives that were explicitly mentioned in a File List; in many cases, this is no longer necessary.

Enable Snapshot

EnableSnapshot = <yes|no> If this directive is set to yes the File Daemon will be notified that the user wants to use the Snapshot Engine for this job. The default is no. This directive is effective only for Snapshot enabled Unix File Daemons. It permits a consistent copy of open files to be made for cooperating applications. The bsnapshot tool should be installed on the Client.

Include

Include {Options {<file-options>}; <file-list> }

Exclude

Exclude {<file-list>}

The Include resource must contain a list of directories and/or files to be processed in the backup job. Normally, all files found in all subdirectories of any directory in the Include File list will be backed up. Note, see below for the definition of the file-list. The Include resource may also contain one or more Options resources that specify options such as compression to be applied to all or any subset of the files found when processing the file-list for backup. Please see below for more details concerning Options resources.

There can be any number of Include resources within the FileSet, each having its own list of directories or files to be backed up and the backup options defined by one or more Options resources. The file-list consists of one file or directory name per line. Directory names should be specified without a trailing slash with Unix path notation.

Windows users, please take note to specify directories (even c:/…) in Unix path notation. If you use Windows conventions, you will most likely not be able to restore your files due to the fact that the Windows path separator was defined as an escape character long before Windows existed, and Bacula adheres to that convention (i.e. means the next character appears as itself).

You should always specify a full path for every directory and file that you list in the FileSet. In addition, on Windows machines, you should always prefix the directory or filename with the drive specification (e.g. c:/xxx) using Unix directory name separators (forward slash). The drive letter itself can be upper or lower case (e.g. c:/xxx or C:/xxx).

Bacula’s default for processing directories is to recursively descend in the directory saving all files and subdirectories. Bacula will not by default cross filesystems (or mount points in Unix parlance). This means that if you specify the root partition (e.g. /), Bacula will save only the root partition and not any of the other mounted filesystems. Similarly on Windows systems, you must explicitly specify each of the drives you want saved (e.g. c:/ and d:/…). In addition, at least for Windows systems, you will most likely want to enclose each specification within double quotes particularly if the directory (or file) name contains spaces. The df command on Unix systems will show you which mount points you must specify to save everything. See below for an example.

Take special care not to include a directory twice or Bacula will backup the same files two times wasting a lot of space on your archive device. Including a directory twice is very easy to do. For example:

Include {
    Options {compression=GZIP}
    File = /
    File = /usr
    }

on a Unix system where /usr is a subdirectory (rather than a mounted filesystem) will cause /usr to be backed up twice.

Please take note of the following items in the FileSet syntax:

  1. There is no equal sign (=) after the Include and before the opening brace ({). The same is true for the Exclude.

  2. Each directory (or filename) to be included or excluded is preceded by a File =. Previously they were simply listed on separate lines.

  3. The options that previously appeared on the Include line now must be specified within their own Options resource.

  4. The Exclude resource does not accept Options.

  5. When using wild-cards or regular expressions, directory names are always terminated with a slash (/) and filenames have no trailing slash.

The Options resource is optional, but when specified, it will contain a list of keyword=value options to be applied to the file-list. See below for the definition of file-list. Multiple Options resources may be specified one after another. As the files are found in the specified directories, the Options will applied to the filenames to determine if and how the file should be backed up. The wildcard and regular expression pattern matching parts of the Options resources are checked in the order they are specified in the FileSet until the first one that matches. Once one matches, the compression and other flags within the Options specification will apply to the pattern matched.

A key point is that in the absence of an Option or no other Option is matched, every file is accepted for backing up. This means that if you want to exclude something, you must explicitly specify an Option with an exclude = yes and some pattern matching.

Once Bacula determines that the Options resource matches the file under consideration, that file will be saved without looking at any other Options resources that may be present. This means that any wild cards must appear before an Options resource without wild cards.

If for some reason, Bacula checks all the Options resources to a file under consideration for backup, but there are no matches (generally because of wild cards that don’t match), Bacula as a default will then backup the file. This is quite logical if you consider the case of no Options clause is specified, where you want everything to be backed up, and it is important to keep in mind when excluding as mentioned above.

However, one additional point is that in the case that no match was found, Bacula will use the options found in the last Options resource. As a consequence, if you want a particular set of “default” options, you should put them in an Options resource after any other Options.

It is a good idea to put all your wild-card and regex expressions inside double quotes to prevent conf file scanning problems.

This is perhaps a bit overwhelming, so there are a number of examples included below to illustrate how this works.

You find yourself using a lot of Regex statements, which will cost quite a lot of CPU time, we recommend you simplify them if you can, or better yet convert them to Wild statements which are much more efficient.

The directives within an Options resource may be one of the following:

  • compression=GZIP All files saved will be software compressed using the GNU ZIP compression format. The compression is done on a file by file basis by the File Daemon. If there is a problem reading the tape in a single record of a file, it will at most affect that file and none of the other files on the tape. Normally this option is not needed if you have a modern tape drive as the drive will do its own compression. In fact, if you specify software compression at the same time you have hardware compression turned on, your files may actually take more space on the volume.

    Software compression is very important if you are writing your Volumes to a file, and it can also be helpful if you have a fast computer but a slow network, otherwise it is generally better to rely your tape drive’s hardware compression. As noted above, it is not generally a good idea to do both software and hardware compression.

    Specifying ``GZIP`` uses the default compression level 6 (i.e. ``GZIP`` is identical to GZIP6). If you want a different compression level (1 through 9), you can specify it by appending the level number with no intervening spaces to ``GZIP``. Thus compression=GZIP1 would give minimum compression but the fastest algorithm, and compression=``GZIP``9 would give the highest level of compression, but requires more computation. According to the GZIP documentation, compression levels greater than six generally give very little extra compression and are rather CPU intensive.

    You can overwrite this option per Storage resource with Allow Compression option.

  • compression=LZO All files saved will be software compressed using the LZO compression format. The compression is done on a file by file basis by the File Daemon. Everything else about GZIP is true for LZO.

    LZO provides much faster compression and decompression speed but lower compression ratio than GZIP. If your CPU is fast enough you should be able to compress your data without making the backup duration longer.

    Note

    Bacula only use one compression level LZO1X-1 specified by LZO.

    You can overwrite this option per Storage resource with Allow Compression option.

Signature

Signature=SHA1 An SHA1 signature will be computed for all The SHA1 algorithm is purported to be some what slower than the MD5 algorithm, but at the same time is significantly better from a cryptographic point of view (i.e. much fewer collisions, much lower probability of being hacked.) It adds four more bytes than the MD5 signature. We strongly recommend that either this option or MD5 be specified as a default for all files. Note, only one of the two options MD5 or SHA1 can be computed for any file.

Signature=SHA256 A SHA256 signature will be computed for all files saved. Adding this option generates about 5% extra overhead for each file saved. In addition to the additional CPU time, the SHA256 signature adds 44 more bytes per file to your catalog.

Signature=SHA512 A SHA256 signature will be computed for all files saved. Adding this option generates about 5% extra overhead for each file saved. In addition to the additional CPU time, the SHA512 signature adds 87 more bytes per file to your catalog.

Signature=MD5 An MD5 signature will be computed for all files saved. Adding this option generates about 5% extra overhead for each file saved. In addition to the additional CPU time, the MD5 signature adds 16 more bytes per file to your catalog. We strongly recommend that this option or the SHA1 option be specified as a default for all files.

Dedup

Dedup=none||storage|bothsides The Dedup Fileset option can use the following values:

  • storage All the deduplication work is done on Storage Daemon side if the device type is dedup (default value).

  • none Force File Daemon and Storage Daemon to not use deduplication even if the device type is dedup.

  • bothsides The deduplication work is done on the FD and the SD if the device type is dedup.

Basejob

Basejob=<options> The options letters specified are used when running a Backup Level=Full with BaseJobs. The options letters are the same as in the accurate= option below.

Accurate=<options> The options letters specified are used when running a Backup Level=Incremental/Differential in Accurate mode. The options letters are the same as in the verify= option below with the addition of the following options:

  • A Always backup files

  • M Look mtime/ctime like normal incremental backup

  • o Check signature if other options would cause a backup, and if the signature is unchanged, back up only file metadata.

The ’o’ option should be used in conjunction with one of the signature checking options (1, 2, 3, or 5). When the option is specified, the signature is computed only for files that have one of the other accurate options specified triggering a backup of the file (for example an inode change, a permission change, etc…). In cases where only the file’s metadata has changed (ie: the signature is identical), only the file’s attributes will be backed up. If the file’s data has been changed (hence a different signature), the file will be backed up in the usual way.

This can save considerable space when backing up files which have only metadata part changed (e.g. changed permissions). The ’pinug2o’ options could be used, which will then cause the File Daemon to compare permision bits, inotes, number of links, owner user and group and if any of it changes it will also compute the file’s singature to verify if only metadata need to be backed up or is it needed to back up the file’s contents.

Verify

verify=<options> The options letters specified are used when running a Verify Level=Catalog as well as the DiskToCatalog level job. The options letters may be any combination of the following:

  • i compare the inodes

  • p compare the permission bits

  • n compare the number of links

  • u compare the user id

  • g compare the group id

  • s compare the size

  • a compare the access time

  • m compare the modification time (st_mtime)

  • c compare the change time (st_ctime)

  • d report file size decreases

  • 5 compare the MD5 signature

  • 1 compare the SHA1 signature

  • 2 compare the SHA256 signature

  • 3 compare the SHA512 signature

  • o Save only the metadata of a file when possible (available since Bacula Enterprise 12.8.2)

The ‘o’ option should be used in conjunction with one of the signature checking options (1, 2, 3, or 5). When the option is specified, the signature is computed only for files that have one of the other accurate options specified triggering a backup of the file (for example an inode change, a permission change, etc…). In cases where only the file’s metadata has changed (ie: the signature is identical), only the file’s attributes will be backed up. If the file’s data has been changed (hence a different singature), the file will be backed up in the usual way

A useful set of general options on the Level=Catalog or Level=DiskToCatalog verify is pins5 i.e. compare permission bits, then inodes, number of links, size, and finally MD5 changes.

To save some space when backing up files which have only metadata part changed (e.g. changed permissions) the ‘pino5’ options could be used (or some other combination with the ‘o’ flag). It will then compare permision bits, inotes, number of links and if any of it changes it will also compute file’s singature to verify if only metadata need to be backed up or is it needed to update file’s contents.

Onefs

Onefs=<yes|no> If set to yes (the default), Bacula will remain on a single file system. That is it will not backup file systems that are mounted on a subdirectory. If you are using a *nix system, you may not even be aware that there are several different filesystems as they are often automatically mounted by the OS (e.g. /dev, /net, /sys, /proc …). It will inform you when it decides not to traverse into another filesystem. This can be very useful if you forgot to backup a particular partition. An example of the informational message in the job report is:

bacula-fd: /misc is a different filesystem. Will not descend from / into /misc
bacula-fd: /net is a different filesystem. Will not descend from / into /net
bacula-fd: /var/lib/nfs/rpc_pipefs is a different filesystem. Will not descend from /var/lib/
bacula-fd: /selinux is a different filesystem. Will not descend from / into /selinux
bacula-fd: /sys is a different filesystem. Will not descend from / into /sys
bacula-fd: /dev is a different filesystem. Will not descend from / into /dev
bacula-fd: /home is a different filesystem. Will not descend from / into /home

Note

In older versions of Bacula, the above message was of the form:

Filesystem change prohibited. Will not descend into /misc

If you wish to backup multiple filesystems, you can explicitly list each filesystem you want saved. Otherwise, if you set the onefs option to no, Bacula will backup all mounted file systems (i.e. traverse mount points) that are found within the FileSet. Thus if you have NFS or Samba file systems mounted on a directory listed in your FileSet, they will also be backed up. Normally, it is preferable to set onefs=yes and to explicitly name each filesystem you want backed up. Explicitly naming the filesystems you want backed up avoids the possibility of getting into a infinite loop recursing filesystems. Another possibility is to use onefs=no and to set fstype=ext4, …. See the example below for more details.

If you think that Bacula should be backing up a particular directory and it is not, and you have onefs=no set, before you complain, please do:

stat /
stat <filesystem>

where you replace filesystem with the one in question. If the Device: number is different for / and for your filesystem, then they are on different filesystems. E.g.

stat /
    File: ‘/’
    Size: 4096          Blocks: 16      IO Block: 4096    directory
Device: 302h/770d       Inode: 2         Links: 26
Access: (0755/drwxr-xr-x) Uid: (0/ root) Gid: (0/root)
Access: 2005-11-10 12:28:01.000000000 +0100
Modify: 2005-09-27 17:52:32.000000000 +0200
Change: 2005-09-27 17:52:32.000000000 +0200

stat /net
    File: ‘/home’
    Size: 4096         Blocks: 16       IO Block: 4096    directory
Device: 308h/776d      Inode: 2         Links: 7
Access: (0755/drwxr-xr-x) Uid: (0/root) Gid: (0/root)
Access: 2005-11-10 12:28:02.000000000 +0100
Modify: 2005-11-06 12:36:48.000000000 +0100
Change: 2005-11-06 12:36:48.000000000 +0100

Also be aware that even if you include /home in your list of files to backup, as you most likely should, you will get the informational message that “/home is a different filesystem” when Bacula is processing the / directory. This message does not indicate an error. This message means that while examining the File = referred to in the second part of the message, Bacula will not descend into the directory mentioned in the first part of the message. However, it is possible that the separate filesystem will be backed up despite the message. For example, consider the following FileSet:

File = /
File = /var

where /var is a separate filesystem. In this example, you will get a message saying that Bacula will not decend from / into /var. But it is important to realise that Bacula will descend into /var from the second File directive shown above. In effect, the warning is bogus, but it is supplied to alert you to possible omissions from your FileSet. In this example, /var will be backed up. If you changed the FileSet such that it did not specify /var , then /var will not be backed up.

Honor nodump flag

Honor nodump flag=<yes|no> If your file system supports the nodump flag (e.g. most BSD-derived systems and many Linux file systems) Bacula will honor the setting of the flag when this option is set to yes. Files having this flag set will not be included in the backup and will not show up in the catalog. For directories with the nodump flag set recursion is turned off and the directory will be listed in the catalog. If the honor nodump flag option is not defined or set to no every file and directory will be eligible for backup.

Portable

Portable=<yes|no> If set to yes (default is no), the Bacula File Daemon will backup Win32 files in a portable format, but not all Win32 file attributes will be saved and restored. By default, this option is set to no, which means that on Win32 systems, the data will be backed up using Windows BackupRead API calls and all the security and ownership attributes will be properly backed up (and restored). However this format is not portable to other systems – e.g. Unix, Win95/98/Me. When backing up Unix systems, this option is ignored, and unless you have a specific need to have portable backups, we recommend accept the default (no) so that the maximum information concerning your Windows files is saved.

Note

The portable directive shouldn’t be required in recent Windows/Linux versions as recent Linux versions can handle files with win32 format.

Recurse

Recurse=<yes|no> If set to yes (the default), Bacula will recurse (or descend) into all subdirectories found unless the directory is explicitly excluded using an exclude definition. If you set recurse=no, Bacula will save the subdirectory entries, but not descend into the subdirectories, and thus will not save the files or directories contained in the subdirectories. Normally, you will want the default (yes).

Sparse

Sparse=<yes|no> Enable special code that checks for sparse files such as created by ndbm. The default is no, so no checks are made for sparse files. You may specify sparse=yes even on files that are not sparse file. No harm will be done, but there will be a small additional overhead to check for buffers of all zero, and if there is a 32K block of all zeros (see below), that block will become a hole in the file, which may not be desirable if the original file was not a sparse file.

  • Restrictions: Bacula reads files in 64K buffers. If the whole buffer is zero, it will be treated as a sparse block and not written to the target Volume. However, if any part of the buffer is non-zero, the whole buffer will be written, possibly including large ranges of zeroes. As a consequence, Bacula’s detection of sparse blocks is in 64K increments rather than the system block size. If anyone considers this to be a real problem, please send in a request for change with the reason.

    If you are not familiar with sparse files, an example is say a file where you wrote 512 bytes at address zero, then 512 bytes at address 1 million. The operating system will allocate only two blocks, and the empty space or hole will have nothing allocated. However, when you read the sparse file and read the addresses where nothing was written, the OS will return all zeros as if the space were allocated, and if you backup such a file, a lot of space will be used to write zeros to the Volume. Worse yet, when you restore the file, all the previously empty space will now be allocated using much more disk space. By turning on the sparse option, Bacula will specifically look for empty space in the file, and any empty space will not be written to the Volume, nor will it be restored. The price to pay for this is that Bacula must search each block it reads before writing it. On a slow system, this may be important. If you suspect you have sparse files, you should benchmark the difference or set sparse for only those files that are really sparse.

    You probably should not use this option on files or raw disk devices that are not really sparse files (i.e. have holes in them).

Read Fifo

ReadFifo=<yes|no> If enabled, tells the Client to read the data on a backup and write the data on a restore to any FIFO (pipe) that is explicitly mentioned in the FileSet. In this case, you must have a program already running that writes into the FIFO for a backup or reads from the FIFO on a restore. This can be accomplished with the RunBeforeJob directive. If this is not the case, Bacula will hang indefinitely on reading/writing the FIFO. When this is not enabled (no, the default), the Client simply saves the directory entry for the FIFO.

Unfortunately, when Bacula runs a RunBeforeJob, it waits until that script terminates, and if the script accesses the FIFO to write into the it, the Bacula job will block and everything will stall. However, Vladimir Stavrinov as supplied tip that allows this feature to work correctly. He simply adds the following to the beginning of the RunBeforeJob script:

exec > /dev/null

No Atime

NoAtime=<yes|no> If enabled, and if your Operating System supports the O_NOATIME file open flag, Bacula will open all files to be backed up with this option. It makes it possible to read a file without updating the inode atime (and also without the inode ctime update which happens if you try to set the atime back to its previous value). It also prevents a race condition when two programs are reading the same file, but only one does not want to change the atime. It’s most useful for backup programs and file integrity checkers (and bacula can fit on both categories).

This option is particularly useful for sites where users are sensitive to their MailBox file access time. It replaces both the keepatime option without the inconveniences of that option (see below).

If your Operating System does not support this option, it will be silently ignored by Bacula.

Mtime Only

MtimeOnly=<yes|no> If enabled, tells the Client that the selection of files during Incremental and Differential backups should based only on the st_mtime value in the stat() packet. The default is no which means that the selection of files to be backed up will be based on both the st_mtime and the st_ctime values. In general, it is not recommended to use this option.

Keep atime

KeepAtime=<yes|no> The default is no. When enabled, Bacula will reset the st_atime (access time) field of files that it backs up to their value prior to the backup. This option is not generally recommended as there are very few programs that use st_atime, and the backup overhead is increased because of the additional system call necessary to reset the times. However, for some files, such as mailboxes, when Bacula backs up the file, the user will notice that someone (Bacula) has accessed the file. In this, case keepatime can be useful.

Note

If you use this feature, when Bacula resets the access time, the change time (st_ctime) will automatically be modified by the system, so on the next incremental job, the file will be backed up even if it has not changed. As a consequence, you will probably also want to use mtimeonly = yes as well as keepatime.

Check File Changes

CheckFileChanges=<yes|no> If enabled, the Client will check size, age of each file after their backup to see if they have changed during backup. If time or size mismatch, an error will raise. The default value is no.

bacula-fd: Client1.2023-03-31_09.46.21 Error: /tmp/test mtime changed during backup.

In general, it is recommended to use this option to backup regular files. It is not compatible with fifo or plugin streams.

Hardlinks=<yes|no> When enabled (yes, the default), this directive will cause hard links to be backed up. However, the File daemon keeps track of hard linked files and will backup the data only once. The process of keeping track of the hard links can be quite expensive if you have lots of them (tens of thousands or more). This doesn’t occur on normal Unix systems, but if you use a program like BackupPC, it can create hundreds of thousands, or even millions of hard links. Backups become very long and the File daemon will consume a lot of CPU power checking hard links. In such a case, set hardlinks=no and hard links will not be backed up. Note, using this option will most likely backup more data and on a restore the file system will not be restored identically to the original.

Wild

Wild=<string> Specifies a wild-card string to be applied to the filenames and directory names. Note, if Exclude is not enabled, the wild-card will select which files are to be included. If Exclude=yes is specified, the wild-card will select which files are to be excluded. Multiple wild-card directives may be specified, and they will be applied in turn until the first one that matches. Note, if you exclude a directory, no files or directories below it will be matched.

You may want to test your expressions prior to running your backup by using the bwild program. Please see the Utilities chapter of Bacula Enterprise for more information. You can also test your full FileSet definition by using the in the estimate command. It is recommended to enclose the string in double quotes.

Enhanced Wild

EnhancedWild=<yes|no> The EnhancedWild directive controls how path name matching with wildcards is done.

The default is no, which makes wildcards not match match path separators. If set to yes, an asterisk, question mark, or a bracketed slash will also be matched by a slash. In other words, wildcards will then span path hierarchy.

Wild Dir

WildDir=<string> Specifies a wild-card string to be applied to directory names only. No filenames will be matched by this directive. Note, if Exclude is not enabled, the wild-card will select directories to be included. If Exclude=yes is specified, the wild-card will select which directories are to be excluded. Multiple wild-card directives may be specified, and they will be applied in turn until the first one that matches. Note, if you exclude a directory, no files or directories below it will be matched.

It is recommended to enclose the string in double quotes.

You may want to test your expressions prior to running your backup by using the bwild program. Please see the Utilities command for more information. You can also test your full FileSet definition by using the estimate command.

Wild File

WildFile=<string> Specifies a wild-card string to be applied to non-directories. That is no directory entries will be matched by this directive. However, note that the match is done against the full path and filename, so your wild-card string must take into account that filenames are preceded by the full path. If Exclude is not enabled, the wild-card will select which files are to be included. If Exclude=yes is specified, the wild-card will select which files are to be excluded. Multiple wild-card directives may be specified, and they will be applied in turn until the first one that matches.

It is recommended to enclose the string in double quotes.

You may want to test your expressions prior to running your backup by using the bwild program. Please see the Utilities command for more information. You can also test your full FileSet definition by using the estimate command.

Regex

Regex=<string> Specifies a POSIX extended regular expression to be applied to the filenames and directory names, which include the full path. If Exclude is not enabled, the regex will select which files are to be included. If Exclude=yes is specified, the regex will select which files are to be excluded. Multiple regex directives may be specified within an Options resource, and they will be applied in turn until the first one that matches. Note, if you exclude a directory, no files or directories below it will be matched.

It is recommended to enclose the string in double quotes.

The regex libraries differ from one operating system to another, and in addition, regular expressions are complicated, so you may want to test your expressions prior to running your backup by using the bregex program.

Regex Dir

RegexDir=<string> Specifies a POSIX extended regular expression to be applied to directory names only. No filenames will be matched by this directive. Note, if Exclude is not enabled, the regex will select directories files are to be included. If Exclude=yes is specified, the regex will select which files are to be excluded. Multiple regex directives may be specified, and they will be applied in turn until the first one that matches. Note, if you exclude a directory, no files or directories below it will be matched.

It is recommended to enclose the string in double quotes.

The regex libraries differ from one operating system to another, and in addition, regular expressions are complicated, so you may want to test your expressions prior to running your backup by using the bregex program. You can also test your full FileSet definition by using the estimate command.

You find yourself using a lot of Regex statements, which will cost quite a lot of CPU time, we recommend you simplify them if you can, or better yet convert them to Wild statements which are much more efficient.

Regex File

RegexFile=<string> Specifies a POSIX extended regular expression to be applied to non-directories. No directories will be matched by this directive. However, note that the match is done against the full path and filename, so your regex string must take into account that filenames are preceded by the full path. If Exclude is not enabled, the regex will select which files are to be included. If Exclude=yes is specified, the regex will select which files are to be excluded. Multiple regex directives may be specified, and they will be applied in turn until the first one that matches.

It is recommended to enclose the string in double quotes.

The regex libraries differ from one operating system to another, and in addition, regular expressions are complicated, so you may want to test your expressions prior to running your backup by using the bregex program.

Exclude 2

Exclude=<string> The default is No. When enabled, any files matched within the Options will be excluded from the backup.

ACL Support

AclSupport=<yes|no> The default is no. If this option is set to yes, and you have the needed POSIX ACL support installed, Bacula will backup the file and directory Unix ACLs as defined in IEEE Std 1003.1e draft 17 and “POSIX.1e” (abandoned). This feature is available on Unix and Linux systems only and requires the platform ACL library. Bacula is automatically compiled with ACL support if the libacl library is installed on your system (shown in config.out). While restoring the files Bacula will try to restore the ACLs, if there is no ACL support available on the system as a whole or the destination file system, Bacula restores the files and directories but not the ACL information.

Linux systems usually have ACL support available, if not installed by default. The file systems often need to be mounted with explicit options to enable ACLs.

For other Unix operating systems there is typically support for either POSIX ACLs or the more extensible NFSv4 ACLs.

The ACL stream format between Operation Systems is not compatible so for example an ACL saved on Linux cannot be restored on Solaris.

The following Operating Systems are currently supported:

  1. AIX (pre-5.3 (POSIX) and post 5.3 (POSIX and NFSv4) ACLs)

  2. Darwin

  3. FreeBSD (POSIX and NFSv4/ZFS ACLs)

  4. HPUX

  5. IRIX

  6. Linux (POSIX and GPFS)

  7. Solaris (POSIX and NFSv4/ZFS ACLs)

  8. Tru64

ACL Support Xattr Support

XattrSupport=<yes|no> The default is no. If this option is set to yes, and your operating system support either so called Extended Attributes or Extensible Attributes Bacula will backup the file and directory XATTR data. This feature is available on Unix and Linux only and depends on support of some specific library calls in libc.

The XATTR stream format between Operating Systems is not compatible so an XATTR saved on Linux cannot for example be restored on Solaris.

On some operating systems ACLs are also stored as Extended Attributes (Linux, Darwin, FreeBSD) Bacula checks if you have the aclsupport option enabled and if so will not save the same info when saving extended attribute information. Thus ACLs are only saved once.

The following Operating Systems are currently supported:

  1. AIX (Extended Attributes)

  2. Darwin (Extended Attributes)

  3. FreeBSD (Extended Attributes)

  4. IRIX (Extended Attributes)

  5. Linux (Extended Attributes)

  6. NetBSD (Extended Attributes)

  7. Solaris (Extended Attributes and Extensible Attributes)

  8. Tru64 (Extended Attributes)

On Linux systems, extended attribute support depends on file system as well as mount options. Bacula Enterprise version 10.2 introduced specific support for CIFS file systems (Windows shares): If Linux kernel and CIFS file system provide the necessary functionality, the special system.cifs_acl extended attribute can be backed up. Restoring those extended attributes / ACLs will not recreate an identical file tree, as the ownership of the restored files will be determined by the CIFS mount option. ACLs referring to determined users will be working correctly. As such, we recommend relying on this feature only when data restores and ACLs are the goal and ownership information can reasonably well be fixed in a manual step. Please consult mount.cifs(8) for technical details.

Ignore Case

IgnoreCase=<yes|no> The default is no. On Windows systems, you will almost surely want to set this to yes. When this directive is set to yes the case of characters will be ignored in wild-card and regex comparisons. That is an uppercase A will match a lowercase a.

Fs Type

FsType=filesystem-type-list This option ensures that the FD, while processing files with this option block effective, will only descend into filesystems of types mentioned in the Filesystem-type-list. This is most useful in combination with One FS = no set.

This directive may appear multiple times, and all list elements will be added, i.e. a specification of:

FS Type = ext4, xfs
FS Type = ntfs

will result in all three mentioned file system types being accepted.

On Windows, this functionality is not available, but see Drive Type.

Drive Type

DriveType=Windows-drive-type This option is effective only on Windows machines and is somewhat similar to the Unix/Linux fstype described above, except that it allows you to select what Windows drive types you want to allow. By default all drive types are accepted.

The permitted drivetype names are:

removable, fixed, remote, cdrom, ramdisk

You may have multiple Drive Type directives, and thus permit matching of multiple drive types within a single Options resource. If the type specified on the drive type directive does not match the filesystem for a particular directory, that directory will not be backed up. This directive can be used to prevent backing up non-local filesystems. Normally, when you use this directive, you would also set onefs=no so that Bacula will traverse filesystems.

This option is not implemented in Unix/Linux systems.

Hfs Plus Support

HfsPlusSupport=<yes|no> This option allows you to turn on support for Mac OSX HFS plus finder information.

Strip Path

StripPath=<integer> This option will cause integer paths to be stripped from the front of the full path/filename being backed up. This can be useful if you are migrating data from another vendor or if you have taken a snapshot into some subdirectory. This directive can cause your filenames to be overlayed with regular backup data, so should be used only by experts and with great care.

File List

<file-list> is a list of directory and/or filename names specified with a File = directive. To include names containing spaces, enclose the name between double-quotes. Wild-cards are not interpreted in file-lists. They can only be specified in Options resources.

There are a number of special cases when specifying directories and files in a file-list. They are:

  • Any name preceded by an at-sign (@) is assumed to be the name of a file, which contains a list of files each preceded by a “File =”. The named file is read once when the configuration file is parsed during the Director startup. Note, that the file is read on the Director’s machine and not on the Client’s. In fact, the @filename can appear anywhere within the conf file where a token would be read, and the contents of the named file will be logically inserted in the place of the @filename. What must be in the file depends on the location the @filename is specified in the conf file. For example:

    Include {
        Options compression=GZIP
        @/home/files/my-files
        }
    
  • Any name beginning with a vertical bar (|) is assumed to be the name of a program. This program will be executed on the Director’s machine at the time the Job starts (not when the Director reads the configuration file), and any output from that program will be assumed to be a list of files or directories, one per line, to be included. Before submitting the specified command bacula will perform character substitution.

    This allows you to have a job that, for example, includes all the local partitions even if you change the partitioning by adding a disk. The examples below show you how to do this. However, note two things:

    1. if you want the local filesystems, you probably should be using the fstype directive, which was added in version 1.36.3 and set onefs=no.

    2. the exact syntax of the command needed in the examples below is very system dependent. For example, on recent Linux systems, you may need to add the -P option, on FreeBSD systems, the options will be different as well.

    In general, you will need to prefix your command or commands with a sh -c so that they are invoked by a shell. This will not be the case if you are invoking a script as in the second example below. Also, you must take care to escape (precede with a \) wild-cards, shell character, and to ensure that any spaces in your command are escaped as well. If you use a single quotes (’) within a double quote (“), Bacula will treat everything between the single quotes as one field so it will not be necessary to escape the spaces. In general, getting all the quotes and escapes correct is a real pain as you can see by the next example. As a consequence, it is often easier to put everything in a file and simply use the file name within Bacula. In that case the will not be sh -c necessary providing the first line of the file is #!/bin/sh.

    As an example:

    Include {
        Options {signature = SHA1 }
        File = "|sh -c ’df -l | grep \"^/dev/hd[ab]\" | grep -v \".*/tmp\" \
        | awk \"{print $6}\"’"
        }
    

    will produce a list of all the local partitions on an old Red Hat Linux system.

    Note

    The above line was split, but should normally be written on one line. Quoting is a real problem because you must quote for Bacula which consists of preceding every \ and every ” with a \, and you must also quote for the shell command.

    In the end, it is probably easier just to execute a small file with:

    Include {
        Options {
            signature=MD5
            }
        File = "|my_partitions"
        }
    

    where my_partitions has:

    #!/bin/sh
    df -l | grep "^/dev/hd[ab]" | grep -v ".*/tmp" | awk "{print $6}"
    

    If the vertical bar in front of my_partitions is preceded by a backslash as in \|, the program will be executed on the Client’s machine instead of on the Director’s machine. Please note that if the filename is given within quotes, you will need to use two slashes. An example that backs up all the local UFS partitions on a remote system is:

    FileSet {
        Name = "All local partitions"
        Include {
            Options {signature=SHA1; onefs=yes; }
            File = "\\|bash -c \"df -klF ufs | tail +2 | awk ’{print $6}’\""
        }
    }
    

    The above requires two backslash characters after the double quote (one preserves the next one). If you are a Linux user, just change the ufs to ext3 (or your preferred filesystem type), and you will be in business.

    If you know what filesystems you have mounted on your system, e.g. for Red Hat Linux normally ext4 and ext3, you can backup all local filesystems using something like:

    Include {
        Options {signature = SHA1; onfs=no; fstype=ext4 }
        File = /
        }
    

    On Windows, the command is executed with “cmd /c” prefix, and it is recommended to keep the path of the scripts as simple as possible (without spaces for example). The exact quoting and escaping sequence of the string can be difficult to determine.

  • Any file-list item preceded by a less-than sign (<) will be taken to be a file. This file will be read on the Director’s machine (see below for doing it on the Client machine) at the time the Job starts, and the data will be assumed to be a list of directories or files,one per line, to be included. The names should start in column 1 and should not be quoted even if they contain spaces. This feature allows you to modify the external file and change what will be saved without stopping and restarting Bacula as would be necessary if using the @ modifier noted above. For example:

    Include {
        Options {signature = SHA1 }
        File = "</home/files/local-filelist"
    }
    

    If you precede the less-than sign (<) with a backslash as in \<, the file-list will be read on the Client machine instead of on the Director’s machine.

    Note

    If the filename is given within quotes, you will need to use two backslashes.

    Include {
        Options {signature = SHA1 }
        File = "\\</home/xxx/filelist-on-client"
    }
    
  • If you explicitly specify a block device such as /dev/hda1, then Bacula will assume that this is a raw partition to be backed up. In this case, you are strongly urged to specify a sparse=yes include option, otherwise, you will save the whole partition rather than just the actual data that the partition contains. For example:

    Include {
        Options {signature=MD5; sparse=yes }
        File = /dev/hdb6
    }
    

    will backup the data in device /dev/hdb6. Note, the /dev/hdb6 must be the raw partition itself. Bacula will not back it up as a raw device if you specify a symbolic link to a raw device such as may be created by the LVM Snapshot utilities.

    If you explicitly specify a FIFO device name (created with mkfifo), and you add the option readfifo=yes as an option, Bacula will read the FIFO and back its data up to the Volume. For example:

    Include {
        Options {
            signature=SHA1
            readfifo=yes
            }
        File = /home/abc/fifo
    }
    

    if /home/abc/fifo is a fifo device, Bacula will open the fifo, read it, and store all data thus obtained on the Volume. Please note, you must have a process on the system that is writing into the fifo, or Bacula, after one minute of waiting, give up and go on to the next file. The data read can be anything since Bacula treats it as a stream.

    This feature can be an excellent way to do a “hot” backup of a very large database. You can use the RunBeforeJob to create the fifo and to start a program that dynamically reads your database and writes it to the fifo. Bacula will then write it to the Volume. Be sure to read the readfifo section that gives a tip to ensure that the RunBeforeJob does not block Bacula.

    During the restore operation, the inverse is true, after Bacula creates the fifo if there was any data stored with it (no need to explicitly list it or add any options), that data will be written back to the fifo. As a consequence, if any such FIFOs exist in the fileset to be restored, you must ensure that there is a reader program or Bacula will time out the write to the fifo after one minute and move on to the next file.

  • A file-list may not contain wild-cards. Use directives in the Options resource if you wish to specify wild-cards or regular expression matching.

  • The ExcludeDirContaining = is a directive that can be added to the Include section of the FileSet resource. If the specified filename (filename-string) is found on the Client in any directory to be backed up, the whole directory will be ignored (not backed up). For example:

    # List of files to be backed up
    FileSet {
        Name = "MyFileSet"
        Include {
            Options {
                signature = MD5
            }
        File = /home
        Exclude Dir Containing = .excludeme
        }
    }
    

    will allow users to indicate that they don’t want to have certain directories backed up. For example, with the above FileSet, if the user or sysadmin creates a file named .excludeme in specific directories, such as

    /home/user/www/cache/.excludeme
    /home/user/temp/.excludeme
    

    then Bacula will not backup the two directories named:

    /home/user/www/cache
    /home/user/temp
    

    Note

    Subdirectories will not be backed up. That is, the directive applies to the two directories in question and any children (be they files, directories, etc.).

FileSet Examples

The following is an example of a valid FileSet resource definition.

Note

The first Include pulls in the contents of the file when Bacula is started (i.e. the @), and that file must have each filename to be backed up preceded by a File = and on a separate line.

FileSet {
    Name = "Full Set"
    Include {
        Options {
            Compression=GZIP
            signature=SHA1
            Sparse = yes
        }
        @/etc/backup.list
    }
    Include {
        Options {
            wildfile = "*.o"
            wildfile = "*.exe"
            Exclude = yes
        }
        File = /root/myfile
        File = /usr/lib/another_file
    }
}

In the above example, all the files contained in /etc/backup.list will be compressed with GZIP compression, an SHA1 signature will be computed on the file’s contents (its data), and sparse file handling will apply.

The two directories /root/myfile and /usr/lib/another_file will also be saved without any options, but all files in those directories with the extensions and will be excluded.

Let’s say that you now want to exclude the directory /tmp. The simplest way to do so is to add an directive that lists /tmp. The example above would then become:

FileSet {
    Name = "Full Set"
    Include {
        Options {
            Compression=GZIP
            signature=SHA1
            Sparse = yes
        }
    @/etc/backup.list
    }

    Include {
        Options {
            wildfile = "*.o"
            wildfile = "*.exe"
            Exclude = yes
        }
        File = /root/myfile
        File = /usr/lib/another_file
    }
    Exclude {             # don’t add trailing /
        File = /tmp
    }
}

Now let’s make a slight variation on the above and suppose you want to save all your filesystems except /tmp. The problem that comes up is that Bacula will not normally cross from one filesystem to another. Doing a df command, you get the following output:

:math:`df
Filesystem      1k-blocks      Used Available Use% Mounted on
/dev/hda5         5044156    439232   4348692  10% /
/dev/hda1           62193      4935     54047   9% /boot
/dev/hda9        20161172   5524660  13612372  29% /home
/dev/hda2           62217      6843     52161  12% /rescue
/dev/hda8         5044156     42548   4745376   1% /tmp
/dev/hda6         5044156   2613132   2174792  55% /usr
none               127708         0    127708   0% /dev/shm
//minimatou/c` 14099200 9895424 4203776 71 lmatou:/ 1554264 215884
1258056 15 lmatou:/home 2478140 1589952 760072 68 lmatou:/usr 1981000
1199960 678628 64 lpmatou:/ 995116 484112 459596 52 lpmatou:/home
19222656 2787880 15458228 16 lpmatou:/usr 2478140 2038764 311260 87
deuter:/ 4806936 97684 4465064 3 deuter:/home 4806904 280100 4282620
7 deuter:/files 44133352 27652876 14238608 67

And we see that there are a number of separate filesystems (/ /boot /home /rescue/tmp and /tmp not to mention mounted systems). If you specify only in your Include list, Bacula will only save the Filesystem /dev/hda5. To save all filesystems except /tmp with out including any of the Samba or NFS mounted systems, and explicitly excluding a /tmp, proc, .journal, and .autofsck, which you will not want to be saved and restored, you can use the following:

FileSet {
    Name = Include_example
    Include {
        Options {
            wilddir = /proc
            wilddir = /tmp
            wildfile = "/.journal"
            wildfile = "/.autofsck"
            exclude = yes
        }
    File = /
    File = /boot
    File = /home
    File = /rescue
    File = /usr
    }
}

Since /tmp is on its own filesystem and it was not explicitly named in the Include list, it is not really needed in the exclude list. It is better to list it in the Exclude list for clarity, and in case the disks are changed so that it is no longer in its own partition.

Now, lets assume you only want to backup .Z and .gz files and nothing else. This is a bit trickier because Bacula by default will select everything to backup, so we must exclude everything but .Z and .gz files. If we take the first example above and make the obvious modifications to it, we might come up with a FileSet that looks like this:

FileSet {
    Name = "Full Set"
    Include {
        Options {
            wildfile = "*.Z"
            wildfile = "*.gz"
        }
    File = /myfile
    }
}

The .Z and .gz files will indeed be backed up, but all other files that are not matched by the Options directives will automatically be backed up too (i.e. that is the default rule).

To accomplish what we want, we must explicitly exclude all other files. We do this with the following:

FileSet {
    Name = "Full Set"
    Include {
        Options {
            wildfile = "*.Z"
            wildfile = "*.gz"
        }
        Options {
            Exclude = yes
            RegexFile = ".*"
        }
        File = /myfile
    }
}

The “trick” here was to add a RegexFile expression that matches all files. It does not match directory names, so all directories in /my_file will be backed up (the directory entry) and any .Z and .gz files contained in them. If you know that certain directories do not contain any .Z or .gz files and you do not want the directory entries backed up, you will need to explicitly exclude those directories. Backing up a directory entry is not very expensive.

Bacula uses the system regex library and some of them are different on different OSes. The above has been reported not to work on FreeBSD. This can be tested by using the estimate job=job-name listing command in the console and adapting the RegexFile expression appropriately. In a future version of Bacula, we will supply our own Regex code to avoid such system dependencies.

Be aware that allowing Bacula to traverse or change file systems can be very dangerous. For example, with the following:

FileSet {
    Name = "Bad example"
    Include {
        Options {onefs=no }
        File = /mnt/matou
    }
}

you will be backing up an NFS mounted partition (/mnt/matou), and since onefs is set to no, Bacula will traverse file systems. Now if /mnt/matou has the current machine’s file systems mounted, as is often the case, you will get yourself into a recursive loop and the backup will never end.

As a final example, let’s say that you have only one or two subdirectories of /home that you want to backup. For example, you want to backup only subdirectories beginning with the letter a and the letter b – i.e. /home/a and /home/b . Now, you might first try:

FileSet {
    Name = "Full Set"
    Include {
        Options {
            wilddir = "/home/a*"
            wilddir = "/home/b*"
            }
        File = /home
        }
    }

The problem is that the above will include everything in /home. To get things to work correctly, you need to start with the idea of exclusion instead of inclusion. So, you could simply exclude all directories except the two you want to use:

FileSet {
    Name = "Full Set"
    Include {
        Options {
            RegexDir = "^/home/[c-z]"
            exclude = yes
        }
    File = /home
    }
}

And assuming that all subdirectories start with a lowercase letter, this would work.

An alternative would be to include the two subdirectories desired and exclude everything else:

FileSet {
    Name = "Full Set"
        Include {
            Options {
                wilddir = "/home/a*"
                wilddir = "/home/b*"
            }
        Options {
            RegexDir = ".*"
            exclude = yes
        }
        File = /home
        }
    }

The following example shows how to back up only the My Pictures directory inside the My Documents directory for all users in C:/Documents and Settings, i.e. everything matching the pattern:

C:/Documents and Settings/*/My Documents/My Pictures/

To understand how this can be achieved, there are two important points to remember:

Firstly, Bacula traverses the filesystem starting from the File = lines. It stops descending when a directory is excluded, so you must include all ancestor (higher level) directories of each directory containing files to be included.

Secondly, each directory and file is compared to the Options clauses in the order they appear in the FileSet. When a match is found, no further Optionss are compared and the directory or file is either included or excluded.

The FileSet resource definition below implements this by including specific directories and files and excluding everything else.

FileSet {
    Name = "AllPictures"
    Include {
        File = "C:/Documents and Settings"
        Options {
            signature = SHA1
            verify = s1
            IgnoreCase = yes
            # Include all users’ directories so we reach the inner ones. Unlike a
            # WildDir pattern ending in *, this RegExDir only matches the top-level
            # directories and not any inner ones.
            RegExDir = "^C:/Documents and Settings/[^/]+$"
            # Ditto all users’ My Documents directories.
            WildDir = "C:/Documents and Settings/*/My Documents"
            # Ditto all users’ My Documents/My Pictures directories.
            WildDir = "C:/Documents and Settings/*/My Documents/My Pictures"
            # Include the contents of the My Documents/My Pictures directories and
            # any subdirectories.
            Wild = "C:/Documents and Settings/*/My Documents/My Pictures/*"
        }
        Options {
            Exclude = yes
            IgnoreCase = yes
            # Exclude everything else, in particular any files at the top level and
            # any other directories or files in the users’ directories.
            Wild = "C:/Documents and Settings/*"
            }
        }
    }

In the above example, we setup a FileSet to backup a subset of a single directory (on Windows) based on filename.

FileSet {
    Name = "win-fileset"
    Include {
        Options {
            signature = MD5
            wildfile = "C:/File/backup_NDB_COUNT*"
        }
        # Exclude all files not matching the wildfile list above
    Options {
        Exclude = yes
        RegexFile = ".*"
        }
    File = C:/File
    }
}

Backing Up Raw Partitions

The following FileSet definition will backup a raw partition:

FileSet {
    Name = "RawPartition"
    Include {
        Options {sparse=yes }
        File = /dev/hda2
    }
}

While backing up and restoring a raw partition, you should ensure that no other process including the system is writing to that partition. As a precaution, you are strongly urged to ensure that the raw partition is not mounted or is mounted read-only. If necessary, this can be done using the RunBeforeJob directive.

Excluding Files and Directories

You may also include full filenames or directory names in addition to using wild-cards and Exclude=yes in the Options resource as specified above by simply including the files to be excluded in an Exclude resource within the FileSet. It accepts wild-cards pattern, so for a directory, don’t add a trailing /. For example:

FileSet {
    Name = Exclusion_example
    Include {
        Options {
            Signature = SHA1
        }
    File = /
    File = /boot
    File = /home
    File = /rescue
    File = /usr
    }
    Exclude {
        File = /proc
        File = /tmp
        File = .journal
        File = .autofsck
    }
}

The following fileset will not work as expected:

Fileset {
  Name = "Home-fileset"
  Description = "Home directory without File1* files"
  Include {
   Options {
    AclSupport = yes
    FsType = "xfs","ext2","ntfs","ext3","ext4","apfs","hfs"
    OneFs = no
    Signature = Sha1
    Sparse = yes
    XattrSupport = yes
   }
   Options {
     Exclude = yes
     WildDir = "/home/dir1/File1*"
  }
   File = "/"
  }
}

When parsing the Options blocks, Bacula will parse the first block and apply all the defined options if a file matches it. However, it will go through the second Options block (having Exclude = yes) and, even if the file doesn’t match this block, the options from this second block are applied to the file that will be included in the backup. As there is no option defined, the default values are used which means “AclSupport = no, OneFS = yes, Signature = none, Sparse = no, xattrSupport = no” will be used. The options you wish to have applied for all files that will be included in the backup, should be in the last options block:

Fileset {
  Name = "Home-fileset"
  Description = "Home directory without File1* files"
  Include {
   Options {
     Exclude = yes
     WildDir = "/home/dir1/File1*"
  }
   Options {
    AclSupport = yes
    FsType = "xfs","ext2","ntfs","ext3","ext4","apfs","hfs"
    OneFs = no
    Signature = Sha1
    Sparse = yes
    XattrSupport = yes
   }
   File = "/"
  }
}

Windows FileSets

If you are entering Windows file names, the directory path may be preceded by the drive and a colon (as in c:). However, the path separators must be specified in Unix convention (i.e. forward slash (/)). If you wish to include a quote in a file name, precede the quote with a backslash (). For example you might use the following for a Windows machine to backup the My Documents directory:

FileSet {
    Name = "Windows Set"
    Include {
        Options {
            WildFile = "*.obj"
            WildFile = "*.exe"
            exclude = yes
        }
        File = "c:/My Documents"
    }
}

For exclude lists to work correctly on Windows, you must observe the following rules:

  • Filenames are case sensitive, so you must use the correct case.

  • To exclude a directory, you must not have a trailing slash on the directory name.

  • If you have spaces in your filename, you must enclose the entire name in double-quote characters (“). Trying to use a backslash before the space will not work.

  • If you are using the old Exclude syntax (noted below), you may not specify a drive letter in the exclude. The new syntax noted above should work fine including driver letters.

If you are having difficulties getting includes or excludes to work, you might want to try using the estimate job=xxx listing command.

On Windows systems, if you move a directory or file or rename a file into the set of files being backed up, and a Full backup has already been made, Bacula will not know there are new files to be saved during an Incremental or Differential backup (blame Microsoft, not me). To avoid this problem, please copy any new directory or files into the backup area. If you do not have enough disk to copy the directory or files, move them, but then initiate a Full backup.

A Windows Example FileSet

Note

For presentation purposes, the lines beginning with Data and Internet have been wrapped and should included on the previous line with one space.

This is my Windows 2022 fileset:

FileSet {
    Name = "Windows 2022"
    Include {
        Options {
            signature = MD5
            Exclude = yes
            IgnoreCase = yes
            # Exclude cache files
            WildDir = "[A-Z]:/ProgramData/Windows/Caches"
            WildDir = "[A-Z]:/Users/*/AppData"
            WildFile = "[A-Z]:/Users/*/ntuser.DAT"
            WildDir = "C:/ClusterStorage"
            # Some random bits of Windows we want to ignore
            WildDir = "[A-Z]:/Windows/system32/config"
            WildDir = "[A-Z]:/Windows/NTDS"
            WildDir = "[A-Z]:/Windows/cluster"
            # Temporary directories & files
            WildDir = "[A-Z]:/Windows/temp"
            WildDir = "[A-Z]:/Windows/Spool"
            WildFile = "*.tmp"
            # Recycle bins
            WildDir = "[A-Z]:/$RECYCLE.BIN"
            # Swap files
            WildFile = "[A-Z]:/pagefile.sys"
            # These are programs and are easier to reinstall than restore from
            # backup
            WildDir = "[A-Z]:/cygwin"
            WildDir = "[A-Z]:/Program Files/Grisoft"
            WildDir = "[A-Z]:/Program Files/Java"
            WildDir = "[A-Z]:/Program Files/Java Web Start"
            WildDir = "[A-Z]:/Program Files/JavaSoft"
            WildDir = "[A-Z]:/Program Files/Microsoft Office"
            WildDir = "[A-Z]:/Program Files/Mozilla Firefox"
            WildDir = "[A-Z]:/Program Files/Mozilla Thunderbird"
            WildDir = "[A-Z]:/Program Files/OpenOffice*"
            WildDir = "[A-Z]:/Program Files (x86)/Internet Explorer"
            WildDir = "[A-Z]:/Program Files (x86)/Windows Defender"
        }
    File = "/"
    }
}

Note

The three line of the above were split to fit on the document page, they should be written on a single line in real use.

Testing Your FileSet

If you wish to get an idea of what your FileSet will really backup or if your exclusion rules will work correctly, you can test it by using the estimate command in the Console program. See the of the estimate command.

As an example, suppose you add the following test FileSet:

FileSet {
    Name = Test
    Include {
        File = /home/xxx/test
        Options {
            regex = ".*\.c$"
        }
    }
}

You could then add some test files to the directory and use the following command in the console:

estimate job=<any-job-name> listing client=<desired-client> fileset=Test

to give you a listing of all files that match. In the above example, it should be only files with names ending in .

Include All Windows Drives in FileSet

The alldrives Windows Plugin allows you to include all local drives with a simple directive. This plugin is available in the Windows 64 and 32 bit installer.

FileSet {
    Name = EverythingFS
    ...
    Include {
        Plugin = "alldrives"
    }
}

You exclude some specific drives with the exclude option.

FileSet Name = EverythingFS ... Include Plugin = "alldrives:
exclude=D,E"

The all-drives Windows plugin only considers regular drives (i.e. C:/, D:/, E:/). Mount points inside the directory tree will no be part of the snapshots unless you set “OneFS = no” in the block of the FileSet, which will cause Bacula to snapshot everything.

Microsoft VSS Writer Plugin

We provide a single plugin named vss-fd.dll that permits you to backup a number of different components on Windows machines. This plugin is available from Bacula Systems as an option.

Find more information about it here: vss-plugin

Contact the Support Team to find more information about our VSS products.

System State writers:

  • Registry

  • Event Logs

  • COM+ REGDB (COM Registration Database)

  • System (Systems files – most of what is under c:/windows and more)

  • WMI

  • NTDS (Active Directory)

  • NTFRS (SYSVOL etc replication – Windows 2003 domains)

  • DFS Replication (SYSVOLS etc replication – Windows 2008 domains)

  • ASR Writer

This component is known to work.

Each of the above specified Microsoft components can be backed up by specifying a different plugin option within the Bacula FileSet. All specifications must start with vss: and be followed with a keyword which indicates the writer, such as /@SYSTEMSTATE/ (see below).

To activate each component, use the following:

  • System State writers

    Plugin = "vss:/@SYSTEMSTATE/"
    

    Note, exactly which subcomponents will be backed up depends on which ones you have enabled within Windows. For example, on a standard default Vista system only ASR Writer, COM+ REGDB, System State, and WMI are enabled.

  • MSSQL databases (except those owned by Sharepoint if that plugin is specified)

    Plugin = "vss:/@MSSQL/"
    

    The Microsoft literature says that the mssql writer is only good for snapshots and it needs to be enabled via a registry tweak or else the older MSDE writer will be invoked instead.

  • Exchange (all exchange databases)

    Plugin = "vss:/@EXCHANGE/"
    

The plugin directives must be specified exactly as shown above. A Job may have one or more of the vss plugins components specified.

Also ensure that the vss-fd.dll plugin is in the plugins directory on the FD doing the backup, and that the plugin directory config line is present in the FD’s configuration file (bacula-fd.conf).

Backup

If everything is set up correctly as above then the backup should include the system state. The system state files backed up will appear in a bconsole or BAT(Bacula Administration Tool) restore like:

/@SYSTEMSTATE/
/@SYSTEMSTATE/ASR Writer/
/@SYSTEMSTATE/COM+ REGDBWriter/

etc.

Only a complete backup of the system state is supported at this time. That is it is not currently possible to just back up the Registry or Active Directory by itself. In almost all cases a complete backup is a good idea anyway as most of the components are interconnected in some way. Also, if an incremental or differential backup is specified on the backup Job then a full backup of the system state will still be done. The size varies according to your installation. The actual size depends on how many Windows components are enabled.

The system state component automatically respects all the excludes present in the FilesNotToBackup registry key, which includes things like %TEMP%, pagefile.sys, hiberfil.sys, etc. Each plugin may additionally specify files to exclude, eg the VSS Registry Writer will tell Bacula to not back up the registry hives under C:WINDOWSsystem32config because they are backed up as part of the system state.

Restore

In most cases a restore of the entire backed up system state is recommended. Individual writers can be selected for restore, but currently not individual components of those writers. To restore just the Registry, you would need to mark @SYSTEMSTATE (only the directory, not the subdirectories), and then do mark Registry* to mark the Registry writer and everything under it.

Restoring anything less than a single component may not produce the intended results and should only be done if a specific need arises and you know what you are doing, and not without testing on a non-critical system first.

To restore Active Directory, the system will need to be booted into Directory Services Restore Mode, an option at Windows boot time.

Only a non-authoritative restore of NTFRS/DFSR is supported at this time. There exists Windows literature to turn a DC restored in non-authoritative mode back into an authoritative Domain Controller. If only one DC exists it appears that Windows does an authoritative restore anyway.

Most VSS components will want to restore to files that are currently in use. A reboot will be required to complete the restore (eg to bring the restored registry online).

Starting another restore of VSS data after the restore of the registry without first rebooting will not produce the intended results as the “to be replaced next reboot” file list will only be updated in the “to be replaced” copy of the registry and so will not be actioned.

Example

Suppose you have the following backup FileSet:

@SYSTEMSTATE/
    System Writer/
        instance_{GUID}
        System Files/
    Registry Writer/
        instance_{GUID}
        Registry/
    COM+ REGDB Writer/
        instance_{GUID}
        COM+ REGDB/
    NTDS/
        instance_{GUID}
        ntds/

If only the Registry needs to be restored, then you could use the following commands in bconsole:

markdir @SYSTEMSTATE
cd @SYSTEMSTATE
markdir "Registry Writer"
cd "Registry Writer"
mark instance*
mark "Registry"

Windows Plugins Items to Note

  • Reboot Required after a Plugin Restore In general after any VSS plugin

    is used to restore a component, you will need to reboot the system. This is required because in-use files cannot be replaced during restore time, so they are noted in the registry and replaced when the system reboots.

  • After a System State restore, a reboot will generally take longer

    than normal because the pre-boot process must move the newly restored files into their final place prior to actually booting the OS.

  • One File from Each Drive needed by the Plugins must be backed up

    At least one file from each drive that will be needed by the plugin must have a regular file that is marked for backup. This is to ensure that the main Bacula code does a snapshot of all the required drives. At a later time, we will find a way to accomplish this automatically.

  • Bacula does not Automatically Backup Mounted Drives

    Any drive that is mounted in the normal file structure using a mount point or junction point will not be backed up by Bacula. If you want it backed up, you must explicitly mention it in a Bacula file directive in your FileSet.

  • When doing a backup that is to be used as a Bare Metal Recovery, do

    not use the VSS plugin. The reason is that during a Bare Metal Recovery, VSS is not available nor are the writers from the various components that are needed to do the restore. You might do full backup to be used with a Bare Metal Recovery once a month or once a week, and all other days, do a backup using the VSS plugin, but under a different Job name. Then to restore your system, use the last Full non-VSS backup to restore your system, and after rebooting do a restore with the VSS plugin to get everything fully up to date.

This plugin is available as an option. Contact Bacula Systems to get access to the VSS Plugin packages and the documentation.

Go back to the Director Resource Types page.

Go back to the Technical Reference for Director.