diff --git a/backup/backup-k8s-apps.sh b/backup/backup-k8s-apps.sh index dc0550f..93acb00 100755 --- a/backup/backup-k8s-apps.sh +++ b/backup/backup-k8s-apps.sh @@ -482,6 +482,16 @@ if [ $VM_SCP_RC -eq 0 ]; then "${BACKUP_NAME}.tar.gz.sha256" \ "${VM_USER}@${VM_HOST}:${VM_DEST}" 2>/dev/null || true TIER2_STATUS="ok" + + # VM-side retention — this tier never had any pruning at all until + # found accumulating 85 legacy pre-k8s archives (131GB) untouched + # since May. Mirrors the local [TIER 1] policy above: same + # MAX_BACKUPS, own glob/lineage only (never touches other + # unrelated backup dirs also living on this VM). + ssh -i "$VM_KEY" -p "$VM_PORT" -o StrictHostKeyChecking=no -o ConnectTimeout=15 \ + "${VM_USER}@${VM_HOST}" \ + "cd ${VM_DEST} && ls -t myapps-k8s-backup-*.tar.gz 2>/dev/null | tail -n +$((MAX_BACKUPS + 1)) | xargs -r -I{} rm -f {} {}.sha256 {}.meta.json" \ + &>/dev/null || true else echo " ⚠️ VM transfer failed (rc=$VM_SCP_RC) — local backup is safe, continuing..." TIER2_STATUS="failed:rc=${VM_SCP_RC}"