'\" t .\" Title: btrbk .\" Author: [see the "AUTHOR(S)" section] .\" Generator: Asciidoctor 2.0.17 .\" Date: 2022-10-23 .\" Manual: Btrbk Manual .\" Source: Btrbk 0.32.5 .\" Language: English .\" .TH "BTRBK" "1" "2022-10-23" "Btrbk 0.32.5" "Btrbk Manual" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 .nh .ad l .de URL \fI\\$2\fP <\\$1>\\$3 .. .als MTO URL .if \n[.g] \{\ . mso www.tmac . am URL . ad l . . . am MTO . ad l . . . LINKSTYLE blue R < > .\} .SH "NAME" btrbk \- backup tool for btrfs subvolumes .SH "SYNOPSIS" .sp .nf btrbk [\-h|\-\-help] [\-\-version] [\-c|\-\-config ] [\-n|\-\-dry\-run] [\-\-exclude ] [\-p|\-\-preserve] [\-\-preserve\-snapshots] [\-\-preserve\-backups] [\-v|\-\-verbose] [\-q|\-\-quiet] [\-l|\-\-loglevel ] [\-t|\-\-table] [\-L|\-\-long] [\-1|\-\-single\-column] [\-\-format ] [\-\-pretty] [\-S|\-\-print\-schedule] [\-\-progress] [\-\-lockfile ] [\-\-override =] [[\-\-] ...] .fi .br .SH "DESCRIPTION" .sp \fBbtrbk\fP is a backup tool for btrfs subvolumes, taking advantage of btrfs specific capabilities to create atomic snapshots and transfer them incrementally to a target btrfs filesystem. It is able to perform backups from one source to multiple destinations. .sp For most operations, \fBbtrbk\fP requires \fIroot privileges\fP to run correctly. Alternatively, consider using "btrfs\-progs\-sudo" or "btrfs\-progs\-btrbk" backends, both of which allows you to run btrbk as a regular user. Refer to configuration option \fIbackend\fP in btrbk.conf(5) for more details. .SS "Snapshots and Backups" .sp Snapshots as well as backup subvolumes are created in the form: .sp .if n .RS 4 .nf .fam C .[_N] .fam .fi .if n .RE .sp Where \fI\fP is identical to the source subvolume name, unless the configuration option \fIsnapshot_name\fP is set. \fI\fP is a timestamp describing the creation time (local time of the host running btrbk) of the snapshot/backup. The format can be configured using the \fItimestamp_format\fP option, refer to btrbk.conf(5) for details. If multiple snapshots/backups are created on the same date/time, \fIN\fP will be incremented on each snapshot, starting at 1. .sp If a snapshot or backup does not match the naming scheme above (e.g. if it has been renamed manually), btrbk will leave it untouched. .sp Note that in btrfs terminology, a \fIsnapshot\fP is a \(lqsubvolume with a given initial content of the original subvolume\(rq (showing a parent\-uuid, see btrfs\-subvolume(8)), and they can be read\-write (default) or read\-only. In btrbk terminology, \fIsnapshot\fP means \(lqread\-only btrfs snapshot\(rq, and \fIbackup\fP means \(lqread\-only subvolume created with send/receive\(rq (showing a received\-uuid). .SH "OPTIONS" .sp \-h, \-\-help .RS 4 Prints the synopsis and a list of the commands. .RE .sp \-\-version .RS 4 Prints the btrbk version. .RE .sp \-c, \-\-config .RS 4 Read the configuration from . .RE .sp \-n, \-\-dry\-run .RS 4 Don\(cqt run anything that would alter the filesystem, just show the snapshots and backup subvolumes that would be created/deleted by the \fBrun\fP, \fBsnapshot\fP, \fBresume\fP, \fBprune\fP, \fBarchive\fP and \fBclean\fP commands. Use in conjunction with \fI\-l debug\fP to see the btrfs commands that would be executed. .RE .sp \-\-exclude .RS 4 Exclude configured sections matching \fI\fP. See FILTER STATEMENTS below. .RE .sp \-p, \-\-preserve .RS 4 Preserve all snapshots and backups. Skips deletion of any snapshots and backups, even if specified in the configuration file (shortcut for "\-\-preserve\-snapshots \-\-preserve\-backups"). .RE .sp \-\-preserve\-snapshots .RS 4 Preserve all snapshots. Skips deletion of any snapshots, even if specified in the configuration file. .RE .sp \-\-preserve\-backups .RS 4 Preserve all backups. Skips deletion of any backups, even if specified in the configuration file. .RE .sp \-\-wipe .RS 4 Ignore configured snapshot retention policy, delete all but the latest snapshots instead. All snapshots needed for incremental backup (latest common) are also preserved. Useful if you are getting low on disk space (ENOSPC). .RE .sp \-v, \-\-verbose .RS 4 Increase the logging level, see "\-\-loglevel". .RE .sp \-q, \-\-quiet .RS 4 Quiet operation. If set, btrbk does not print the summary after executing the \fBrun\fP, \fBsnapshot\fP, \fBresume\fP, \fBprune\fP, or \fBarchive\fP commands. .RE .sp \-l, \-\-loglevel .RS 4 Set the level of verbosity for the stderr logging. Accepted levels are: error, warn, info, debug, and trace. Default is info. .RE .sp \-t, \-\-table .RS 4 Print output in table format (shortcut for "\-\-format=table"). .RE .sp \-L, \-\-long .RS 4 Print output in long table format (shortcut for "\-\-format=long"). .RE .sp \-1, \-\-single\-column .RS 4 Print output as single column (not available for all commands). .RE .sp \-\-format table|long|raw|col:[h:] .RS 4 Print output in specified format. If set to "raw", prints space\-separated, quoted key=value pairs (machine readable). .sp If set to "col:", prints only the specified (comma\-separated list). Header lines are ommitted if the "h:" modifier is present. Columns prefixed with "\-" are collapsed if empty. Columns postfixed with ":RALIGN" are right\-aligned. .RE .sp \-\-pretty .RS 4 Print table output with lowercase, underlined column headings (instead of single\-line uppercase headings). .RE .sp \-S, \-\-print\-schedule .RS 4 Print detailed scheduler information on \fBrun\fP, \fBsnapshot\fP, \fBresume\fP, \fBprune\fP and \fBarchive\fP commands. Use the \fI\-\-format\fP command line option to switch between different output formats. .RE .sp \-\-progress .RS 4 Show progress bar on send\-receive operation. Requires "mbuffer" command (version >= 20180505) installed on the host running btrbk. .RE .sp \-\-lockfile .RS 4 Create lockfile on startup; checks lockfile before running any btrfs commands (using perl "flock"), and exits if the lock is held by another btrbk instance. Overrides configuration option "lockfile". Ignored on dryrun (\fI\-n\fP, \fI\-\-dry\-run\fP). .RE .sp \-\-override = .RS 4 Override a configuration option with . Globally, for ALL contexts. Use with care! .RE .SH "COMMANDS" .SS "Actions" .sp The following commands are used to create snapshots and/or backups. All actions can operate in dry\-run mode (\fI\-n\fP, \fI\-\-dry\-run\fP). Use the \fI\-\-format\fP command line option to switch between different output formats. .sp See section RETENTION POLICY in \fBbtrbk.conf\fP(5) for information on configuring the retention policy. .sp \fBrun\fP [filter...] .RS 4 Perform snapshot and backup operations as specified in the configuration file. If the optional [filter...] arguments are present, snapshots and backups are only performed for the subvolumes/targets matching a filter statement (see FILTER STATEMENTS below). .sp \fBStep 0: Read Data\fP .RS 4 Read information from the source and target btrfs filesystems in order to perform sanity checks and identify parent/child and received\-from relationships. .RE .sp \fBStep 1: Create Snapshots\fP .RS 4 If the checks succeed, btrbk creates snapshots for the source subvolumes specified in the configuration file, according to the \fIsnapshot_create\fP option. .RE .sp \fBStep 2: Create Backups\fP .RS 4 For each specified target, btrbk creates the backups as follows: After comparing the backups to the source snapshots, btrbk transfers all missing snapshots needed to satisfy the configured target retention policy, incrementally from the latest common parent subvolume found. If no common parent subvolume is found (or if the \fIincremental\fP option is set to \(lqno\(rq), a full (non\-incremental) backup is created. .RE .sp \fBStep 3: Delete Backups\fP .RS 4 Unless the \-p, \-\-preserve or \-\-preserve\-backups option is set, backup subvolumes that are not preserved by their configured retention policy will be deleted. Note that the latest snapshot/backup pair are always preserved, regardless of the retention policy. .RE .sp \fBStep 4: Delete Snapshots\fP .RS 4 Unless the \-p, \-\-preserve or \-\-preserve\-snapshots option is set, snapshots that are not preserved by their configured retention policy will be deleted. Note that the latest snapshot (the one created in step 1) as well as the latest snapshot/backup pair are always preserved, regardless of the retention policy. If any target is unreachable or has errors, all snapshots are preserved in order not to break the incremental chain. .RE .RE .sp \fBdryrun\fP [filter...] .RS 4 Don\(cqt run any btrfs commands that would alter the filesystem, just show the snapshots and backup subvolumes that would be created/deleted by the \fBrun\fP command. Use in conjunction with \fI\-l debug\fP to see the btrfs commands that would be executed. .RE .sp \fBsnapshot\fP [filter...] .RS 4 Snapshot only: skips backup creation and deletion (steps 2 and 3). Use in conjunction with \-p, \-\-preserve (or \-\-preserve\-snapshots) if you also want to skip snapshot deletion (step 4). .sp Note that snapshot deletion is skipped if the target is not accessible, as it is still required in order to determine the latest snapshot/backup pair (which is always preserved, regardless of the retention policy). .RE .sp \fBresume\fP [filter...] .RS 4 Resume backups: skips snapshot creation (step 1), transfers and deletes snapshots/backups in order to satisfy their configured retention policy. Use in conjunction with \-p, \-\-preserve, \-\-preserve\-backups, \-\-preserve\-snapshots if you want to skip backup and/or snapshot deletion (steps 3, 4). .RE .sp \fBprune\fP [filter...] .RS 4 Prune snapshots and backups: skips snapshot and backup creation (steps 1, 2), only deletes snapshots and backups in order to satisfy their configured retention policy. Useful for cleaning the disk after changing the retention policy. Use in conjunction with \-\-preserve\-backups, \-\-preserve\-snapshots if you want to skip backup or snapshot deletion (steps 3, 4). .sp Note that deletion is skipped if source or target is not accessible, as it is still required in order to determine the latest snapshot/backup pair (which is always preserved, regardless of the retention policy). .RE .sp \fBarchive\fP [\-\-raw] .RS 4 Recursively copy all subvolumes created by btrbk from to directory, optionally rescheduled using \fIarchive_preserve_*\fP configuration options. Also creates directory tree on . Useful for creating extra archive copies (clones) from your backup disks. Note that you can continue using btrbk after swapping your backup disk with the archive disk. .sp If you want to use nested subvolumes on the target filesystem, you need to create them by hand (e.g. by running "btrfs subvolume create /dir"). Check the output of \-\-dry\-run if unsure. .sp Note that this feature needs a \fBlinux kernel >=4.4\fP to work correctly! .sp If \fI\-\-raw\fP option is set, creates raw targets (experimental, see btrbk.conf(5), TARGET TYPES). .RE .sp \fBclean\fP [filter...] .RS 4 Delete incomplete (garbled) backups. Incomplete backups can be left behind on network errors or kill signals while a send/receive operation is ongoing, and are identified by the "received_uuid" flag not being set on a target (backup) subvolume. .RE .sp The following table gives a quick overview of the action commands and resulting snapshot creation (S+), backup creation (B+), snapshot deletion (S\-), and backup deletion (B\-): .sp .if n .RS 4 .nf .fam C Command Option S+ B+ S\- B\- \-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\- run x x x x run \-\-preserve x x run \-\-preserve\-snapshots x x x run \-\-preserve\-backups x x x snapshot x x snapshot \-\-preserve x resume x x x resume \-\-preserve x resume \-\-preserve\-snapshots x x resume \-\-preserve\-backups x x prune x x prune \-\-preserve\-snapshots x prune \-\-preserve\-backups x .fam .fi .if n .RE .SS "Informative Commands" .sp The following commands are informative only, and will not alter the file system. .sp \fBstats\fP [filter...] .RS 4 Print statistics of snapshot and backup subvolumes. Optionally filtered by [filter...] arguments (see FILTER STATEMENTS below). .RE .sp \fBlist\fP [filter...] .RS 4 Print information defined by in a tabular form. Optionally filtered by [filter...] arguments (see FILTER STATEMENTS below). .sp Available subcommands (default \(lqall\(rq): .sp \fBall\fP .RS 4 List all snapshots and backups created by btrbk. .RE .sp \fBsnapshots\fP .RS 4 List all snapshots created by btrbk. .RE .sp \fBbackups\fP .RS 4 List all backups (and correlated snapshots) created by btrbk. .RE .sp \fBlatest\fP .RS 4 List most recent common snapshot/backup pair, or most recent snapshot if no common found. .RE .sp \fBconfig\fP .RS 4 List configured source/snapshot/target relations. .RE .sp \fBsource\fP .RS 4 List configured source/snapshot relations. .RE .sp \fBvolume\fP .RS 4 List configured volume sections. .RE .sp \fBtarget\fP .RS 4 List configured targets. .RE .sp Use the \fI\-\-format\fP command line option to switch between different output formats. .RE .sp \fBusage\fP [filter...] .RS 4 Print filesystem usage information for all source/target volumes, optionally filtered by [filter...] arguments (see FILTER STATEMENTS below). Note that the "free" value is an estimate of the amount of data that can still be written to the file system. .RE .sp \fBorigin\fP .RS 4 Print the subvolume origin tree: Shows the parent\-child relationships as well as the received\-from information. Use the \fI\-\-format\fP command line option to switch between different output formats. .RE .sp \fBdiff\fP .RS 4 List the modified files since generation (transid) of subvolume in subvolume . Columns: .sp .if n .RS 4 .nf .fam C SIZE file was modified for a total of SIZE bytes COUNT file was modified in COUNT generations FLAGS "+" file accessed at offset 0 (at least once) "c" COMPRESS flag is set (at least once) "i" INLINE flag is set (at least once) .fam .fi .if n .RE .RE .sp \fBextents\fP [diff] ... [exclusive ...] .RS 4 Print accurate disk space usage and diff based on extent data (FIEMAP ioctl, slow!). .sp Subvolumes following the \fIexclusive\fP keyword are added to a separate set, and additional set\-exclusive data is printed at the end of the list. This gives a hint of how much data will be freed if deleting all subvolumes in the set. Example: .sp .if n .RS 4 .nf .fam C btrbk extents diff /backup/data.* exclusive /backup/data.2010* .fam .fi .if n .RE .sp The EXCLUSIVE column shows the set\-exclusive data of all other listed (!) subvolumes (relative complement of block regions). Provided that all related subvolumes (holding references to extents) are also listed, this amount of disk space would be freed when deleting the subvolume. .sp The DIFF column shows the data added to the previous subvolume (relative complement of block regions). .sp If called with the \fI\-\-related\fP option, btrbk also lists all related subvolumes. This is not recommended for backups, as parent\-uuid relations break for received subvolumes as soon as an intermediate subvolume is deleted. .sp Note that reading all extents is a disk\-intensive task, expect long execution times and high ram usage. Consider setting \fIcache_dir\fP. .RE .sp \fBls\fP |... .RS 4 List all btrfs subvolumes below . Use the \fI\-\-format\fP command line option to switch between different output formats. See lsbtr(1). .RE .sp \fBconfig\fP print|print\-all .RS 4 Prints the parsed configuration file. .RE .SH "FILTER STATEMENTS" .sp Filter arguments are accepted in form: .sp .RS 4 Matches the \fIgroup\fP configuration option of \fIvolume\fP, \fIsubvolume\fP or \fItarget\fP sections. .RE .sp [:] .RS 4 Matches the \fIhostname\fP portion from \fI\fP of \fIvolume\fP or \fItarget\fP sections. .RE .sp | .RS 4 Matches \fIvolume\fP, \fIsubvolume\fP or \fItarget\fP sections by either relative or absolute path (if starting with "/" or "ssh://" or ":/"), accepting wildcard character "*". Relative paths are matched against the end of the pathname. Either: .sp .RS 4 Matches \fIvolume\fP sections. .RE .sp / .RS 4 Matches \fIsubvolume\fP sections. .RE .sp // .RS 4 Matches \fIsubvolume\fP sections defining snapshots with the configured \fIsnapshot_dir\fP and \fIsnapshot_name\fP. .RE .sp .RS 4 Matches \fItarget\fP sections. .RE .sp / .RS 4 Matches \fItarget\fP sections within \fIsubvolume\fP sections defining snapshots with the configured \fIsnapshot_name\fP. .RE .sp Accepted formats for \fI\fP are: .sp .if n .RS 4 .nf .fam C ssh://[:]/ : .fam .fi .if n .RE .RE .sp Note that for \fBrun\fP and \fBsnapshot\fP commands, a filter matching a \fItarget\fP configuration section also enables snapshot creation of the surrounding \fIsubvolume\fP section. If this is not desired, consider running \fBsnapshot\fP and \fBresume\fP commands separately. .sp Filter statements can match multiple times (e.g. on group as well as host name). In such a case, all matches are processed. .SH "FILES" .sp \f(CR/etc/btrbk.conf\fP, \f(CR/etc/btrbk/btrbk.conf\fP .RS 4 Default configuration file. The file format and configuration options are described in \fBbtrbk.conf\fP(5). .RE .SH "EXIT STATUS" .sp \fBbtrbk\fP returns the following error codes: .sp 0 .RS 4 No problems occurred. .RE .sp 1 .RS 4 Generic error code. .RE .sp 2 .RS 4 Parse error: when parsing command\-line options or configuration file. .RE .sp 3 .RS 4 Lockfile error: if lockfile is present on startup. .RE .sp 10 .RS 4 Backup abort: At least one backup task aborted. .RE .sp 255 .RS 4 Script error. .RE .SH "AVAILABILITY" .sp Please refer to the btrbk project page \fB\c .URL "https://digint.ch/btrbk/" "" "\fP" for further details. .SH "SEE ALSO" .sp \fBbtrbk.conf\fP(5), \fBbtrfs\fP(8) .sp For more information about btrfs and incremental backups, see the web site at \c .URL "https://btrfs.wiki.kernel.org/index.php/Incremental_Backup" "" "" .SH "AUTHOR" .sp Axel Burri \c .MTO "axel\(attty0.ch" "" ""