#!/usr/bin/env bash # Archive one-shot bootstrap/diag scripts from ~ after backup. Keeps credentials and stacks. set -euo pipefail BACKUP="$HOME/backup-oneshots-$(date -u +%Y%m%dT%H%M%SZ).tar.gz" cd "$HOME" FILES=( allow-docker-pg.sh diag-pg-docker2.sh fix-pg-for-docker.sh fix-pg-docker.sh remote-bootstrap-env-db.sh remote-bootstrap-phase-a.sh remote-migrate-and-up.sh remote-reset-db-migrate-up.sh tighten-pg-listen.sh verify-harden.sh ) EXIST=() for f in "${FILES[@]}"; do [[ -f "$f" ]] && EXIST+=("$f") done if [[ ${#EXIST[@]} -eq 0 ]]; then echo "Nothing to clean" exit 0 fi tar -czf "$BACKUP" "${EXIST[@]}" mkdir -p "$HOME/archive-oneshots" mv "${EXIST[@]}" "$HOME/archive-oneshots/" echo "Archived to $BACKUP and moved into ~/archive-oneshots/" ls -la "$BACKUP" echo "CLEANUP_OK"