various fixes
[distro-setup] / btrbk-run
index 05589d1c8626391454b9e0cf261e4196d4e52a1e..c59faf99c9eecb0e976a532bd6e2ef00225c59f7 100755 (executable)
--- a/btrbk-run
+++ b/btrbk-run
@@ -18,13 +18,15 @@ script_dir=$(dirname $(readlink "$BASH_SOURCE"))
 
 conf_only=false
 dry_run=false # mostly for testing
+resume_arg=
 
-temp=$(getopt -l help hcnt: "$@") || usage 1
+temp=$(getopt -l help hcnrt: "$@") || usage 1
 eval set -- "$temp"
 while true; do
     case $1 in
         -c) conf_only=true; shift ;;
         -n) dry_run=true; dry_run_arg=-n; shift ;;
+        -r) resume_arg=-r; shift ;;
         -t) IFS=, targets=($2); shift 2 ;;
         -h|--help) usage ;;
         --) shift; break ;;
@@ -81,7 +83,9 @@ fi
 # a subvol on current host is not fresh.
 # umount first to ensure we don't have any errors
 # todo: do some kill fuser stuff to make umount more reliable
-# todo: run this on a systemd timer on $primary, once per hour.
+# todo: run this on a systemd timer on $primary, once per hour,
+# and if primary is, change that timer over to primary, and make
+# sure we mount the latest
 # todo: setup lock so that if this is already running, we exit out, so
 # that manual runs don't interfere with cronjobs.
 
@@ -129,9 +133,9 @@ if $conf_only; then
 fi
 
 if $dry_run; then
-    btrbk -n run
+    btrbk -n $resume_arg run
 else
-    btrbk -q run
+    btrbk -q $resume_arg run
 fi
 
 # if we have /p, rsync to targets without /p
@@ -153,7 +157,7 @@ fi
 if ! $dry_run; then
     for tg in ${targets[@]}; do
         scp $script_dir/{mount-latest-subvol,check-subvol-stale} \
-            root@tg:/usr/local/bin
+            root@$tg:/usr/local/bin
         ssh root@$tg bash <<'EOF'
 set -e
 chmod +x /usr/local/bin/{mount-latest-subvol,check-subvol-stale}