What needs to be backed up
A Rereflect deployment has two categories of data that matter for recovery: the PostgreSQL database and the environment secrets.
The database holds everything: organizations, users, feedback items, analysis results, categories, integrations, and settings. If you lose the database without a backup, that data is gone. The environment secrets — particularly SECRET_KEY and LLM_ENCRYPTION_KEY — are not stored in the database. If you lose LLM_ENCRYPTION_KEY, any LLM API keys stored in the database become unrecoverable (they are encrypted ciphertext without the key). If you lose SECRET_KEY, existing user sessions are invalidated but users can log in again.
- PostgreSQL database — all application data.
- LLM_ENCRYPTION_KEY — required to decrypt stored LLM API keys. Cannot be recovered from the database.
- SECRET_KEY — signs JWT sessions. Loss invalidates existing sessions but is not data loss.
- Any custom configuration in docker-compose.yml or .env beyond the defaults.
Backing up the PostgreSQL database
The standard PostgreSQL backup tool is pg_dump. It produces a SQL dump file that can restore the database to the exact state at the time of the dump. For a Rereflect deployment using the bundled Docker database service, you run pg_dump inside the container.
A compressed dump of a Rereflect database with a few thousand feedback items is typically a small file — tens of megabytes at most. Store it somewhere other than the host running the database: an object storage bucket (S3, Backblaze B2, Cloudflare R2), a separate server, or wherever your existing backup infrastructure is.
- docker exec rereflect-db pg_dump -U postgres rereflect | gzip > rereflect_$(date +%Y%m%d_%H%M%S).sql.gz
- Copy the dump file off the host: scp, rclone to object storage, or your preferred transfer method.
- Back up .env (including LLM_ENCRYPTION_KEY and SECRET_KEY) separately from the database dump.
- Automate with a cron job or systemd timer for unattended daily backups.
Backup frequency and retention
How often to back up depends on how much data you can afford to lose. For a team actively importing and analysing feedback, a daily backup means losing at most a day of analysis results in a worst case. For teams with high feedback import volume or active usage throughout the day, hourly backups may be more appropriate.
A practical retention policy for most self-hosted deployments: keep daily backups for 14 days, weekly backups for 3 months, and monthly backups for a year. The exact numbers depend on your storage constraints and recovery point objective (RPO). Object storage is cheap enough that over-retaining costs very little compared to the risk of needing a backup that does not exist.
Automate retention management — manual cleanup is a task that gets forgotten. Most object storage providers support lifecycle rules that automatically delete objects older than a defined age.
| Backup type | Suggested frequency | Suggested retention |
|---|---|---|
| Database dump (pg_dump) | Daily (minimum) | 14 daily, 12 weekly, 12 monthly |
| Environment secrets (.env) | On any change | Encrypted, stored in secrets manager or separate secure location |
| docker-compose.yml | On any change | Version-controlled in a private repo |
Restoring from a backup
A backup you have never tested is an assumption, not a guarantee. The restore process for Rereflect is straightforward, but you should run through it at least once to verify it works before you need it in an emergency.
To restore: start with a fresh Rereflect stack (or stop the existing one), drop and recreate the database, then load the dump. With the bundled Docker database service, you connect to the container and run psql to execute the dump file.
- Stop the Rereflect stack: docker compose down
- Start only the database service: docker compose up -d db
- Drop and recreate the database: docker exec rereflect-db psql -U postgres -c "DROP DATABASE IF EXISTS rereflect; CREATE DATABASE rereflect;"
- Load the dump: gunzip -c rereflect_backup.sql.gz | docker exec -i rereflect-db psql -U postgres rereflect
- Restore your .env with the original LLM_ENCRYPTION_KEY and SECRET_KEY.
- Start the full stack: docker compose up -d
- Verify: open the UI and confirm feedback, organizations, and settings are present.
Verifying backups periodically
The only reliable way to know a backup works is to restore it to a test environment and verify the result. This does not need to be elaborate — a monthly restore to a temporary Docker environment on your laptop, followed by a basic sanity check that the UI loads and data is present, is sufficient for most self-hosted deployments.
Set a calendar reminder to run through the restore procedure quarterly. It takes fifteen to thirty minutes, and it is the step that turns a backup policy into actual disaster recovery capability.
Also verify that your backup storage is accessible: download the most recent dump periodically to confirm the file is intact and the storage credentials are valid. Object storage credentials expire; automated backup jobs can fail silently. A quick periodic check that the latest backup file exists and has a reasonable size catches most failure modes before they matter.