Tarsnap - Online backups for the truly paranoid

Navigation menu

Selecting files to back up

You can customize which files Tarsnap backs up with the include, exclude, nodump options.

Whichever method(s) you chose, once you have prepared the configuration file, it is strongly recommended that you use --dry-run -v to check that the right files and directories will be backed up:

tarsnap -c --dry-run -v /MY/DATADIR

Global flags: include and exclude

This behaviour of include and exclude is inherited from BSD tar(1); all filenames are checked against the specified patterns.

  • Any include option will back up only those files and directories.
  • All exclude options are processed before include, and exclude takes precedence. This pair of lines in the config file will result in nothing being backed up:
    exclude /
    include /home
  • The process of recursing into subdirectories is also affected. Adding this to the config file:
    include /home
    and then attempting to back up / results in nothing being backed up.
  • Wildcards * may be used.
    However, if you are using wildcards on the command-line, make sure that the shell does not expand them. For example, use --include "only-these-*" with the quotation marks.

Per-directory, per-file: nodump

Tarsnap pays attention to the nodump flag on files and directories if you use the tarsnap --nodump option. This is particularly useful on a multi-user system, where a user may wish to exclude files herself without needing to ask the system administrator to edit the include / exclude list.

Users can set the flag on their own files, with the command depending on the operating system:

  • On Linux, you can set (or unset) the flag with:
    chattr +d big-temporary-data/
    chattr -d small-permanent-data/
    and view attributes with
    lsattr
  • On BSD (including macOS), you can set (or unset) the flag with:
    chflags nodump big-temporary-data/
    chflags dump   small-permanent-data/
    and view attributes with
    ls -lao

Tarsnap must have the --nodump option set on the command-line or in the configuration file.