chore(backups): ship exact DB-state dumps + restore scripts
The databases live in Docker volumes (not in git), so teammates on a fresh boot saw an empty system. backups/procurement.dump + casdoor.dump are exact pg_dump snapshots of the current demo state (users/roles, projects, warehouses, quotes with receipts, inventory rows; Casdoor org/app/users); restore.ps1 / restore.sh replace both DBs with the committed state (--clean --if-exists, verified by a round-trip restore into throwaway DBs). README documents how to restore and how to take a fresh dump.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# Restore the committed demo-state dumps (backups/*.dump) into the running
|
||||
# stack (Linux/macOS/Git Bash). REPLACES all data in the `procurement` and
|
||||
# `casdoor` databases.
|
||||
#
|
||||
# bash backups/restore.sh
|
||||
set -euo pipefail
|
||||
cd "$(dirname "$0")/.."
|
||||
|
||||
echo "Stopping api + casdoor (they hold DB connections)..."
|
||||
docker compose stop api casdoor
|
||||
|
||||
echo "Restoring procurement DB..."
|
||||
docker cp backups/procurement.dump procurement-postgres:/tmp/procurement.dump
|
||||
docker exec procurement-postgres pg_restore -U postgres -d procurement --clean --if-exists --single-transaction /tmp/procurement.dump
|
||||
|
||||
echo "Restoring casdoor DB..."
|
||||
docker cp backups/casdoor.dump procurement-postgres:/tmp/casdoor.dump
|
||||
docker exec procurement-postgres pg_restore -U postgres -d casdoor --clean --if-exists --single-transaction /tmp/casdoor.dump
|
||||
|
||||
echo "Starting services..."
|
||||
docker compose start casdoor api
|
||||
|
||||
echo ""
|
||||
echo "Restore complete."
|
||||
echo "App : http://localhost"
|
||||
echo "Casdoor : http://localhost:8080 (admin / 123)"
|
||||
Reference in New Issue
Block a user