1BTRBK.CONF(5) Btrbk Manual BTRBK.CONF(5)
2
3
4
6 btrbk.conf - btrbk configuration file
7
9 /etc/btrbk.conf
10 /etc/btrbk/btrbk.conf
11
13 The btrbk configuration file specifies which btrfs subvolumes on the
14 filesystem are to be processed, what target subvolumes should be used
15 to create the backups, and where the snapshots should be generated. The
16 retention policy, as well as most other options can be defined either
17 globally or within a section.
18
19 The options specified always apply to the last section encountered,
20 superseding the values set in upper-level sections. This means that
21 global options must be set before any sections are defined.
22
23 Blank lines are ignored. A hash character (#) starts a comment
24 extending until end of line.
25
27 volume <volume-directory>|<url> (optional)
28 Absolute path pointing to a btrfs file system containing the source
29 subvolume(s) to be backed up. Usually the mount point of a btrfs
30 filesystem mounted with the subvolid=5 option.
31
32 subvolume <subvolume-name>
33 Subvolume to be backed up, relative to the <volume-directory> of
34 the volume section, or absolute if the volume section is omitted.
35 Accepts wildcard character "*".
36
37 Note that if this subvolume is btrfs root (id=5), it needs to have
38 a valid UUID, which is not the case for file systems created with
39 btrfs-progs < 4.16.
40
41 target [send-receive|raw] <target-directory>|<url>
42 Target directory where the backup subvolumes are to be created. The
43 optional target type defaults to “send-receive”, see TARGET TYPES
44 below for details.
45
46 Multiple target sections are allowed, in any context: a target
47 defined in volume or global context will be used for all underlying
48 subvolume sections (hint: run "btrbk list" or "btrbk config print"
49 to see the resulting configuration).
50
51 If a <url> is specified, btrbk actions (shell commands) are executed
52 remotely via ssh, using the SSH Options described below. Accepted
53 formats are:
54
55 ssh://<hostname>[:<port>]/<directory>
56 <hostname>:<directory>
57
58 Where <hostname> is either a host name, an IPv4 address in
59 dotted-decimal form, or an IP literal encapsulated within square
60 brackets (e.g. "[2001:db8::7]").
61
62 If you are connecting to virtual machines, consider configuring several
63 volume sections for a <hostname>, with distinct <port> numbers for each
64 machine.
65
67 The options described here can be specified in global context as well
68 as volume, subvolume and target sections, unless stated otherwise.
69
70 Basic Options
71 timestamp_format short|long|long-iso
72 Timestamp format used as postfix for new snapshot subvolume names.
73 Defaults to “long”.
74
75 short
76 YYYYMMDD[_N] (e.g. "20150825", "20150825_1")
77
78 long
79 YYYYMMDD<T>hhmm[_N] (e.g. "20150825T1531")
80
81 long-iso
82 YYYYMMDD<T>hhmmss±hhmm[_N] (e.g.
83 "20150825T153123+0200")
84
85 Note that a postfix "_N" is appended to the timestamp if a snapshot
86 or backup already exists with the timestamp of current date/time.
87
88 Use “long-iso” if you want to make sure that btrbk never creates
89 ambiguous time stamps (which can happen if multiple snapshots are
90 created during a daylight saving time clock change).
91
92 Note that using “long-iso” has implications on the scheduling, see
93 Reference Time below.
94
95 snapshot_dir <directory>
96 Directory in which the btrfs snapshots are created, relative to
97 <volume-directory> of the volume section, or absolute if the volume
98 section is omitted. Note that btrbk does not automatically create
99 this directory, and the snapshot creation will fail if it is not
100 present.
101
102 snapshot_name <basename>
103 Base name of the created snapshot (and backup). This option is only
104 valid in the subvolume section. Defaults to <subvolume-name>.
105
106 snapshot_create always|onchange|ondemand|no
107 If set to “always”, snapshots are always created. If set to
108 “onchange”, snapshots are only created if the last snapshot is not
109 up-to-date, i.e. the source subvolume has changed (more precisely:
110 the btrfs generation has been increased) since the last snapshot
111 was created. If set to “ondemand”, snapshots are only created if at
112 least one target subvolume is reachable (useful if you are tight on
113 disk space and you only need btrbk for backups to an external disk
114 which is not always connected). If set to “no”, the snapshots are
115 never created (useful if another instance of btrbk is taking care
116 of snapshot creation). Defaults to “always”.
117
118 incremental yes|no|strict
119 If set, incremental backups are created. If set to “strict”,
120 non-incremental (initial) backups are never created, and
121 incremental backups are restricted to related parents (by
122 parent-uuid relationship). Defaults to “yes”.
123
124 Note that even if the parent-uuid chain is broken, snapshots and
125 backups can still share data (which is especially true for backups
126 created with incremental option enabled), and are perfectly
127 suitable as parents for incremental send-receive operations. But as
128 btrbk can not be certain about this, such operations are disallowed
129 in "incremental strict" mode.
130
131 noauto yes|no
132 If set, the context is skipped by all btrbk actions unless
133 explicitly enabled by a matching btrbk <filter> command line
134 argument (e.g. "btrbk run myfilter").
135
136 Grouping Options
137 group <group-name> [<group-name>]...
138 Add the current section (volume, subvolume or target) to
139 user-defined groups, which can be used as filter for most btrbk
140 commands (see btrbk(1) FILTER STATEMENTS). This option can be set
141 multiple times within the same context.
142
143 Retention Policy Options
144 preserve_day_of_week monday|tuesday|...|sunday
145 Defines on what day a snapshot/backup is considered to be a
146 "weekly" backup. Weekly, monthly and yearly backups are preserved
147 on this day of week (see RETENTION POLICY below). Defaults to
148 “sunday”.
149
150 preserve_hour_of_day [0..23]
151 Defines after what time (in full hours since midnight) a
152 snapshot/backup is considered to be a "daily" backup. Daily,
153 weekly, monthly and yearly backups are preserved on this hour (see
154 RETENTION POLICY below). Ignored on snapshots or backups without
155 time information (timestamp_format short). Defaults to “0”.
156
157 snapshot_preserve no|<retention_policy>
158 Set retention policy for snapshots (see RETENTION POLICY below). If
159 set to “no”, preserve snapshots according to snapshot_preserve_min
160 only. Defaults to “no”.
161
162 Note that snapshot_preserve has no effect if snapshot_preserve_min
163 is set to “all” (the default).
164
165 snapshot_preserve_min all|latest|<number>{h,d,w,m,y}
166 Preserve all snapshots for a minimum amount of hours (h), days (d),
167 weeks (w), months (m) or years (y), regardless of how many there
168 are. If set to “all”, preserve all snapshots forever. If set to
169 “latest”, preserve latest snapshot. Defaults to “all”.
170
171 target_preserve no|<retention_policy>
172 Set retention policy for backups (see RETENTION POLICY below). If
173 set to “no”, preserve backups according to target_preserve_min
174 only. Defaults to “no”.
175
176 Note that target_preserve has no effect if target_preserve_min is
177 set to “all” (the default).
178
179 target_preserve_min all|latest|no|<number>{h,d,w,m,y}
180 Preserve all backups for a minimum amount of hours (h), days (d),
181 weeks (w), months (m) or years (y), regardless of how many there
182 are. If set to “all”, preserve all backups forever. If set to
183 “latest”, always preserve the latest backup (useful in conjunction
184 with "target_preserve no", if you want to keep the latest backup
185 only). If set to “no”, only the backups following the
186 target_preserve policy are created. Defaults to “all”.
187
188 archive_preserve no|<retention_policy>
189 Set retention policy for archives ("btrbk archive" command), with
190 same semantics as target_preserve.
191
192 archive_preserve_min all|latest|no|<number>{h,d,w,m,y}
193 Set retention policy for archives ("btrbk archive" command), with
194 same semantics as target_preserve_min.
195
196 archive_exclude <pattern>
197 Exclude subvolumes matching <pattern> from archiving. The pattern
198 accepts wildcard character "*", and is matched against the end of
199 the pathname.
200
201 SSH Options
202 ssh_identity <file>
203 Absolute path to a ssh identity file (private key). Note that if
204 the private key is password protected, btrbk will prompt for user
205 input, which is usually not desired.
206
207 ssh_user <username>
208 Remote username for ssh. Defaults to “root”. Make sure the remote
209 user is able to run "btrfs" with root privileges (see option
210 backend for details).
211
212 ssh_compression yes|no
213 Enables or disables the compression of ssh connections. Defaults to
214 “no”. Note that if stream_compress is enabled, ssh compression will
215 always be disabled for send/receive operations.
216
217 ssh_cipher_spec <cipher_spec>
218 Selects the cipher specification for encrypting the session
219 (comma-separated list of ciphers in order of preference). See the
220 "-c cipher_spec" option in ssh(1) for more information. Defaults to
221 “default” (the ciphers specified in ssh_config).
222
223 Previous versions btrbk allowed you to set a ssh_port option, this has
224 been dropped in favor of the ssh://hostname:port notation in the volume
225 and target sections. If you want to set a global port for all SSH
226 connections to remote hosts, set the “Port” option in ssh_config(5).
227
228 Data Stream Options
229 stream_compress <compress_command>|no
230 Compress the btrfs send stream before transferring it from/to
231 remote locations. Defaults to “no”. If enabled, make sure that
232 <compress_command> is available on the source and target hosts.
233 Supported <compress_command>: gzip, pigz, bzip2, pbzip2, xz, lzo,
234 lz4, zstd.
235
236 stream_compress_level default|<number>
237 Compression level for the specified <compress_command>. Refer to
238 the related man-page for details (usually [1..9], where 1 means
239 fastest compression). Defaults to “default” (the default
240 compression level of <compress_command>).
241
242 stream_compress_long default|<number>
243 Enable long distance matching for the specified <compress_command>.
244 Refer to the related man-page for details. Only supported for
245 "zstd".
246
247 stream_compress_threads default|<number>
248 Number of threads to use for <compress_command>. Only supported for
249 "pigz", "pbzip2", "zstd" and recent versions of "xz".
250
251 stream_compress_adapt default|<number>
252 Enable adaptive compression for <compress_command>. Only supported
253 for "zstd" (version >= 1.3.6).
254
255 stream_buffer <size>|no
256 Add a buffer to the btrfs send stream (locally, on uncompressed
257 data), with a maximum size of <size>. This can give a speed
258 improvement (measured up to 20%) on both local or remote
259 operations, but also increases system load. A suffix of "k", "m",
260 "g", or "%" can be added to <size> to denote kilobytes (*1024),
261 megabytes, gigabytes, or a percentage of total physical memory.
262 Defaults to “no”.
263
264 If enabled, make sure that the "mbuffer" command (at least version
265 20180505) is available on the host running btrbk. As of
266 btrbk-0.29.0, mbuffer(1) is used for both rate_limit and
267 stream_buffer options:
268
269 mbuffer [-m <stream_buffer>] [-r <rate_limit>]
270
271 Note that mbuffer(1) always reads defaults from "/etc/mbuffer.rc"
272 and "~/.mbuffer.rc".
273
274 Leave this option disabled if your main concern is a stable backup
275 process: while recent versions of mbuffer have proven reliable, it
276 is often desirable to keep things simple rather than adding an
277 additional, multi-threaded process to the command pipe.
278
279 stream_buffer_remote <size>|no
280 Add a buffer on remote hosts (either source or target). Defaults to
281 “no”.
282
283 Enable this if you prefer buffering on the remote side, or even on
284 both sides: reasons for this depend on available memory, disk and
285 cpu performance (btrfs send/receive, compression), as well as
286 networking constraints.
287
288 rate_limit <rate>|no
289 Limit the read rate of the btrfs send stream to <rate> bytes per
290 second (locally, on uncompressed send stream). A suffix of "k",
291 "m", "g", or "t" can be added to denote kilobytes (*1024),
292 megabytes, and so on. Defaults to “no”. Note that rate_limit
293 implicitly adds a stream buffer (see stream_buffer option above).
294
295 rate_limit_remote <rate>|no
296 Add rate limit on remote hosts (either source or target). Defaults
297 to “no”. Note that it usually does not make much sense to enable
298 both rate_limit and rate_limit_remote.
299
300 System Options
301 transaction_log <file>|no
302 If set, all transactions (snapshot create, subvolume send-receive,
303 subvolume delete) as well as abort messages are logged to <file>,
304 in a space-separated table format: "localtime type status
305 target_url source_url parent_url message".
306
307 transaction_syslog <facility>|no
308 If set, all transactions (as described in transaction_log above)
309 are logged to syslog. The program name used in the messages is
310 "btrbk". Accepted parameters for <facility>: user, mail, daemon,
311 auth, lpr, news, cron, authpriv, local0..local7.
312
313 lockfile <file>|no
314 Create lockfile <file> on startup; checks lockfile before running
315 any btrfs commands (using perl "flock"), and exits if the lock is
316 held by another btrbk instance. Ignored on dryrun (-n, --dry-run).
317 See also --lockfile command-line option.
318
319 backend <backend>
320 Backend filesystem utilities to be used for btrfs specific
321 operations. Available backends:
322
323 btrfs-progs
324 Default backend, btrfs commands are called as specified in
325 btrfs(8) (e.g. "btrfs subvolume show").
326
327 btrfs-progs-btrbk
328 btrfs commands are separated by a dash instead of a whitespace
329 (e.g. "btrfs-subvolume-show" instead of "btrfs subvolume
330 show"). Useful for setting suid or file capabilities (setcap)
331 on specific btrfs commands, as implemented in
332 https://github.com/digint/btrfs-progs-btrbk.
333
334 btrfs-progs-sudo
335 btrfs commands are prefixed with "sudo -n" (e.g. "sudo -n btrfs
336 subvolume show" instead of "btrfs subvolume show"). Make sure
337 to have appropriate (root) permissions for the "btrfs" command
338 groups as well as the "readlink" and "test" commands in
339 /etc/sudoers.
340
341 btrfs-progs-doas
342 Similar to btrfs-progs-sudo, using prefix "doas -n".
343
344 If you want to set this option for local or remote hosts only, set
345 backend_local or backend_remote (e.g. "backend_remote
346 btrfs-progs-btrbk").
347
348 If you want to set this option for regular (non-root) user only,
349 set backend_local_user.
350
351 compat busybox|no
352 If set to “busybox”, use busybox compatible commands. Defaults to
353 “no”. If you want to set this option for local or remote hosts
354 only, you can set compat_local or compat_remote (e.g.
355 "compat_remote busybox").
356
357 cache_dir <directory>
358 If set, cache extent maps for the "btrbk extents" command.
359
360 Btrfs Specific Options
361 btrfs_commit_delete after|each|no
362 If set, make sure the deletion of snapshot and backup subvolumes
363 are committed to disk when btrbk terminates. Defaults to “no”.
364
365 incremental_prefs <list-spec>[:<amount>]...
366 Specify the preferences to determine the best common (correlated)
367 parent and clone sources for incremental backups, by choosing from
368 predefined candidate lists.
369
370 The list-spec defines from what candidate list the next
371 parent/clone-src should be appended to a result list; amount
372 defines how many (e.g. "sro:1 sro:1" is identical to "sro:2"), or
373 all if omitted. Any candidate which is already in the results is
374 dropped.
375
376 The resulting list of subvolumes is then used as parameters for the
377 btrfs-send(8) command: the first for "-p <parent>", all others for
378 "-c <clone-src>".
379
380 Available list-spec (candidate lists = filtered subsets of
381 correlated subvolumes):
382
383 sro,srn
384 All from snapshot_dir matching snapshot_name, with parent_uuid
385 relationship, sorted by btrbk timestamp (o=older n=newer).
386
387 sao,san
388 All from snapshot_dir matching snapshot_name, sorted by btrbk
389 timestamp (o=older n=newer).
390
391 aro,arn
392 All from incremental_resolve, with parent_uuid relationship,
393 sorted by cgen (o=older n=newer).
394
395 Defaults to "sro:1 srn:1 sao:1 san:1 aro:1 arn:1". Note that for
396 most operations the default resolves a single parent, as there
397 usually are no newer snapshots, and all "sro:1 sao:1 aro:1" resolve
398 to the same snapshot.
399
400 Example: "defaults,sao,san,aro,arn" takes the defaults, and adds
401 clone sources for all (!) known candidates on the filesystem.
402
403 incremental_clones yes|no
404 If enabled, btrbk adds "-c <clone-src>" to the btrfs-send(8)
405 command for all correlated subvolumes resolved by
406 incremental_prefs. If disabled, only "-p <parent>" is used.
407 Defaults to “yes”.
408
409 incremental_resolve mountpoint|directory
410 Specifies where to search for the best common parent for
411 incremental backups. If set to “mountpoint”, use parents in the
412 filesystem tree below the mount point of the snapshot and target
413 directory. If set to “directory”, use parents strictly below
414 snapshot/target directories. Set this to “directory” if you get
415 access problems (when not running btrbk as root). Defaults to
416 “mountpoint”.
417
418 snapshot_qgroup_destroy yes|no *experimental*
419
420
421 target_qgroup_destroy yes|no *experimental*
422
423
424 archive_qgroup_destroy yes|no *experimental*
425 Whenever a subvolume is deleted, also destroy corresponding default
426 qgroup "0/<subvol-id>". Only useful if you have enabled btrfs quota
427 support. See also:
428 https://bugzilla.kernel.org/show_bug.cgi?id=91751
429
430 Informative Options
431 warn_unknown_targets yes|no
432 If set, prints a warning if btrbk encounters a target subvolume at
433 a unknown location (i.e. not following btrbk naming scheme, or
434 outside the target directory). Defaults to “no”.
435
437 Retention policies are defined individually for snapshots, backups and
438 archives (summarized as "backups" in the following text), using a
439 combination of:
440
441 *_preserve_min all|latest|no|<number>{h,d,w,m,y}
442 Amount of time (duration) in which all backups are preserved.
443
444 *_preserve no|<retention_policy>
445 Schedule (single points in time) for which individual backups are
446 preserved.
447
448 Note that if "preserve_min" is set to “all” (the default), any setting
449 of "preserve" obviously has no effect.
450
451 The format for <retention_policy> is:
452
453 [<hourly>h] [<daily>d] [<weekly>w] [<monthly>m] [<yearly>y]
454
455 hourly
456 Defines how many hours back hourly backups should be preserved. The
457 first backup of an hour is considered an hourly backup.
458
459 daily
460 Defines how many days back daily backups should be preserved. The
461 first backup of a day (starting at preserve_hour_of_day) is
462 considered a daily backup.
463
464 weekly
465 Defines how many weeks back weekly backups should be preserved. The
466 first daily backup created at preserve_day_of_week (or the first
467 backup in this week if none was made on the exact day) is
468 considered as a weekly backup.
469
470 monthly
471 Defines how many months back monthly backups should be preserved.
472 Every first weekly backup in a month is considered a monthly
473 backup.
474
475 yearly
476 Defines for how many years back yearly backups should be preserved.
477 Every first monthly backup in a year is considered a yearly backup.
478
479 Use an asterisk for “all” (e.g. "target_preserve 60d *m" states:
480 "preserve daily backups for 60 days back, and all monthly backups").
481
482 Hint: Run btrbk with the -S, --print-schedule option to get a
483 comprehensive output of the scheduler results.
484
485 Reference Time
486 The local time on the host running btrbk defines the reference time for
487 all date/time calculations, especially for "beginning of a day", and as
488 a consequence for the first daily, weekly, monthly or yearly backups.
489 The local time on remote hosts (ssh source/target) is never used.
490
491 Unless "timestamp_format long-iso" is set, daily backups are preserved
492 at "preserve_hour_of_day" (defaults to midnight) of the respective time
493 zone (and not for "00:00 UTC", which would be "14:00" in Honolulu).
494 This becomes relevant for setups with multiple btrbk instances, e.g.
495 many snapshot-only instances (spread around the world), and a
496 fetch-only instance on the backup server.
497
498 Caveat:
499
500 • If "timestamp_format long-iso" is set, each btrbk instance on has a
501 different interpretation of "first in day". Make sure to run btrbk
502 with the same time zone on every host, e.g. by setting the TZ
503 environment variable (see tzset(3)).
504
506 send-receive
507 Backup to a btrfs filesystem, using "btrfs send/receive". This is
508 the recommended (standard) target type. The <target-directory> must
509 be an absolute path and point to a subvolume or directory within a
510 btrfs file system. See btrfs-send(8), btrfs-receive(8).
511
512 raw *experimental*
513 Backup to a raw (filesystem independent) file from the output of
514 btrfs-send(8), with optional compression and encryption.
515
516 Note that the target preserve mechanism is currently disabled for
517 incremental raw backups (btrbk does not delete any incremental raw
518 files)!
519
520 Raw backups consist of two files: the main data file containing the
521 btrfs send stream, and a sidecar file ".info" containing metadata:
522
523 <snapshot-name>.<timestamp>[_N].btrfs[.gz|.bz2|.xz][.gpg]
524 <snapshot-name>.<timestamp>[_N].btrfs[.gz|.bz2|.xz][.gpg].info
525
526 For incremental backups ("incremental yes"), please note that:
527
528 • As soon as a single incremental backup file is lost or
529 corrupted, all later incremental backups become invalid, as
530 there is no common parent for the subsequent incremental images
531 anymore. This might be a good compromise for a vacation backup
532 plan, but for the long term make sure that a non-incremental
533 backup is triggered from time to time.
534
535 • There is currently no support for rotation of incremental
536 backups: if incremental is set, a full backup must be triggered
537 manually from time to time in order to be able to delete old
538 backups.
539
540 Additional options for raw targets:
541
542 raw_target_compress <compress_command>|no
543 Compression algorithm to use for raw backup target. Supported
544 <compress_command>: gzip, pigz, bzip2, pbzip2, xz, lzo, lz4,
545 zstd.
546
547 raw_target_compress_level default|<number>
548 Compression level for the specified <compress_command>.
549
550 raw_target_compress_long default|<number>
551 Enable long distance matching for the specified
552 <compress_command>.
553
554 raw_target_compress_threads default|<number>
555 Number of threads to use for <compress_command>.
556
557 raw_target_split <size>|no
558 Split the raw backup file into pieces of size <size>.
559
560 raw_target_block_size <number>
561 Block size to use for writing the raw backup file. Defaults to
562 “128K”.
563
564 raw_target_encrypt gpg|openssl_enc|no
565 If enabled, encrypt the target raw file using gpg or
566 openssl_enc.
567
568 Additional options for "raw_target_encrypt gpg":
569
570 gpg_keyring <file>
571 Keyring to use for gpg, e.g. "/etc/btrbk/gpg/pubring.kbx".
572
573 gpg_recipient <name>
574 Encrypt for user id <name> (email address).
575
576 Additional options for "raw_target_encrypt openssl_enc" (very
577 experimental):
578
579 openssl_ciphername <name>
580 Defaults to “aes-256-cbc”.
581
582 openssl_iv_size <size-in-bytes>|no
583 Depends on selected cipher.
584
585 openssl_keyfile <file>|no
586 Point to a key file in hex (absolute path). Example key file
587 creation (256bit key):
588
589 # dd if=/dev/urandom bs=1 count=32 \
590 | od -x -A n \
591 | tr -d "[:space:]" > /path/to/keyfile
592
593 kdf_backend <file>|no
594 KDF backend to be executed, e.g.
595 "/usr/share/btrbk/scripts/kdf_pbkdf2.py".
596
597 kdf_keysize <size-in-bytes>
598 Defaults to “32”.
599
600 kdf_keygen once|each
601 Defaults to “once”.
602
604 Please refer to the btrbk project page https://digint.ch/btrbk/ for
605 further details.
606
608 btrbk(1)
609
611 Axel Burri axel@tty0.ch
612
613
614
615Btrbk 0.32.1 2022-02-26 BTRBK.CONF(5)