btrbk.conf − btrbk configuration file
The btrbk configuration file specifies which btrfs subvolumes on the filesystem are to be processed, what target subvolumes should be used to create the backups, and where the snapshots should be generated. The retention policy, as well as most other options can be defined either globally or within a section.
The options specified always apply to the last section encountered, superseding the values set in upper-level sections. This means that global options must be set before any sections are defined.
Blank lines are ignored. A hash character (#) starts a comment extending until end of line.
Directory of a btrfs volume containing the source subvolume(s) to be backed up. <volume−directory> must be an absolute path and point to a btrfs volume (or subvolume). Usually the mount point of a btrfs filesystem mounted with the subvolid=0 option.
Subvolume to be backed up, relative to the <volume−directory> specified in the volume section. Multiple subvolume sections are allowed within volume sections. Accepts wildcard character "*".
target <type> <target−directory>|<url>
Target type and directory where the backup subvolumes are to be created. See the TARGET TYPES section for supported <type>. Multiple target sections are allowed within subvolume sections. A target section defined in the global context or in a volume section is propagated (multiplied) to all underlying subvolume sections, unless a target with the same declaration already exists (hint: run "btrbk config print" to see the resulting configuration).
For the volume and target sections, you can specify a ssh−url instead of a local directory. The syntax for <url> is:
If a <url> is specified, all access to the filesystem is performed via ssh, using the "ssh_" options described below. For convenience, "ssh://<hostname>/<directory>" can also be specified as "<hostname>:<directory>".
Note that btrfs is very picky on file names (mainly for security reasons), only the characters [0−9] [a−z] [A−Z] and "._+−@" are allowed.
If set, all transactions (snapshot create, subvolume send−receive, subvolume delete) as well as abort messages are logged to <file>, in a space-separated table format: "localtime type status duration target_url source_url parent_url message".
If set, all transactions (as described in transaction_log above) are logged to syslog. The program name used in the messages is "btrbk". Accepted parameters for <facility>: user, mail, daemon, auth, lpr, news, cron, authpriv, local0..local7.
Timestamp format used as postfix for new snapshot subvolume names. Defaults to “short”.
YYYYMMDD[_N] (e.g. "20150825", "20150825_1")
YYYYMMDD<T>hhmm[_N] (e.g. "20150825T1531")
YYYYMMDD<T>hhmmss±hhmm[_N] (e.g. "20150825T153123+0200")
Note that a postfix "_N" is appended to the timestamp if a snapshot or backup already exists with the timestamp of current date/time.
Use “long−iso” if you want to make sure that btrbk never creates ambiguous time stamps (which can happen if multiple snapshots are created during a daylight saving time clock change).
Note that using “long−iso” has implications on the scheduling, see RETENTION POLICY (caveats) below.
Directory in which the btrfs snapshots are created, relative to <volume−directory> of the volume section. Note that btrbk does not autmatically create this directory, and the snapshot creation will fail if it is not present.
Base name of the created snapshot (and backup). This option is only valid in the subvolume section. Defaults to <subvolume−name>.
If set to “always”, snapshots are always created. If set to “onchange”, snapshots are only created if the source subvolume has changed since the last snapshot (more precisely: if the btrfs generation has been increased since the last snapshot). If set to “ondemand”, snapshots are only created if the target subvolume is reachable (useful if you are tight on disk space and you only need btrbk for backups to an external disk which is not always connected). If set to “no”, the snapshots are never created (useful if another instance of btrbk is taking care of snapshot creation). Defaults to “always”.
If set, incremental backups are created. If set to “strict”, non-incremental (initial) backups are never created. Defaults to “yes”.
Set retention policy for snapshots (see RETENTION POLICY below). If set to “no”, preserve snapshots according to snapshot_preserve_min only. Defaults to “no”.
Preserve all snapshots for a minimum amount of hours (h), days (d), weeks (w), months (m) or years (y), regardless of how many there are. If set to “all”, preserve all snapshots forever. If set to “latest”, preserve latest snapshot. Defaults to “all”.
Set retention policy for backups (see RETENTION POLICY below). If set to “no”, preserve backups according to target_preserve_min only. Defaults to “no”.
Preserve all backups for a minimum amount of hours (h), days (d), weeks (w), months (m) or years (y), regardless of how many there are. If set to “all”, preserve all backups forever. If set to “latest”, always preserve the latest backup (useful in conjunction with "target_preserve no", if you want to keep the latest backup only). If set to “no”, only the backups following the target_preserve policy are created. Defaults to “all”.
Set retention policy for archives ("btrbk archive" command), with same semantics as target_preserve, target_preserve_min.
Defines on what day a backup/snapshot is considered as a weekly backup. Defaults to “sunday”.
Add the current section (volume, subvolume or target) to a user-defined group, which can be used as filter for several btrbk commands.
Absolute path to a ssh identity file (private key). Note that if the private key is password protected, btrbk will prompt for user input, which is usually not desired.
Remote username for ssh. Defaults to “root”. Note that you will have to make sure that the remote user is able to run "/sbin/btrfs" (which needs root privileges).
Port to connect to on the remote host. Defaults to “default” (the port specified in ssh_config, which defaults to 22).
Enables or disables the compression of ssh connections. Defaults to “no”.
Selects the cipher specification for encrypting the session (comma-separated list of ciphers in order of preference). See the "−c cipher_spec" option in ssh(1) for more information. Defaults to “default” (the ciphers specified in ssh_config).
Compress the btrfs send stream before transferring it from/to remote locations. Defaults to “no”. If enabled, make sure that <compress_command> is available on the source and target hosts. Supported <compress_command>: gzip, pigz, bzip2, pbzip2, xz, lzo, lz4.
Compression level for the specified <compress_command>. Refer to the related man-page for details (usually [1..9], where 1 means fastest compression). Defaults to “default” (the default compression level of <compress_command>).
Number of threads to use for <compress_command>. Only supported for "pigz", "pbzip2" and recent versions of "xz".
Limit the transfer to a maximum of <rate> bytes per second. A suffix of "k", "m", "g", or "t" can be added to denote kilobytes (*1024), megabytes, and so on. Defaults to “no”. If enabled for remote sources, make sure that the "pv" command is available on the source host.
Create lockfile <file> on startup; checks lockfile before running any btrfs commands (using perl "flock"), and exits if the lock is held by another btrbk instance. Ignored on dryrun (−n, −−dry−run). See also −−lockfile command-line option.
If set, make sure the deletion of snapshot and backup subvolumes are committed to disk when btrbk terminates. Defaults to “no”.
Backend filesystem utilities to be used for btrfs specific operations. The default “btrfs-progs” simply executes btrfs(8) commands groups (e.g. "btrfs subvolume show").
If set to “btrfs-progs-btrbk”, specific btrfs(8) commands groups needs to be separated by a dash instead of a whitespace (e.g. "btrfs-subvolume-show" instead of "btrfs subvolume show"). Useful for setting suid or file capabilities (setcap) on specific btrfs commands, as implemented in <https://github.com/digint/btrfs-progs-btrbk>.
If set to “btrfs-progs-sudo”, btrfs commands are prefixed with "sudo -n" (e.g. "sudo -n btrfs subvolume show" instead of "btrfs subvolume show"). Make sure to have apropriate (root) permissions for "btrfs" command groups in /etc/sudoers.
For convenience, it is also possible to set backend_local or backend_remote options, which will override the backend only for local or remote sources/targets (e.g. "backend_remote btrfs-progs-btrbk").
btrbk uses separate retention policies for snapshots and backups, which are defined by the snapshot_preserve_min, snapshot_preserve, target_preserve_min, target_preserve, and the preserve_day_of_week configuration options.
Within this section, any statement about "backups" is always valid for backups as well as snapshots, referring to target_preserve or snapshot_preserve respectively.
The format for <retention_policy> is:
[<hourly>h] [<daily>d] [<weekly>w] [<monthly>m] [<yearly>y]
With the following semantics:
Defines how many hours back hourly backups should be preserved. The first backup of an hour is considered an hourly backup. Note that if you use <hourly> scheduling, make sure to also set timestamp_format to “long” or “long−iso”, or the scheduler will interpret the time as "00:00" (midnight).
Defines how many days back daily backups should be preserved. The first backup of a day is considered a daily backup.
Defines how many weeks back weekly backups should be preserved. The first daily backup created at preserve_day_of_week (or the first backup in this week if none was made on the exact day) is considered as a weekly backup.
Defines how many months back monthly backups should be preserved. Every first weekly backup in a month is considered a monthly backup.
Defines for how many years back yearly backups should be preserved. Every first monthly backup in a year is considered a yearly backup.
Use an asterisk for “all” (e.g. "target_preserve 60d *m" states: "preserve daily backups for 60 days back, and all monthly backups").
The reference time (which defines the beginning of a day, week, month or year) for all date/time calculations is the local time of the host running btrbk.
If you run a setup with several btrbk instances (e.g. one snapshot-only instance per remote client, and a separate fetch-only instance on the backup server), it makes perfectly sense to run btrbk with different local time on the clients, in order to make sure the backups from all the remote hosts are preserved for "midnight", and not at "00:00 UTC" (which would be "14:00" in Honolulu). If you want this behaviour, do NOT use "timestamp_format long−iso".
If "timestamp_format long−iso" is set, running btrbk from different time zones leads to different interpretation of "first in day, week, month, or year". Make sure to run btrbk with the same time zone on every host, e.g. by setting the TZ environment variable (see tzset(3)).
Backup to a btrfs filesystem, using "btrfs send/receive". This is the recommended (standard) target type. The <target−directory> must be an absolute path and point to a btrfs volume (or subvolume), or to a directory within a subvolume. See btrfs−send(8), btrfs−receive(8).
Backup to a raw (filesystem independent) file from the output of btrfs−send(8), with optional compression and encryption.
Note that the target preserve mechanism is currently disabled for raw backups (btrbk does not delete any raw files)!
Additional options for raw targets:
raw_target_block_size <number> (defaults to 128K)
Raw targets get an extra file suffix in the format:
The <parent_uuid> is only set on incremental backups, and points to the <received_uuid> of the previous backup in a incremental backup chain.
For incremental backups ("incremental yes"), please note that:
As soon as a single incremental backup file is lost or corrupted, all later incremental backups become invalid, as there is no common parent for the subsequent incremental images anymore. This might be a good compromise for a vacation backup plan, but for the long term make sure that a non-incremental backup is triggered from time to time.
There is currently no support for rotation of incremental backups: if incremental is set, a full backup must be triggered manually from time to time in order to be able to delete old backups.
Please refer to the btrbk project page http://digint.ch/btrbk/ for further details.
Axel Burri <firstname.lastname@example.org>