From 805d7f4a0d33216de2b4e9fc4ad83c01d322b40c Mon Sep 17 00:00:00 2001 From: Axel Burri Date: Mon, 1 Apr 2019 16:27:49 +0200 Subject: [PATCH] btrbk-verify: add workaround for btrbk <= 0.27.2 bug: missing target_rsh, target_type btrbk <= 0.27.2 does not print "target_rsh" and "target_type" when called with --format=raw, see $table_formats{resolved}. This is fixed in 0.28.0. Hardcoding target_type=send-receive is not so bad, as for raw targets btrbk-verify complains first with: btrbk-verify: missing required variable "target_rsh" in btrbk --format=raw line So we should not run rsync (which is not really a problem, rsync just fails with "not a directory"). --- contrib/cron/btrbk-verify | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/contrib/cron/btrbk-verify b/contrib/cron/btrbk-verify index 78f6e62..c056dfa 100755 --- a/contrib/cron/btrbk-verify +++ b/contrib/cron/btrbk-verify @@ -313,6 +313,19 @@ eval_btrbk_resolved_line() # basic input validation, set prefixed variable (eval) local var_assignment=$(echo "$line" | grep -Eo "${vv}"'="[^"]*"') if [[ $? -ne 0 ]] || [[ -z "$var_assignment" ]]; then + if [[ $vv == "target_type" ]]; then + # hack for btrbk <= 0.27.2 bug: missing "target_type" in $table_formats{resolved} + # hardcode send-receive type, this results in rsync failing on raw targets with: + # rsync: ERROR: cannot stat destination "xxx.btrfs.xz.gpg/": Not a directory (20) + eval "${prefix}target_type=\"send-receive\"" || return 1 + continue + fi + if [[ $vv == "target_rsh" ]] && [[ -z "$R_target_host" ]]; then + # hack for btrbk <= 0.27.2 bug: missing "target_rsh" in $table_formats{resolved} + # note that target_rsh is not needed if target_host is not set. + # variable has already been reset above, continue + continue + fi log_line "btrbk-verify: missing required variable \"${vv}\" in btrbk --format=raw line" return 1 fi