m() { if $verbose; then printf "$pre%s\n" "$*"; fi; "$@"; }
e() { printf "$pre%s\n" "$*"; }
die() { printf "$pre%s\n" "$*" >&2; echo "exiting with status 1" >&2; exit 1; }
m() { if $verbose; then printf "$pre%s\n" "$*"; fi; "$@"; }
e() { printf "$pre%s\n" "$*"; }
die() { printf "$pre%s\n" "$*" >&2; echo "exiting with status 1" >&2; exit 1; }
# default options
conf_only=false
dry_run=false # mostly for testing
rate_limit=no
verbose=true; verbose_arg=-v
progress_arg="--progress"
# default options
conf_only=false
dry_run=false # mostly for testing
rate_limit=no
verbose=true; verbose_arg=-v
progress_arg="--progress"
;;
# only creates the config file, does not run btrbk
-c) conf_only=true; shift ;;
;;
# only creates the config file, does not run btrbk
-c) conf_only=true; shift ;;
# bytes per second, suffix k m g
-l) rate_limit=$2; shift 2 ;;
# Comma separated mountpoints to backup. This has defaults set below.
# bytes per second, suffix k m g
-l) rate_limit=$2; shift 2 ;;
# Comma separated mountpoints to backup. This has defaults set below.
# TODO: i wonder if there should be an option to send to the default
# targets, plus any given on the command line.
# TODO: i wonder if there should be an option to send to the default
# targets, plus any given on the command line.
for h in ${targets[@]}; do
if zone=$(ssh root@$h "mkdir -p /mnt/root/btrbk && date +%z"); then
# This is a separate ssh because xprintidle can fail and thats ok.
for h in ${targets[@]}; do
if zone=$(ssh root@$h "mkdir -p /mnt/root/btrbk && date +%z"); then
# This is a separate ssh because xprintidle can fail and thats ok.