# Backup and restore runbook

## What is backed up

- PostgreSQL: nightly logical dump plus continuous WAL archiving.
- Object storage: versioned bucket with 30-day noncurrent retention.
- Configuration: environment templates stored in the secret manager, not the repo.

## Verify a backup

1. Restore the latest dump into a scratch database.
2. Run the integrity queries in ops/verify.sql.
3. Compare row counts for tenants, subscriptions and invoices.
4. Record the result in the operations log.

## Restore procedure

1. Put the application in maintenance mode.
2. Restore the database dump.
3. Replay WAL to the desired recovery point.
4. Restore object storage versions if attachments are affected.
5. Run smoke tests, then exit maintenance mode.

Target recovery point objective: 15 minutes. Target recovery time objective:
2 hours.
