Backup and restore
Back up the metadata database and the attachment bucket as one logical unit. A database restore without the matching objects leaves attachment metadata pointing at missing bytes; a bucket restore without the database loses the review and audit context.
What to back up
Section titled “What to back up”- Metadata — Postgres database or SQLite file. Includes tenants, users, API keys, towns, parcels, captures, attachments, audit events, sessions, rate-limit counters, retention settings, webhook endpoints, and deliveries.
- Attachments — S3-compatible bucket or local attachment directory.
- Configuration — environment variables and secret references, not their values, in your secret manager or deployment configuration.
- Backup keys — the encryption keys or KMS configuration needed to restore.
Postgres
Section titled “Postgres”Use a consistent logical dump:
pg_dump --format=custom --no-owner --file=commitment-desk.dump "$DATABASE_URL"pg_restore --clean --if-exists --no-owner --dbname "$RESTORE_DATABASE_URL" commitment-desk.dumpFor larger deployments, use your provider’s continuous backup or snapshot capability and verify point-in-time recovery. A snapshot must be taken with the bucket snapshot or at least a known bucket version.
SQLite
Section titled “SQLite”Stop the API or use SQLite’s online backup command. Copy the database and any -wal/-shm files
together, or checkpoint first:
sqlite3 .data/commitment-desk.sqlite "PRAGMA wal_checkpoint(TRUNCATE);"cp .data/commitment-desk.sqlite backup/commitment-desk-$(date +%F).sqliteDo not copy only the main file while the service is writing unless you also capture the WAL.
Attachments
Section titled “Attachments”S3-compatible
Section titled “S3-compatible”Use versioning and replication where available, and copy the bucket with the tool for your provider:
aws s3 sync s3://commitment-desk-attachments backup/attachments --endpoint-url "$S3_ENDPOINT"The bucket contains tenant-scoped keys. Preserve key names exactly; restoring into a different prefix will break attachment metadata.
Filesystem
Section titled “Filesystem”Archive the attachment directory with the database backup:
tar -czf backup/attachments-$(date +%F).tar.gz -C .data attachmentsRestore procedure
Section titled “Restore procedure”- Stop the API so no writes occur.
- Restore the metadata database into an empty database.
- Restore the attachment bucket or directory with the same keys.
- Set the same
WEB_BASE_URL, storage driver, and bucket settings. - Start the API and confirm
GET /v1/healthreturnsok. - Sign in with a synthetic reviewer where available and confirm capture lists, detail, attachments, and audit events load.
- Run the shared contract suite against a restored staging copy when possible.
DATABASE_URL=postgres://... pnpm --filter @commitment-desk/api-node migratepnpm --filter @commitment-desk/api-node testVerification checklist
Section titled “Verification checklist”- Health endpoint responds.
- A capture detail loads and its attachment metadata matches an object in the bucket.
- Audit events are present and ordered.
- Exports return the expected capture count.
- Webhook endpoints and delivery history are present.
- Deleted or expired captures remain absent from lists and exports.
- Secrets and API keys still authenticate; revoke and reissue any key exposed during recovery.
Retention and encryption
Section titled “Retention and encryption”Backups contain sensitive data. Encrypt them, restrict access, and apply a retention period that matches the tenant policy. Deleted live data may remain in older backups; document that in the operator’s retention policy and rotate backups accordingly.
Rollback
Section titled “Rollback”If a restore fails verification, keep the failed environment isolated, restore the previous backup set, and compare counts before reopening the service. Do not partially restore attachments into a live bucket.