diff --git a/README.md b/README.md index dec160c..01ca655 100644 --- a/README.md +++ b/README.md @@ -157,6 +157,8 @@ Retention policy: snapshot_preserve_min 2d snapshot_preserve 14d + + target_min no target_preserve 20d 10w *m 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` -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 regular basis: /etc/btrbk/btrbk.conf: + timestamp_format long + snapshot_preserve_min 18h + snapshot_preserve 48h 20d 6m + volume /mnt/btr_pool snapshot_dir btrbk_snapshots subvolume home -/etc/cron.daily/btrbk: +/etc/cron.hourly/btrbk: #!/bin/sh exec /usr/sbin/btrbk -q run -Note that you can run btrbk more than once a day, e.g. by creating the -above script in `/etc/cron.hourly/btrbk`, or by calling `sudo btrbk -run` from the command line. +Note that you can run btrbk more than once an hour, e.g. by by calling +`sudo btrbk run` from the command line. With this setup, all those +extra snapshots will be kept for 18 hours. Example: multiple btrbk instances @@ -268,20 +274,20 @@ to only fetch the snapshots. /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 subvolume home - snapshot_dir btrbk_snapshots - snapshot_preserve_min all - snapshot_create no - - target_preserve 0d 10w *m + snapshot_dir btrbk_snapshots + snapshot_preserve_min all + snapshot_create no target send-receive /mnt/btr_backup/my-laptop.com -If the server runs btrbk with this config, the latest snapshot (which -is *always* transferred), 10 weeklies and all monthlies are received -from 192.168.0.42. The source filesystem is never altered because of -`snapshot_preserve_min all`. +If the server runs btrbk with this config, 10 weeklies and all +monthlies are received from 192.168.0.42. The source filesystem is +never altered because of `snapshot_preserve_min all`. Example: backup from non-btrfs source @@ -301,9 +307,10 @@ follows: volume /mnt/btr_backup 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`, with retention as defined with the snapshot_preserve option. @@ -327,15 +334,15 @@ compressed and piped through GnuPG. /etc/btrbk/btrbk.conf: - raw_target_compress xz - raw_target_encrypt gpg - gpg_keyring /etc/btrbk/gpg/pubring.gpg - gpg_recipient btrbk@mydomain.com + raw_target_compress xz + raw_target_encrypt gpg + gpg_keyring /etc/btrbk/gpg/pubring.gpg + gpg_recipient btrbk@mydomain.com volume /mnt/btr_pool subvolume home target raw ssh://cloud.example.com/backup - ssh_user btrbk + ssh_user btrbk # incremental no This will create a GnuPG encrypted, compressed files on the target diff --git a/btrbk b/btrbk index 1776aab..3d2384b 100755 --- a/btrbk +++ b/btrbk @@ -83,9 +83,9 @@ my %config_options = ( incremental => { default => "yes", accept => [ "yes", "no", "strict" ] }, 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_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_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_min => { default => "all", accept => [ "all", "latest", "no" ], accept_regexp => qr/^[0-9]+[hdwmy]$/ }, btrfs_commit_delete => { default => undef, accept => [ "after", "each", "no" ] }, diff --git a/btrbk.conf.example b/btrbk.conf.example index bc932c8..b617ee4 100644 --- a/btrbk.conf.example +++ b/btrbk.conf.example @@ -92,7 +92,8 @@ snapshot_dir _btrbk_snap # # Example configuration: # -snapshot_preserve_all 14d +snapshot_preserve_min 14d +snapshot_preserve_min no target_preserve 20d 10w *m # Backup to external disk mounted on /mnt/btr_backup diff --git a/doc/btrbk.conf.5 b/doc/btrbk.conf.5 index 71ccc29..9cab029 100644 --- a/doc/btrbk.conf.5 +++ b/doc/btrbk.conf.5 @@ -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 .nh .\" 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 are. If set to \[lq]all\[rq], preserve all snapshots forever. If set to \[lq]latest\[rq], preserve latest snapshot. Defaults to -\[lq]1d\[rq]. +\[lq]all\[rq]. .RE .PP \fBtarget_preserve\fR no| @@ -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 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 -\fItarget_preserve\fR policy are created. Defaults to \[lq]no\[rq]. +\fItarget_preserve\fR policy are created. Defaults to \[lq]all\[rq]. .RE .PP \fBpreserve_day_of_week\fR monday|tuesday|...|sunday