TotalBase
Operations

Backup and Restore

What to back up: the database, files and the master key.

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

WhatWhereWhy
The databasePOSTGRES_DB, wholeYour data and TotalBase's own totalbase schema together: permissions, DataViews, audit log and resource identity only make sense alongside the tables they describe
Uploaded filesthe volume at files.storage_local_path (/var/lib/totalbase/files)The database holds files' details; their content is on disk
The master keyTOTALBASE_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
Without the master key, a restored database works, but every stored secret (the SMTP password, providers' client secrets, the embedding secret) is unreadable and must be entered again. A different key fails startup with INVALID_MASTER_KEY.

How

  • pg_dump -Fc for logical backups; pg_basebackup and 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

  1. Restore the database (pg_restore) and the files volume.
  2. Start TotalBase against it with the same master key - the variable, or the file back in the data directory.
  3. 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.

Next steps