Backup & Restore

PostgreSQL backup procedures and restore verification

This runbook covers PostgreSQL backups and basic restore verification.

Backup (PostgreSQL)

  1. Ensure DATABASE_URL is set in the environment.
  2. Run the backup script:
$bash scripts/ops/backup-postgres.sh

The script writes a timestamped dump to BACKUP_DIR (defaults to ./backups).

Verify Backup

  1. Restore into a temporary database.
  2. Run a few sanity queries (users, networks, posts).
  3. Delete the temporary DB after verification.

Restore (PostgreSQL)

  1. Create a new empty database.
  2. Restore with pg_restore:
$pg_restore --clean --if-exists --no-owner --no-acl --dbname "$DATABASE_URL" ./backups/pg-<timestamp>.dump

R2 / Media

R2 backups are not automated yet. If needed, use rclone or Cloudflare’s export tooling to snapshot the bucket.

Automation Hook

Use the script below in cron or your CI scheduler:

$bash scripts/ops/backup-postgres.sh