> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.recursiv.io/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.recursiv.io/_mcp/server.

# Backup & Restore

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
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`:

```bash
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
bash scripts/ops/backup-postgres.sh
```