Operations — database backup & restore
What it is
How to back up and restore the ManpowerIQ PostgreSQL database. ManpowerIQ uses standard PostgreSQL tooling for this — there is no bespoke backup procedure in the project; the runbook's own "restore baseline" mechanism is the migration-level drop + recreate, which is for resetting to seed, not for preserving data.
Honest scope. For preserving and restoring real data, use the standard
pg_dump/pg_restore(or pgAdmin's backup/restore UI) against the canonical local DB (Dockerpostgres:16-alpine). The project documents the reset path, not a data-backup runbook — so treat the commands below as the standard Postgres approach, not a ManpowerIQ-specific flow.
Backup (pg_dump)
Against the docker-compose Postgres (DB manpoweriq, user manpoweriq, port 5432):
# Custom-format dump (recommended — compress + selective restore)
pg_dump -h localhost -U manpoweriq -d manpoweriq -F c -f manpoweriq_backup.dump
# Or plain SQL
pg_dump -h localhost -U manpoweriq -d manpoweriq -f manpoweriq_backup.sql
In pgAdmin: right-click the manpoweriq database → Backup… → choose Custom format → Backup.
Restore (pg_restore)
# Into a fresh/empty database
pg_restore -h localhost -U manpoweriq -d manpoweriq --clean --if-exists manpoweriq_backup.dump
# Plain SQL dump
psql -h localhost -U manpoweriq -d manpoweriq -f manpoweriq_backup.sql
In pgAdmin: right-click the target database → Restore… → select the dump file → Restore.
When to use which
| Goal | Use |
|---|---|
| Preserve real/working data and restore it later | pg_dump / pg_restore (this page) |
| Reset to the seeded baseline (lose data) | drop + recreate + reseed |
Gotchas / constraints
- Restoring does not run EF migrations — a
pg_restorereproduces the schema as it was dumped; it does not advance__EFMigrationsHistorybeyond the dump's state. To move to a newer schema after restore, rundotnet ef database update(see Migrations). - RLS roles — the runtime app role is RLS-bound; back up/restore as the owner (
manpoweriq) which hasBYPASSRLS. - The Hangfire schema is separate (
hangfireschema); include/exclude it deliberately depending on whether you want queued jobs preserved. - Don't use drop+recreate as a "backup" — it discards data and restores only the seed baseline.
Build status
Available — standard Postgres tooling works against the documented local DB. There is no automated/scheduled backup pipeline (none is documented); that would be part of a hosted deployment (see Deployment).
Related
- Local run & reset · Migrations · Deployment
- Source:
Local_Environment_Runbook.md(docker DB + reset); standard PostgreSQLpg_dump/pg_restore.