btrbk: sane defaults: xxx_preserve_min defaults to "all", xxx_preserve default to "no" (for backwards compatibility with 0.22.0 default)

pull/88/head
Axel Burri 2016-04-19 21:07:04 +02:00
parent 29b9c8fc60
commit 2b22524ccd
4 changed files with 36 additions and 28 deletions

View File

@ -157,6 +157,8 @@ Retention policy:
snapshot_preserve_min 2d snapshot_preserve_min 2d
snapshot_preserve 14d snapshot_preserve 14d
target_min no
target_preserve 20d 10w *m target_preserve 20d 10w *m
snapshot_dir btrbk_snapshots snapshot_dir btrbk_snapshots
@ -237,26 +239,30 @@ This will pull backups from alpha/beta.mydomain.com and locally create:
* `/mnt/btr_backup/beta/dbdata.YYYYMMDD` * `/mnt/btr_backup/beta/dbdata.YYYYMMDD`
Example: local time-machine (daily snapshots) Example: local time-machine (hourly snapshots)
--------------------------------------------- ----------------------------------------------
If all you want is to create snapshots of your home directory on a If all you want is to create snapshots of your home directory on a
regular basis: regular basis:
/etc/btrbk/btrbk.conf: /etc/btrbk/btrbk.conf:
timestamp_format long
snapshot_preserve_min 18h
snapshot_preserve 48h 20d 6m
volume /mnt/btr_pool volume /mnt/btr_pool
snapshot_dir btrbk_snapshots snapshot_dir btrbk_snapshots
subvolume home subvolume home
/etc/cron.daily/btrbk: /etc/cron.hourly/btrbk:
#!/bin/sh #!/bin/sh
exec /usr/sbin/btrbk -q run exec /usr/sbin/btrbk -q run
Note that you can run btrbk more than once a day, e.g. by creating the Note that you can run btrbk more than once an hour, e.g. by by calling
above script in `/etc/cron.hourly/btrbk`, or by calling `sudo btrbk `sudo btrbk run` from the command line. With this setup, all those
run` from the command line. extra snapshots will be kept for 18 hours.
Example: multiple btrbk instances Example: multiple btrbk instances
@ -268,20 +274,20 @@ to only fetch the snapshots.
/etc/btrbk/btrbk.conf (on backup server): /etc/btrbk/btrbk.conf (on backup server):
target_preserve_min no
target_preserve 0d 10w *m
volume ssh://192.168.0.42/mnt/btr_pool volume ssh://192.168.0.42/mnt/btr_pool
subvolume home subvolume home
snapshot_dir btrbk_snapshots snapshot_dir btrbk_snapshots
snapshot_preserve_min all snapshot_preserve_min all
snapshot_create no snapshot_create no
target_preserve 0d 10w *m
target send-receive /mnt/btr_backup/my-laptop.com target send-receive /mnt/btr_backup/my-laptop.com
If the server runs btrbk with this config, the latest snapshot (which If the server runs btrbk with this config, 10 weeklies and all
is *always* transferred), 10 weeklies and all monthlies are received monthlies are received from 192.168.0.42. The source filesystem is
from 192.168.0.42. The source filesystem is never altered because of never altered because of `snapshot_preserve_min all`.
`snapshot_preserve_min all`.
Example: backup from non-btrfs source Example: backup from non-btrfs source
@ -301,9 +307,10 @@ follows:
volume /mnt/btr_backup volume /mnt/btr_backup
subvolume myhost_sync subvolume myhost_sync
snapshot_name myhost snapshot_name myhost
snapshot_preserve 14d 20w *m snapshot_preserve_min latest
snapshot_preserve 14d 20w *m
This will produce daily snapshots `/mnt/btr_backup/myhost.20150101`, This will produce daily snapshots `/mnt/btr_backup/myhost.20150101`,
with retention as defined with the snapshot_preserve option. with retention as defined with the snapshot_preserve option.
@ -327,15 +334,15 @@ compressed and piped through GnuPG.
/etc/btrbk/btrbk.conf: /etc/btrbk/btrbk.conf:
raw_target_compress xz raw_target_compress xz
raw_target_encrypt gpg raw_target_encrypt gpg
gpg_keyring /etc/btrbk/gpg/pubring.gpg gpg_keyring /etc/btrbk/gpg/pubring.gpg
gpg_recipient btrbk@mydomain.com gpg_recipient btrbk@mydomain.com
volume /mnt/btr_pool volume /mnt/btr_pool
subvolume home subvolume home
target raw ssh://cloud.example.com/backup target raw ssh://cloud.example.com/backup
ssh_user btrbk ssh_user btrbk
# incremental no # incremental no
This will create a GnuPG encrypted, compressed files on the target This will create a GnuPG encrypted, compressed files on the target

