4 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
6 [[ $EUID == 0 ]] ||
exec sudo
-E "$BASH_SOURCE" "$@"
9 if [[ $1 == -c ]]; then
15 cat >/etc
/btrbk.conf
<<'EOF'
16 ssh_identity /root/.ssh/id_rsa
17 transaction_syslog daemon
19 # so we only run one at a time
20 lockfile /var/lock/btrbk.lock
22 # default format of short does not accomidate hourly preservation setting
23 timestamp_format long-iso
24 # background on timezones. with short/long, timestamps use local time.
25 # for long, if your local time moves backwards, by moving timezones or
26 # for an hour when daylight savings changes it, you will temporarily get
27 # a more aggressive retention policy for the overlapping period, and
28 # vice versa for the opposite timezone move. The alternative is using
29 # long-iso, which puts timezone info into the timestamp, which means
30 # that instead of shifting time, you shift the start of day/week/month
31 # which is used for retention to your new local time, which means for
32 # example, if you moved forward by 8 hours, the daily/weekly/monthly
33 # retention will be 8 hours more aggressive since midnight is at a new
34 # time, unless you fake the timzeone using the TZ env variable.
35 # However, in the short term, there will be no inconsistencies.
36 # I don't see any problem with shifting when the day starts for
37 # retention, so I'm using long-iso.
39 # only make a snapshot if things have changed
40 snapshot_create onchange
41 # much less snapshots because I have less space on the
43 snapshot_preserve 2h 2d
45 # so, total backups = ~89
46 target_preserve 48h 14d 8w 24m
47 target_preserve_min 6h
49 # if something fails and it's not obvious, try doing
50 # btrbk -l debug -v dryrun
56 if ! timeout
-s 9 10 ssh frodo
:; then
57 target_host
=$HOME_DOMAIN
58 cat >>/etc
/btrbk.conf
<<EOF
65 if [[ $HOSTNAME != frodo
]]; then
66 remote_target
="target send-receive ssh://${target_host}/mnt/root/${HOSTNAME}-btrbk"
72 mountpoint
$root &>/dev
/null ||
return
73 cat >>/etc
/btrbk.conf
<<EOF
81 target-section
/mnt
/iroot i
82 target-section
/mnt
/root q