Backup and Restore
TotalBase has no backup mechanism of its own: PostgreSQL already has the right tools. Back up an instance like any production PostgreSQL workload, plus two things that live outside the database.
What to back up
| What | Where | Why |
|---|---|---|
| The database | POSTGRES_DB, whole | Your data and TotalBase's own totalbase schema together: permissions, DataViews, audit log and resource identity only make sense alongside the tables they describe |
| Uploaded files | the volume at files.storage_local_path (/var/lib/totalbase/files) | The database holds files' details; their content is on disk |
| The master key | TOTALBASE_MASTER_KEY, or the file /var/lib/totalbase/master.key TotalBase generated (Status shows which) | It decrypts the stored secrets and is never in the database |
INVALID_MASTER_KEY.How
pg_dump -Fcfor logical backups;pg_basebackupand WAL archiving for point-in-time recovery.- A managed PostgreSQL's own backups work unchanged.
- Back up the files volume at about the same time as the database, so a file's details and its content match.
pg_dump -Fc -h db.internal -U totalbase acme > acme-$(date +%F).dump
tar -czf files-$(date +%F).tgz -C /var/lib/totalbase files
Restoring
- Restore the database (
pg_restore) and the files volume. - Start TotalBase against it with the same master key - the variable, or the file back in the data directory.
- Check
/health/ready, sign in, and try a read and a write.
On start, TotalBase verifies its migrations and the master key before taking requests.
Data events and runs that were in progress when the backup was taken may run again or not at all after a restore: check workflows that call other systems.
Try it
A backup that was never restored is a hope. Restore into a throwaway database now and then, after major schema changes and on a schedule, and start an instance against it.
The repository's scripts/backup-restore-check.sh automates the mechanical part as a smoke check: it dumps the database, restores it into a throwaway database, compares row counts of a few totalbase tables, and cleans up. It never writes to the source database.