Files
pokemon-inventory/scripts/verify-postgres-backup.sh
fragginwagon 73b4b9795e
Quality / test (push) Canceled after 0s
feat: verify postgres backups
2026-09-09 18:38:57 -04:00

20 lines
469 B
Bash
Executable File

#!/bin/sh
set -eu
: "${BACKUP_FILE:?Set BACKUP_FILE to a PostgreSQL custom-format dump}"
if [ ! -f "$BACKUP_FILE" ]; then
printf '%s\n' "Backup file not found: $BACKUP_FILE" >&2
exit 1
fi
if [ ! -s "$BACKUP_FILE" ]; then
printf '%s\n' "Backup file is empty: $BACKUP_FILE" >&2
exit 1
fi
docker compose -f compose.production.yaml run --rm -T postgres \
pg_restore --list < "$BACKUP_FILE" >/dev/null
printf '%s\n' "Backup archive is readable: $BACKUP_FILE"