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}"