From 3580b3fda1455630124931a26c5a48f120bc8128 Mon Sep 17 00:00:00 2001 From: Jay Hemnani <193022578+jayhemnani9910@users.noreply.github.com> Date: Thu, 3 Dec 2026 15:02:17 +0530 Subject: [PATCH] Remove a tar backup that failed instead of keeping it --- scripts/opt/backup-loop.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/scripts/opt/backup-loop.sh b/scripts/opt/backup-loop.sh index 6120849..5608664 100644 --- a/scripts/opt/backup-loop.sh +++ b/scripts/opt/backup-loop.sh @@ -357,6 +357,12 @@ tar() { command tar "${excludes[@]}" -I "${tar_compress_parameters[*]}" -cf "${outFile}" -C "${SRC_DIR}" "${includes_patterns[@]}" 2>&1 | tee "$1" || exitCode=$? if [[ $exitCode -eq 1 ]]; then log WARN "Dat files changed as we read it" + elif [[ $exitCode -gt 1 ]]; then + # A fatal tar error (such as a full disk) leaves a truncated archive; + # keeping it would count it as a backup when pruning by count. + log ERROR "Removing incomplete backup ${outFile}" + rm -f "${outFile}" + return $exitCode fi if [ "${LINK_LATEST^^}" == "TRUE" ]; then ln -sf "$(resolve_backup_name)-${ts}.${backup_extension}" "${DEST_DIR}/latest.${backup_extension}"