14 lines
548 B
Bash
Executable File
14 lines
548 B
Bash
Executable File
#!/usr/bin/env sh
|
|
set -eu
|
|
|
|
: "${BACKUP_FILE:?BACKUP_FILE is required}"
|
|
: "${RESTORE_DATABASE_URL:?RESTORE_DATABASE_URL is required and must point to a disposable restore database}"
|
|
|
|
test -f "$BACKUP_FILE"
|
|
if [ -f "$BACKUP_FILE.sha256" ]; then
|
|
sha256sum -c "$BACKUP_FILE.sha256"
|
|
fi
|
|
pg_restore --exit-on-error --clean --if-exists --no-owner --dbname="$RESTORE_DATABASE_URL" "$BACKUP_FILE"
|
|
psql "$RESTORE_DATABASE_URL" -v ON_ERROR_STOP=1 -c "SELECT version FROM schema_migrations ORDER BY applied_at DESC LIMIT 1;"
|
|
printf '%s\n' 'restore-check: ok'
|