backup: harden lifecycle fencing and skip near-empty archives

backup-node.sh now stops services, fences COMPOSE_FILE during backup, and
restores via EXIT trap; consumers skip <1MB .tar.zst artifacts so purged-
volume junk cannot shadow real backups.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-03 04:38:00 +00:00
parent 6c0df2bce5
commit 58adc446e2
6 changed files with 279 additions and 12 deletions

View File

@@ -294,11 +294,12 @@ transfer_backup() {
local key=$1
local volume_name="rpc_$key"
# Find the newest backup file
local backup_file=$(ls -1 "$backup_dir"/"${volume_name}"-[0-9]*G.tar.zst 2>/dev/null | sort | tail -n 1)
# Find the newest restorable backup file (skip near-empty artifacts)
local backup_file
backup_file=$(select_newest_local_backup "$backup_dir" "$volume_name")
if [[ -z "$backup_file" ]] || [[ ! -f "$backup_file" ]]; then
echo "Warning: No backup file found for $volume_name, skipping"
echo "Warning: No restorable backup file found for $volume_name, skipping"
return 1
fi
@@ -482,11 +483,12 @@ transfer_backup_ssh() {
local key=$1
local volume_name="rpc_$key"
# Find the newest backup file
local backup_file=$(ls -1 "$backup_dir"/"${volume_name}"-[0-9]*G.tar.zst 2>/dev/null | sort | tail -n 1)
# Find the newest restorable backup file (skip near-empty artifacts)
local backup_file
backup_file=$(select_newest_local_backup "$backup_dir" "$volume_name")
if [[ -z "$backup_file" ]] || [[ ! -f "$backup_file" ]]; then
echo "Warning: No backup file found for $volume_name, skipping"
echo "Warning: No restorable backup file found for $volume_name, skipping"
return 1
fi