From 02ccbd95188330c3f4edc7db7fd1e8f9eda87382 Mon Sep 17 00:00:00 2001 From: Ian Kelling Date: Tue, 4 Jul 2023 20:12:19 -0400 Subject: [PATCH] btrbk fixes --- btrbk-run | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/btrbk-run b/btrbk-run index 5388858..057ff79 100644 --- a/btrbk-run +++ b/btrbk-run @@ -65,6 +65,7 @@ conf_only=false dry_run=false # mostly for testing rate_limit=no verbose=true; verbose_arg=-v +force=false if [[ $INVOCATION_ID ]]; then # INVOCATION_ID means running as a systemd service. we cant show progress in this case, # but if we pass the arg, it will insert mbuffer into the command. @@ -91,7 +92,7 @@ cron=false fast=false kd_spread_maybe=false orig_args=("$@") -temp=$(getopt -l cron,fast,pull-reexec,help 23ceikl:m:npqrs:t:vh "$@") || usage 1 +temp=$(getopt -l cron,fast,pull-reexec,help 23cefikl:m:npqrs:t:vh "$@") || usage 1 eval set -- "$temp" while true; do case $1 in @@ -110,6 +111,7 @@ while true; do -c) conf_only=true ;; # quit early, just btrbk, no extra remounting etc. -e) early=true ;; + -f) force=true ;; # skip various checks. when we run twice in a row for # switch mail-host, no need to repeat the same checks again. --fast) fast=true ;; @@ -214,6 +216,9 @@ fi kd_spread=false +if ! $cron && $kd_spread_maybe; then + kd_spread=true +fi # set default targets if [[ ! -v targets && ! $source ]]; then if $cron; then @@ -517,7 +522,7 @@ else # which is good enough. # # This is a separate ssh because the command can fail and thatis ok. - if $cron; then + if $cron && ! $force; then locked=false if lock_info=$(timeout -s 9 6 ssh $h DISPLAY=:0 xscreensaver-command -time); then if [[ $lock_info != *non-blanked* ]]; then @@ -718,12 +723,12 @@ fi if [[ $ret == 0 ]]; then for tg in ${targets[@]}; do - h=$(ssh root@$tg hostname) - rsync -a /var/log/btrbk $tg:/var/log/btrbk/$tg + h=$(ssh $tg hostname) + rsync -a -f"- */" -f"+ *" /var/log/btrbk/ root@$tg:/var/log/btrbk/$tg ssh root@$tg /usr/local/bin/mail-backup-clean done if [[ $source ]]; then - rsync -a $source:/var/log/btrbk /var/log/btrbk/$source + rsync -a -f"- */" -f"+ *" $source:/var/log/btrbk/ /var/log/btrbk/$source fi fi -- 2.30.2