I was asked by a former colleague how to do the following in Bacula:
Backup all the sub directories in /data/users/, but exclude /data/users/*/scratch.
Unfortunately, Bacula is slightly less than intuitive on this matter. Simply adding the directory and adding an exclusion later won't work correctly. You need to exclude the directories, first, and then add the directory.
Here is the pattern that works (in the FileSet for the given host - you can ignore the large list of options I have in the set; the first block of options are not necessary for the selective exclusion)
FileSet {
Name = "file_server set"
Include {
Options {
signature = SHA1
compression=GZIP5
onefs=yes
noatime=yes
hardlinks=yes
sparse=yes
ignore case=no
checkfilechanges=yes
}
/usr
/etc
/var
Options {
RegexDir = "^/data/users/.*/scratch"
exclude = yes
}
/data/users
}
}
As you can see, the exclusion needs to happen before the directory is selected. It appears to be a "first match" wins selection method.
Of course, you should test this yourself to make sure it works and doesn't negatively affect your backups.