Opsmate

Excluding Files from Backups

By default, Opsmate backs up all filesystems except for remote (e.g. NFS) or pseudo (e.g. /proc, /sys) filesystems. Specific files and directories can be excluded by editing the file list, /etc/opsmate/backups/file-list. Opsmate installs a default file list that excludes files that generally should not be backed up (such as runtime data, caches, and temporary files).

The format of the file list is a sequence of lines consisting of the operator (+ to include a file, - to exclude a file), followed by a space, followed by the path to include or exclude. Lines starting with a # are ignored.

For example, - /var/tmp excludes /var/tmp.

Paths may contain the following wildcard characters:

  • A single asterisk (*) matches zero or more characters, except for forward slash (/).
  • A double asterisk (**) matches zero or more characters, including forward slash (/).

The file list has the following semantics:

  • Rules are processed from top to bottom, and the first rule to match a path takes precedence.
  • A path ending in a slash (/) matches only directories.
  • If a path starts with a /, it matches the entire path. If it does not start with a /, only the last component(s) of the path are matched. (Example: to exclude all .o files everywhere, use - *.o; to exclude .o files only in the root, use - /*.o.)
  • A single asterisk (*) has to match exactly one path component, whereas a double asterisk (**) matches any number of path components, including zero. (Example: /src/*/core does not match /src/core whereas /src/**/core does.)
  • If a directory is included/excluded, so are all of its descendants, unless an earlier rule explicitly includes or excludes a descendant.

Paths are included by default if no rule matches them. This behavior can be changed by adding a catch-all - * rule to the bottom of the file list. See Backing Up Specific Directories for details.

Including an Excluded Filesystem

To include a remote or pseudo filesystem that would normally be excluded, add an explicit rule for its mount point to your file list:

Example: + /proc

Be warned that pseudo filesystems often have strange semantics that may confuse Opsmate, and remote filesystems may take a long time to back up. If possible, run Opsmate directly on the file server rather than backing it up via a remote mount.

Example

# Exclude all files named core:
- core

# Exclude all files whose names end in ~:
- *~

# Exclude /etc/random-seed:
- /etc/random-seed

# Exclude all descendants of the /tmp directory:
- /tmp/*

# Exclude all descendants of /var/cache, except for /var/cache/apt:
+ /var/cache/apt
- /var/cache/*

# Exclude all files under /home/andrew/src whose names end in .o:
- /home/andrew/src/**.o

Note that order is important in this example. The rule to include /var/cache/apt must come before excluding /var/cache/*, or else it would have no effect. The rules for excluding core and *~ must come before the rule to include /var/cache/apt, or else they would have no effect inside /var/cache/apt.