Backup & restore

What to back up on a d0pe box, and how to restore it.

A d0pe install is a few Docker volumes and one .env. Back up three things and you can rebuild anywhere: Postgres (the transactional truth — leads, flows, partners, ledger, users), ClickHouse (analytics), and .env (your secrets and license binding). Redis is a hot-path cache and doesn't need backing up.

One command

From your install directory, run the backup script. It's read-only and safe on a live instance; it writes a single timestamped archive.

./backup.sh    # → ./backups/d0pe-YYYYmmdd-HHMMSS.tgz.gpg

The archive is encrypted with a passphrase you set (gpg), because the env.bak inside holds DB passwords, your license key and any provider credentials. Store it off the server and keep the passphrase safe — without it the backup can't be restored. (No gpg on the box? The script warns and leaves it unencrypted — install gnupg to encrypt.)

By hand

If you prefer explicit commands, the important pieces are the Postgres dump and .env:

docker compose exec -T postgres pg_dump -U crm crm | gzip > postgres.sql.gz
cp .env env.bak
# analytics (optional — ClickHouse can be re-derived):
docker run --rm --volumes-from $(docker compose ps -q clickhouse) \
  -v $PWD:/backup alpine tar czf /backup/clickhouse.tgz -C /var/lib/clickhouse .

Restore

On a fresh install, bring up the datastores, load the dump, then start the app. The restore script does this in order:

./restore.sh backups/d0pe-YYYYmmdd-HHMMSS.tgz

Migrating to a new machine? Restore is only half of it — you also rebind the license. See “Move to another server”.