2.6 KiB
2.6 KiB
name, description
| name | description |
|---|---|
| replace-production-database | Replace the populated SHD.build production database with a local full bootstrap bundle after verified backups. Use only when the user explicitly authorizes replacement of all production data. |
Replace Production Database
This procedure overwrites production users, sessions, builds, guides, audits, proposals, settings, and source data. Obtain explicit approval for a full replacement. Use the ISAC import flow when the request only concerns canonical game data.
Export
- Stop only this repository's local development server. The embedded database must be closed during export.
- Run
npm run production:bootstrap:export. Record the generated bundle beneathdata/backups/; it includes private account data and uploaded assets. - Transfer the bundle to
f302over SSH. Keep it outside Git and confirm the remote copy is nonempty.
Replace
- Confirm the current production deployment is healthy and no Gitea production deployment is running.
- On
f302, stop only the productionappandschedulerservices from/opt/shd-build-production. - Run
node scripts/db-backup.mjsthrough the production Compose service. Record and retain the JSON backup path before any destructive work. - Reset the production database file and its embedded-database support files. Keep the persistent volume and existing upload directories; the import writes the local avatar and managed-image files without deleting retained files.
- Run
node scripts/db-migrate.mjsthrough the production Compose service to create the current empty schema. - Run
/opt/shd-build-production/bootstrap-production.sh <bundle-path>. The script stages the bundle in the private data volume, assigns it to the runtime UID, runsenvironment-bootstrap-import.mjswith the required confirmation, removes the staged copy, and restarts both services. - Wait for app health, then remove the remote transfer bundle.
Verify
- Confirm the importer reports the expected row, avatar, and managed-image counts.
- Confirm
https://shd.build/api/healthreturnsready: truewith anokdatabase check. - Confirm the production app container is healthy and its scheduler is running.
- Restart the local development server and verify it accepts an HTTP request.
Guardrails
- Never replace a populated production database without explicit user approval.
- Never delete the production Compose volume.
- Do not replace the database while the app or scheduler can write to it.
- Keep the verified pre-replacement backup. It is the recovery source if the import or restart fails.