From bc37b16815bad061e2b1911d4681cbdb4b8e1bef Mon Sep 17 00:00:00 2001 From: Viktor Barzin Date: Tue, 9 Jun 2026 21:26:23 +0000 Subject: [PATCH] =?UTF-8?q?backup:=20fix=20vzdump-vms=20exit=20code=20?= =?UTF-8?q?=E2=80=94=20EXIT-trap=20&&=20short-circuit=20falsely=20failed?= =?UTF-8?q?=20OK=20runs?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit First live run produced a valid 40G dump and logged status=0, but the service exited 1/FAILURE: cleanup() used `[ -n "$KILLED" ] && push_metrics 2 0`, and a bash EXIT trap whose LAST command returns non-zero overrides the script's `exit 0`. With KILLED empty the && short-circuits -> returns 1 -> a successful backup is marked failed (would trip a vzdump staleness/failure alert). Switch to daily-backup's `if…fi` idiom (returns 0 when not killed). Bug reproduced + fix verified locally; redeployed to PVE + reset-failed. [ci skip] Co-Authored-By: Claude Opus 4.8 --- scripts/vzdump-vms.sh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/vzdump-vms.sh b/scripts/vzdump-vms.sh index fabb45e7..8954d0e5 100644 --- a/scripts/vzdump-vms.sh +++ b/scripts/vzdump-vms.sh @@ -55,7 +55,10 @@ push_metrics() { KILLED="" cleanup() { rm -f "${LOCKFILE}" - [ -n "${KILLED}" ] && push_metrics 2 0 + # NB: must be `if…fi`, NOT `[ … ] && …` — a bash EXIT trap whose LAST command + # returns non-zero overrides the script's `exit 0`, so the `&&` short-circuit + # (when KILLED is empty) would falsely mark a successful backup as failed. + if [ -n "${KILLED}" ]; then push_metrics 2 0; fi } trap cleanup EXIT trap 'KILLED=1; exit 143' TERM INT