Spaces:
Running
Running
Download deploy/scripts/restore.sh from Aynkhn/WorkPilot-AI: direct link, hf CLI and curl.
- Browser
- Download file 1.7 kB
-
https://huggingface.co/spaces/Aynkhn/WorkPilot-AI/resolve/main/deploy/scripts/restore.sh
- Command line
-
hf download hf://spaces/Aynkhn/WorkPilot-AI/deploy/scripts/restore.sh
-
curl -L -o restore.sh https://huggingface.co/spaces/Aynkhn/WorkPilot-AI/resolve/main/deploy/scripts/restore.sh
1.7 kB
| # Restore a backup made by deploy/scripts/backup.sh into an EMPTY database. | |
| # | |
| # WP_RESTORE_DATABASE_URL=postgresql://admin:...@host:5432/workpilot_restore \ | |
| # deploy/scripts/restore.sh backups/workpilot-20261205T020000Z.dump | |
| # | |
| # Before running: | |
| # 1. The roles workpilot_owner and workpilot_app must exist on the target server | |
| # (python -m core.db.bootstrap, or deploy/sql/bootstrap_managed.sql on managed Postgres). | |
| # Ownership and grants in the dump refer to them by name. | |
| # 2. The target database exists, is empty, and is owned by workpilot_owner; the pgvector | |
| # extension is available (the dump re-creates it with CREATE EXTENSION). | |
| # 3. Stop the api and worker (or point them elsewhere): never restore under live traffic. | |
| # | |
| # After running: verify (docs/deployment.md, "Restore drill"): | |
| # python -m core.cli check-deploy # owner role; also proves connectivity | |
| # python -m core.cli verify-audit --tenant <id> # hash chains intact | |
| # then repoint WP_DATABASE_URL / WP_OWNER_DATABASE_URL and start the services. | |
| set -euo pipefail | |
| DUMP="${1:?usage: restore.sh <file.dump>}" | |
| : "${WP_RESTORE_DATABASE_URL:?set WP_RESTORE_DATABASE_URL (superuser or the database owner)}" | |
| PG_RESTORE="${PG_RESTORE:-pg_restore}" | |
| JOBS="${WP_RESTORE_JOBS:-2}" | |
| "$PG_RESTORE" --list "$DUMP" > /dev/null # refuse a corrupt/foreign file before touching the DB | |
| # --exit-on-error: a partial restore is worse than none. --no-owner is NOT used: the RLS | |
| # design depends on workpilot_owner owning every table and workpilot_app owning none. | |
| "$PG_RESTORE" --exit-on-error --jobs="$JOBS" --no-password --dbname="$WP_RESTORE_DATABASE_URL" "$DUMP" | |
| echo "restored $DUMP" | |