From 9e0db8bae9235a40b9d8c3318dad78b290f7f3b7 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 3 Dec 2025 13:03:46 +0900 Subject: [PATCH] Fix the error trap with exit to stop calling it again with itself --- borg.backup.functions.init.sh | 5 +++-- borg.backup.functions.verify.sh | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/borg.backup.functions.init.sh b/borg.backup.functions.init.sh index e00e663..f1612f4 100644 --- a/borg.backup.functions.init.sh +++ b/borg.backup.functions.init.sh @@ -18,8 +18,9 @@ cleanup() { trap - SIGINT SIGTERM } error_trap() { - echo "Some part of the script failed with an error: $? @LINE: $(caller)"; - trap - ERR + echo "Some part of the script failed with an error: $? @COMMAND: '$BASH_COMMAND' @LINE: $(caller)"; + # exit caller so we do not catch the same error again + exit 0; } # on exit unset any exported var trap "unset BORG_BASE_DIR BORG_UNKNOWN_UNENCRYPTED_REPO_ACCESS_IS_OK BORG_RELOCATED_REPO_ACCESS_IS_OK" EXIT; diff --git a/borg.backup.functions.verify.sh b/borg.backup.functions.verify.sh index 65618bc..3d48382 100644 --- a/borg.backup.functions.verify.sh +++ b/borg.backup.functions.verify.sh @@ -296,10 +296,10 @@ if [ "${VERIFY}" -eq 1 ] || [ "${INIT}" -eq 1 ]; then printf "${PRINTF_SUB_BLOCK}" "VERIFY" "$(date +'%F %T')" "${MODULE}"; if [ -n "${TARGET_SERVER}" ]; then if [ "${DEBUG}" -eq 1 ]; then - echo "${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY}"; + echo "${BORG_COMMAND} info ${OPT_REMOTE} ${REPOSITORY} 2>&1 "; fi; # use borg info and verify if it returns "Repository ID:" in the first line - REPO_VERIFY=$(${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}"); + REPO_VERIFY=$(${BORG_COMMAND} info ${OPT_REMOTE} "${REPOSITORY}" 2>&1); __LAST_ERROR=$? if [ $__LAST_ERROR -ne 0 ]; then echo "[!] Repository verify error: ${REPO_VERIFY}";