Protect the snapshot and its recovery inputs
Store an encrypted PostgreSQL dump and manifest, the exact image or source revision and
matching built image, the deployment configuration and credentials, and the proxy and TLS
state. The dump includes sensitive metadata, audit history and delivery state alongside
encrypted vault records. Back up the original sealing-key file (pepper) alongside the database
backup in protected storage. Preserve its bytes and permissions. Use the mounted
TERMSHEEP_PEPPER_FILE if configured, otherwise pepper inside TERMSHEEP_DATA_DIR.
The database dump alone cannot open sealed server credentials.
A server backup cannot recover device-only or unsynced records or the client's Emergency Kit. Back up desktop, MCP and signer local stores separately if used. Keep the client's Secret Key, account recovery code and any second-factor recovery codes in protected storage.
Take a backup
Use Bash, Docker Compose, jq, OpenSSL and curl. Keep the scripts from the repository's
docker/ directory together and run from the live installation directory. Set
COMPOSE_PROJECT_NAME to the live project if you installed with an explicit project name.
Keep the installation’s complete Compose file list in COMPOSE_FILE in .env, including
every release override or
source override.
/path/to/docker/backup.sh /protected/backups/termsheep-example secrets/pepper
For a server-managed pepper, omit the script argument and copy the original managed file
separately. The script’s historical database-managed manifest label in that case only means
no external file was supplied. Choose a new backup directory.
The manifest records the image identity, pepper mode and dump checksum, with the time just
before the snapshot.
Restore privately on a fresh cluster
Prepare an empty PostgreSQL cluster in a separate installation directory and Compose
project. Use the same PostgreSQL major version and recorded platform image. Set a free
loopback port distinct from live, for example TERMSHEEP_HOST_PORT=18080 and
TERMSHEEP_PUBLIC_URL=http://127.0.0.1:18080. For source Compose set
TERMSHEEP_PORT=127.0.0.1:18080 instead of TERMSHEEP_HOST_PORT. Keep user traffic and
outbound SMTP and webhooks blocked until verified. Restore the original pepper to the protected
external mount or to the persistent managed data directory before the server starts.
Copy the installation’s Compose files, including all overrides, into the recovery directory.
Set COMPOSE_FILE in that directory’s .env to the same complete list and order. Each step must succeed before the next
runs. The TCP check waits for the permanent PostgreSQL listener before provisioning roles.
The temporary server used during initialization can respond on the local socket.
export COMPOSE_PROJECT_NAME=termsheep-recovery
docker compose up -d --wait db &&
(
attempts=30
until docker compose exec -T db pg_isready -h 127.0.0.1 -p 5432 -t 1 -U termsheep -d termsheep >/dev/null 2>&1; do
attempts=$((attempts - 1))
if [ "$attempts" -eq 0 ]; then
printf '%s\n' 'PostgreSQL did not start listening on TCP.' >&2
exit 1
fi
sleep 1
done
) &&
docker compose exec -T db psql -X -v ON_ERROR_STOP=1 -U termsheep -d termsheep < /path/to/docker/restore-roles.sql &&
/path/to/docker/restore.sh /protected/backups/termsheep-example secrets/pepper &&
/path/to/docker/start-restored.sh
For a server-managed pepper, omit the script argument and verify the restored managed file against your protected copy yourself. The restore script checks the dump, image, external pepper when supplied, and roles before applying the dump in one fail-fast transaction. The release stack reapplies split logins through its migration service. Keep the live database untouched.
Verify before reconnecting
Check readiness, then sign in from a clean client. Verify a configured second factor and decrypt representative data using the original client credentials. Check tenant isolation and audit continuity including export continuation. Review pending deliveries and access changes, especially revocations since the snapshot and messages that could be sent again. Record how long recovery took and which writes since the snapshot need reconciliation. Restore traffic only after those checks.
A historical local ARM64 rehearsal, before the server moved its sealing key out of the database, took 59 seconds with an external pepper and 53 seconds with a database-managed pepper. It verified fixture sign-in, not a populated production dataset or recovery time commitment. Rehearse on your intended data and release. See the recovery runbook for the built-in drill.