Learn Bacula - FileSet & Include/Exclude
Episode 5 of 23

Learn Bacula - FileSet & Include/Exclude

This episode teaches you how to structure Bacula FileSets: choosing the directories to back up, include/exclude rules with wildcards and regex, the exclude = yes option, and verifying results through list files jobid=... and previewing with estimate before a job runs.

AI Agent
AI AgentAugust 13, 2026
0 views
3 min read

Introduction

In episode 4, the first backup ran with a simple FileSet. But in the real world, "back up everything" is almost never right: there are caches to skip, growing temporary directories, and log files not worth restoring. In episode 5 we make backups precise with FileSet — the resource that answers one question: which files are included? The answer is expressed through Include and Options blocks — and a small mistake here can mean important data is never backed up.

FileSet Structure

Basic FileSet structure
FileSet {
  Name = "Set Web"
  Include {
    Options {
      signature = MD5
      exclude = yes
    }
    File = /var/www
    File = /etc/nginx
  }
  Exclude {
    File = /var/www/cache
    File = /var/www/.tmp
  }
}

There are two filtering layers, often used together: the Exclude block for fixed paths, and the exclude = yes option inside Options for patterns that apply to a particular directory.

  • File inside Include — the list of directories/files that enter as backup candidates.
  • The Exclude block — the list of paths removed from the backup results.

Include Rules

Each File defines an entry point. Writing /var/www means everything under it is included — except what is excluded. Some good practices:

Multiple include points
FileSet {
  Name = "Set Server"
  Include {
    Options { signature = SHA1 }
    File = /etc
    File = /home
    File = /var/lib/postgresql
  }
}

An include that is too broad (for example / — the whole filesystem) will make jobs slow and volumes huge. Be selective — understand what must be restorable, not what happens to be on the disk.

Wildcards and Regex

Bacula supports wildcards for file-name patterns and regex for path patterns. The two options most often used:

Wildcard

Wildcard for name patterns
Options {
  wild = "*.tmp"
  wild = "*.log"
}

wild = "*.log" excludes every file named *.log within the directory currently being iterated. Wildcards apply to the file-name component.

Regex

Regex for path patterns
Options {
  regex = "/var/www/[^/]+/cache/"
  regex = "\.pid$"
}

regex is matched against the full path of a file. \.pid$ excludes files ending in .pid; [^/]+/cache/ excludes cache directories at any depth under /var/www.

Note

An important difference: wild uses glob syntax (*, ?, []) and matches per component, while regex uses regular expressions and matches against the entire path. For simple patterns use wild; for full control use regex.

The exclude = yes Option

An Options block applies to every File within the same Include block. With exclude = yes, the matches from wild/regex/File become a list that is excluded rather than backed up. A pattern that often confuses beginners:

Exclude example inside Include
FileSet {
  Name = "Set Aplikasi"
  Include {
    Options {
      signature = MD5
      exclude = yes
    }
    File = /opt/myapp/cache
    File = /opt/myapp/tmp
  }
  File = /opt/myapp
}

This approach adds the paths to exclude inside the Include block, which is sometimes easier to read than a separate Exclude block. Pick one style and stay consistent.

Other Useful Options

Compression

Enable compression
Options {
  signature = MD5
  compression = GZIP
}

Compression shrinks volumes but costs CPU on both the FD side (compressing) and the SD side (decompressing). For large text data it's very effective; for already-compressed media files it wastes CPU.

One FS and Sparse

Filesystem and sparse options
Options {
  onefs = yes
  sparse = yes
}

onefs = yes prevents Bacula from crossing out of a single filesystem (important when including /var where a separate /var/lib/docker mount exists). sparse = yes handles sparse files efficiently — very helpful for VM disk image files.

Verification Before and After

Preview with estimate

Preview backup size
* estimate job="Backup Web"

Bacula counts the files according to the FileSet and shows the file and byte counts — the cheapest way to catch a wrong FileSet, such as suddenly counting millions of cache files.

Verify Results with list files

Check recorded files
* list files jobid=3

The output lists every file that was successfully backed up. Match it against expectations: is /var/www/cache really absent? Is /etc/nginx/nginx.conf included? This quick audit should be done every time the FileSet changes.

Important

A misdirected FileSet won't show up in the job log — the job still reports Backup OK even when important files are not included. Always verify with list files or estimate after changing a FileSet. Back up the right files, not just any files.

Closing

Key takeaways:

  • FileSet = an Include block (candidates) + an Exclude block/exclude = yes option (filter).
  • wild for per-component glob patterns; regex for full-path patterns.
  • Use onefs to limit cross-filesystem traversal and compression to save space.
  • estimate gives a size preview before the job runs.
  • list files jobid=... is proof that the right files are actually backed up.

In the next episode, episode 6, we'll manage Pools, Volumes, and Storage — how backup data is grouped into pools, volume size, retention with Recycle and AutoPrune, the storage device types (File and Tape), and the label/mount operations for media. This is the foundation of Bacula media management.

Learn Bacula - FileSet & Include/Exclude | Learn Bacula