Edgeweir
Operations

Backup and recovery

Backup and restore of the database, master key, ClickHouse, and node state; node resynchronization, restore acceptance, and restore drills.

What to back up

ObjectLocationMethodConstraint
PostgreSQLDatabase edgeweirpg_dump --format=customUse PostgreSQL tools of the server's major version (PostgreSQL 18 in compose.yml)
EDGEWEIR_MASTER_KEY.env, or the file EDGEWEIR_MASTER_KEY_FILE namesOffline copy, stored apart from database backupsWithout it the encrypted data in the database cannot be decrypted; see data sealed with the master key
EDGEWEIR_MASTER_KEY_PREVIOUS.env during a rotationStored with the master keyNeeded by backups taken before the rotation finished
BETTER_AUTH_SECRET.env (if set)Stored with the master keyWhen unset, the session secret is derived from the master key
Deployment configuration.env, compose.yml, compose.override.ymlFile copiesStore a .env that holds keys like the keys
ClickHouseVolume clickhouse-data (with EDGEWEIR_ANALYTICS=clickhouse)Volume copySame restore point as PostgreSQL; see ClickHouse
Node state/var/lib/edgeweir-node on each nodeLocal backup on the nodeHolds the node's private key and config/receipts.json; the private key is never uploaded to the console
Node cache/var/cache/edgeweir-node on each nodeNot backed upRebuilt

With EDGEWEIR_ANALYTICS=lite (default) access logs and statistics are in PostgreSQL and part of the database backup.

Backups contain account data, audit logs, and access logs; restrict who can read them. Pass database credentials through a restricted .pgpass or environment variables, never on the command line or in Git.

Data sealed with the master key

The master key encrypts this data before it is written to the database; each ciphertext is bound to its table, column, and record:

DataUsed for
Private keys of the node channel CA and the Origin CAIssuing node certificates, node channel server certificates, origin certificates, and origin client certificates
Certificate private keys, ACME accountsSite HTTPS and certificate renewal
DNS credentials, DNS provider credentialsACME DNS-01 and DNS scheduling
S3 origin keys, site secrets, access authentication secrets, origin client certificate keysOrigin requests and access control
Alert channel configuration, SMTP settingsAlert notifications
Challenge keys, TLS session ticket keysChallenges and TLS session resumption on nodes
Custom ACME directory settings, setup token, session secret kept after a rotationSystem settings and sign-in

1. Create a backup

Docker Compose built-in database:

umask 077
docker compose exec -T postgres pg_dump -U edgeweir -d edgeweir --format=custom > edgeweir.dump
docker compose exec -T postgres pg_restore --list < edgeweir.dump > edgeweir.dump.list

External PostgreSQL:

umask 077
pg_dump --format=custom --file=edgeweir.dump --dbname=edgeweir
pg_restore --list edgeweir.dump > edgeweir.dump.list

Verify:

grep -c 'TABLE DATA' edgeweir.dump.list
grep -c '__drizzle_migrations' edgeweir.dump.list

Expected: both counts are greater than 0.

DeploymentBackup method
deploy.sh./deploy.sh backup (runs automatically before update): writes the same edgeweir.dump, a copy of .env (master key, EDGEWEIR_MASTER_KEY_PREVIOUS, and BETTER_AUTH_SECRET commented out), and the compose files; keeps the latest EDGEWEIR_BACKUP_KEEP backups (default 5); see the deploy.sh reference
RenderDatabase page Recovery → Create export; see Render
Zeaburpg_dump in the postgresql service, or that service's Backup page; see Zeabur
Other platformsThe platform database's snapshot or export, or pg_dump on a host that can reach the database

Scheduled backups

crontab example for a Docker Compose deployment, daily at 03:00, kept for 14 days:

crontab
0 3 * * * cd /opt/edgeweir && umask 077 && docker compose exec -T postgres pg_dump -U edgeweir -d edgeweir --format=custom > backups/edgeweir-$(date +\%Y\%m\%d).dump && find backups -name 'edgeweir-*.dump' -mtime +14 -delete

deploy.sh deployment:

crontab
0 3 * * * cd /www/dk_project/edgeweir && ./deploy.sh backup
ItemRequirement
StorageCopy to another host or object storage, apart from the master key
Checkpg_restore --list on every backup
DrillRestore into an isolated environment regularly, as in restore drills

2. Restore

Verify in an isolated environment first. Requirements for the restore environment:

ItemRequirement
Master keyEDGEWEIR_MASTER_KEY at backup time. If the key was rotated after the backup, use the new key and set the old one as EDGEWEIR_MASTER_KEY_PREVIOUS. With a wrong key the console refuses to start: EDGEWEIR_MASTER_KEY does not match this database
BETTER_AUTH_SECRETThe original value if it was set; derived from the master key otherwise
Node channel URLThe original EDGEWEIR_NODE_API_URL and EDGEWEIR_NODE_API_HOSTNAMES: enrolled nodes check the certificate against the names at enrollment. A URL saved in System settings is in the database and comes back with it
Console versionSame as or newer than the backup: migrations only go forward; see downgrade
Background jobsOnly one restore environment at a time may run background jobs against real DNS providers and alert channels; drills use ROLE=app or local mock services