4
btrbk
View File

@ -83,9 +83,9 @@ my %config_options = (
incremental => { default => "yes", accept => [ "yes", "no", "strict" ] }, incremental => { default => "yes", accept => [ "yes", "no", "strict" ] },
preserve_day_of_week => { default => "sunday", accept => [ (keys %day_of_week_map) ] }, preserve_day_of_week => { default => "sunday", accept => [ (keys %day_of_week_map) ] },
snapshot_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1, context => [ "root", "volume", "subvolume" ], }, snapshot_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1, context => [ "root", "volume", "subvolume" ], },
snapshot_preserve_min => { default => "1d", accept => [ "all", "latest" ], accept_regexp => qr/^[1-9][0-9]*[hdwmy]$/, context => [ "root", "volume", "subvolume" ], }, snapshot_preserve_min => { default => "all", accept => [ "all", "latest" ], accept_regexp => qr/^[1-9][0-9]*[hdwmy]$/, context => [ "root", "volume", "subvolume" ], },
target_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1 }, target_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1 },
target_preserve_min => { default => undef, accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ }, target_preserve_min => { default => "all", accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ },
archive_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1 }, archive_preserve => { default => undef, accept => [ "no" ], accept_preserve_matrix => 1 },
archive_preserve_min => { default => "all", accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ }, archive_preserve_min => { default => "all", accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ },
btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] }, btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] },

View File

@ -92,7 +92,8 @@ snapshot_dir _btrbk_snap
# #
# Example configuration: # Example configuration:
# #
snapshot_preserve_all 14d snapshot_preserve_min 14d
snapshot_preserve_min no
target_preserve 20d 10w *m target_preserve 20d 10w *m
# Backup to external disk mounted on /mnt/btr_backup # Backup to external disk mounted on /mnt/btr_backup

View File

@ -1,4 +1,4 @@
.TH "btrbk.conf" "5" "2016-04-16" "btrbk v0.23.0-rc1" "" .TH "btrbk.conf" "5" "2016-04-19" "btrbk v0.23.0-dev" ""
.\" disable hyphenation .\" disable hyphenation
.nh .nh
.\" disable justification (adjust text to left margin only) .\" disable justification (adjust text to left margin only)
@ -134,7 +134,7 @@ Preserve all snapshots for a minimum amount of hours (h), days (d),
weeks (w), months (m) or years (y), regardless of how many there weeks (w), months (m) or years (y), regardless of how many there
are. If set to \[lq]all\[rq], preserve all snapshots forever. If set are. If set to \[lq]all\[rq], preserve all snapshots forever. If set
to \[lq]latest\[rq], preserve latest snapshot. Defaults to to \[lq]latest\[rq], preserve latest snapshot. Defaults to
\[lq]1d\[rq]. \[lq]all\[rq].
.RE .RE
.PP .PP
\fBtarget_preserve\fR no|<retention_policy> \fBtarget_preserve\fR no|<retention_policy>
@ -152,7 +152,7 @@ are. If set to \[lq]all\[rq], preserve all backups forever. If set to
\[lq]latest\[rq], always preserve the latest backup (useful in \[lq]latest\[rq], always preserve the latest backup (useful in
conjunction with "target_preserve no", if you want to keep the latest conjunction with "target_preserve no", if you want to keep the latest
backup only). If set to \[lq]no\[rq], only the backups following the backup only). If set to \[lq]no\[rq], only the backups following the
\fItarget_preserve\fR policy are created. Defaults to \[lq]no\[rq]. \fItarget_preserve\fR policy are created. Defaults to \[lq]all\[rq].
.RE .RE
.PP .PP
\fBpreserve_day_of_week\fR monday|tuesday|...|sunday \fBpreserve_day_of_week\fR monday|tuesday|...|sunday