fix(deploy): propagate backup retention failures
This commit is contained in:
+19
-4
@@ -559,14 +559,29 @@ apply_backup_retention() {
|
||||
echo "Monthly recovery set retained: ${monthly_dir}"
|
||||
fi
|
||||
|
||||
find "$BACKUP_DIR" -maxdepth 1 -type f -name 'jobtracker-*' -mtime "+$daily_days" -delete
|
||||
if ! find "$BACKUP_DIR" -maxdepth 1 -type f -name 'jobtracker-*' -mtime "+$daily_days" -delete; then
|
||||
echo "Daily backup retention failed. Aborting deploy."
|
||||
return 1
|
||||
fi
|
||||
|
||||
local monthly_dirs=()
|
||||
mapfile -t monthly_dirs < <(find "$monthly_root" -mindepth 1 -maxdepth 1 -type d -name '20??-??' | sort)
|
||||
local monthly_dirs=() monthly_listing
|
||||
# Check the pipeline directly; mapfile cannot report process-substitution failures.
|
||||
if ! monthly_listing="$(find "$monthly_root" -mindepth 1 -maxdepth 1 -type d -name '20??-??' | sort)"; then
|
||||
echo "Could not enumerate monthly backups. Aborting deploy."
|
||||
return 1
|
||||
fi
|
||||
if [ -n "$monthly_listing" ]; then
|
||||
mapfile -t monthly_dirs <<< "$monthly_listing"
|
||||
fi
|
||||
while [ "${#monthly_dirs[@]}" -gt "$monthly_count" ]; do
|
||||
local oldest="${monthly_dirs[0]}"
|
||||
case "$oldest" in
|
||||
"$monthly_root"/20??-??) rm -rf -- "$oldest" ;;
|
||||
"$monthly_root"/20??-??)
|
||||
if ! rm -rf -- "$oldest"; then
|
||||
echo "Monthly backup retention failed. Aborting deploy."
|
||||
return 1
|
||||
fi
|
||||
;;
|
||||
*) echo "Refusing to prune unexpected monthly backup path: $oldest"; return 1 ;;
|
||||
esac
|
||||
monthly_dirs=("${monthly_dirs[@]:1}")
|
||||
|
||||
Reference in New Issue
Block a user