deploy.sh

In the deployment directory of a deploy.sh deployment:

./deploy.sh restore backups/20261001-080000

Backs up the current database, stops the console, drops and recreates the database, imports edgeweir.dump from the backup, then starts and waits for the health check. .env is unchanged and must hold the master key from the table above. Prerequisites and failure behavior: deploy.sh reference.

Docker Compose

On a new host or in a new Compose project:

  1. Place compose.yml, the original .env, and edgeweir.dump.

  2. Start an empty database:

    docker compose up -d --wait postgres
  3. Import:

    docker compose exec -T postgres pg_restore -U edgeweir -d edgeweir --exit-on-error < edgeweir.dump
  4. Start the console:

    docker compose up -d
  5. Verify: curl -s http://127.0.0.1:3000/healthz returns "status":"ok".

To replace the database of an existing deployment, stop console, recreate the database with dropdb --force and createdb, then import; steps in downgrade from a backup.

External PostgreSQL

  1. Restore into a new database:

    createdb edgeweir_restored
    pg_restore --exit-on-error --dbname=edgeweir_restored edgeweir.dump
  2. Point the console's DATABASE_URL at edgeweir_restored, configure it as in the table above, and start it.

  3. Verify: curl -s http://127.0.0.1:3000/healthz returns "status":"ok".

3. Resynchronize nodes

  1. With the CA restored from the database, enrolled nodes reconnect over mTLS. Wait until every node reports a heartbeat after the restore; heartbeats from before it do not count.
  2. Publish a configuration once (any site or cluster change).

Revision number rules:

RuleDescription
New numbermax(latest revision in the database, highest applied revision verified by receipts from this cluster's nodes) + 1
Unchanged contentA higher number is still created when nodes are ahead; nodes do not stay on their last good configuration
ReceiptsBound to node, cluster, revision, and content hash, authenticated with the master key; unverified numbers are ignored
ExampleRevision 112 at backup → nodes applied 113 → first publish after the restore is 114

Upgrade old nodes and let them sync a configuration before the backup; node state backups keep config/receipts.json.

4. Restore acceptance

CheckPass condition
Console/healthz returns "status":"ok"; no "level":"error" lines in the log
Sign-inThe original account signs in with its password and two-factor authentication
Encrypted dataNo cannot re-seal or cannot upgrade a legacy envelope in the log; certificate states on the Certificates page match the backup
Nodes"Online" under Clusters & nodes
ConfigurationNodes are "In sync": applied revision equals the latest revision, same content hash
Data planeNode data planes are healthy; HTTP and HTTPS requests through the nodes succeed

After acceptance keep the old database and handle it per the backup retention policy.

ClickHouse

Volume backup for Docker Compose (COMPOSE_PROFILES=analytics):

docker compose stop clickhouse
docker run --rm -v edgeweir_clickhouse-data:/data:ro -v "$PWD":/backup alpine \
  tar czf /backup/clickhouse-data.tar.gz -C /data .
docker compose start clickhouse

The volume is named <Compose project name>_clickhouse-data; the project name in compose.yml is edgeweir.

RuleDescription
Restore pointClickHouse and PostgreSQL come from the same restore point, or writing starts in a new ClickHouse database (EDGEWEIR_CLICKHOUSE_DATABASE)
Batch sequenceRestoring older PostgreSQL cursors while keeping newer ClickHouse tables can collide with existing batch sequence numbers
Across storesNot restored automatically; a successful PostgreSQL restore does not mean ClickHouse is restored
Without a backupAccess logs are deleted after their retention anyway; old logs can be dropped and writing started in a new database

Restore drills

Manual drill on a host isolated from production:

  1. Restore the latest backup as in Docker Compose with the production master key in .env, and set ROLE=app (services.console.environment.ROLE in compose.override.yml): no worker runs, so nothing is sent to real DNS providers or alert channels.
  2. Keep production nodes away from the drill: do not change DNS, do not open the node channel port.
  3. Check the console, sign-in, and encrypted data as in restore acceptance.
  4. Record the restore time and the backup's point in time, then remove the drill: docker compose down -v.

Automated drill script:

node scripts/e2e-restore.mjs
ItemDescription
ScopeOnly the test database of compose.e2e.yml. pnpm e2e includes this drill; running it alone needs a running e2e environment and .e2e/m5-state.json from the earlier steps
StepsRuns a real pg_dump; a node applies a revision higher than the backup; creates a new database and runs pg_restore; switches the console's connection; after a new heartbeat, publishes the same content; confirms that the node accepts a higher revision. Then switches back to the original test database and resynchronizes, keeping the restored database for inspection
Result.e2e/restore-result.json
ConstraintNever use the test data and credentials in a real deployment
Edit on GitHub

On this page