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