Edit: /opt/mawid/scripts/restore.sh (569B)
#!/usr/bin/env bash
# Restore a backup into a database (default: mawid). See RUNBOOK.md for the
# full drill including restoring into a scratch DB first.
set -euo pipefail
cd "$(dirname "$0")/.."
FILE=${1:?usage: scripts/restore.sh backups/mawid-
.sql.gz [target-db]}
DB=${2:-mawid}
if [ "$DB" != "mawid" ]; then
docker compose exec -T postgres psql -U mawid -d postgres \
-c "DROP DATABASE IF EXISTS $DB" -c "CREATE DATABASE $DB"
fi
gunzip -c "$FILE" | docker compose exec -T postgres psql -q -U mawid -d "$DB"
echo "restored $FILE into database '$DB'"