Backing up and restoring the coordinator
The coordinator keeps all of its state in one Postgres database: users, tokens, projects, sessions, claims, intents, questions, decisions, router settings, and the audit log. Lose the database and you lose all of it. This guide shows how to back it up, what else to keep beside it, and how to restore it.
Zentri ships no backup tool. There is no zentri-server backup command, no scheduled dump, and no restore command. You use the standard PostgreSQL tools, pg_dump and pg_restore. The commands below are for the Docker Compose stack in deploy/docker-compose.yml.
Every user brings their own agent credentials. Zentri never collects, proxies, stores, or resells model access or consumer subscription tokens, so a backup of the coordinator holds no agent logins.
Before you start
Section titled “Before you start”- The Compose stack from Docker Compose, running. Run every command from the repository root, where
-f deploy/docker-compose.ymlfinds the stack. - A place off the host to keep the backup files.
- For a restore: the dump, your copy of
deploy/.env, and the key files listed below.
The database commands run sh -c inside the postgres container, so they read POSTGRES_USER and POSTGRES_DB there. They work whether you kept the default zentri for both or set your own in deploy/.env.
What to back up
Section titled “What to back up”| What | Where it lives | If you lose it |
|---|---|---|
| The database | The zentri_postgres-data Docker volume |
Everything the coordinator knows, including the audit log. |
deploy/.env and any Compose override file |
Your checkout. deploy/.env is git-ignored, so git does not keep it. |
You rebuild the settings by hand: database passwords, model settings, and the paths of key files. |
The data key, the file ZENTRI_DATA_KEY_FILE names |
The file you mount into the server | Raw prompts stored under it can never be read again. |
The bootstrap admin token, zt_a_... |
Printed once by the first serve |
The database keeps only its SHA-256 hash, so a restore cannot give the token back. |
Model API keys, the files ZENTRI_EMBED_API_KEY_FILE and ZENTRI_LLM_API_KEY_FILE name |
The files you mount into the server | You issue new ones with your model provider. They are not in the database. |
| Integration secrets | Wherever the Slack bot and the merge check run | You issue new ones. The Slack bot reads SLACK_BOT_TOKEN, SLACK_APP_TOKEN, SLACK_SIGNING_SECRET, and an integration token in ZENTRI_TOKEN. The GitHub merge check App reads ZENTRI_INTEGRATION_TOKEN_FILE, ZENTRI_GITHUB_APP_PRIVATE_KEY_FILE, and ZENTRI_GITHUB_WEBHOOK_SECRET_FILE. |
| The audit head line from step 1 | Your notes, off the host | You cannot tell whether rows were removed from the end of the audit log. |
Every Zentri token and invite is stored only as a hash. Engineers keep their own user tokens on their machines, so you do not back those up.
Back up
Section titled “Back up”1. Record the audit head
Section titled “1. Record the audit head”Every audit row holds the hash of the row before it. zentri-server audit verify walks the chain from the first row, checks every hash, and prints the hash of the last row, the head. Run it in a one-off container of the server service, which reads the database with the coordinator’s own role:
docker compose -f deploy/docker-compose.yml run --rm --no-deps server audit verifyaudit chain ok: 1234 rows, head <64 hex characters>Your count and hash differ. Rows are numbered from 1 with no gaps, so the count is also the number of the last row. Save the whole line next to the dump, and keep a copy off the host. If the chain is broken, the command prints audit chain BROKEN at seq ... and exits 1. See The audit chain and a restore.
2. Dump the database
Section titled “2. Dump the database”docker compose -f deploy/docker-compose.yml exec -T postgres \ sh -c 'pg_dump -U "$POSTGRES_USER" -d "$POSTGRES_DB" -Fc' > zentri-2026-11-30.dump-Tturns off the terminal, so the binary dump reaches the file unchanged.-Fcwrites the custom format: compressed, and read bypg_restore.pg_dumpreads one consistent snapshot, so the coordinator can keep serving while it runs. Rows written during the dump are in the next one.- Name each file by date. This guide uses
zentri-2026-11-30.dump.
Check that the file is a dump that holds the audit log:
docker compose -f deploy/docker-compose.yml exec -T postgres \ pg_restore --list < zentri-2026-11-30.dump | grep 'TABLE DATA public audit_log'It prints one line. No line, or an error, means the file is not a usable dump. Make it again.
pg_dump saves one database. It does not save the database roles. The zentri_coordinator login role and the zentri_app group role are cluster-wide, and the Compose init scripts make them again on a fresh volume, as shown in the restore.
3. Keep the secrets
Section titled “3. Keep the secrets”Copy deploy/.env, any Compose override file, and each key file from the table to your backup location. Keep the admin token where you keep other admin credentials.
Zentri runs no schedule. To back up every night, run steps 1 and 2 from cron or a systemd timer on the host, and copy the files off it.
Restore
Section titled “Restore”These steps restore into a fresh postgres-data volume: after a lost disk, on a new host, or to go back to an earlier state.
1. Put the settings back
Section titled “1. Put the settings back”On a new host, check out the same Zentri version, then put back deploy/.env, the Compose override file, and the key files at the paths deploy/.env names. Use the deploy/.env from the backup unchanged. Its ZENTRI_APP_DB_PASSWORD sets the coordinator role’s password in step 3.
2. Remove the old volume
Section titled “2. Remove the old volume”docker compose -f deploy/docker-compose.yml downdocker volume rm zentri_postgres-dataOn a new host there is no volume. Skip this step. docker compose down -v would also remove ollama-data, so this guide removes only the Postgres volume.
3. Start Postgres alone
Section titled “3. Start Postgres alone”docker compose -f deploy/docker-compose.yml up -d --wait postgresOn an empty volume, the scripts in deploy/postgres/init/ run once. They create the vector and pg_trgm extensions and the zentri_coordinator login role, with the password from ZENTRI_APP_DB_PASSWORD.
Start only postgres. A full up would run migrate, which creates the schema, and then serve, which creates a new admin and prints a new token. The dump would then collide with both.
4. Load the dump
Section titled “4. Load the dump”docker compose -f deploy/docker-compose.yml exec -T postgres \ sh -c 'pg_restore -U "$POSTGRES_USER" -d "$POSTGRES_DB"' < zentri-2026-11-30.dumppg_restore prints nothing when it succeeds. Any pg_restore: error: line means part of the dump did not load. Do not start the coordinator. Fix the cause, then go back to step 2.
5. Check the audit chain
Section titled “5. Check the audit chain”docker compose -f deploy/docker-compose.yml run --rm --no-deps server audit verifyThe line must say audit chain ok, with at least as many rows as the line you recorded. Then check that the row you recorded has the same hash. Put your row count in place of 1234:
echo "SELECT encode(hash, 'hex') FROM audit_log WHERE seq = 1234;" | docker compose -f deploy/docker-compose.yml exec -T postgres \ sh -c 'psql -U "$POSTGRES_USER" -d "$POSTGRES_DB" -At'It must print the head you recorded. Each hash covers the row before it, so a match shows that every row up to that one came back unchanged.
6. Start the coordinator
Section titled “6. Start the coordinator”docker compose -f deploy/docker-compose.yml up -dcurl -s http://127.0.0.1:8080/readyzUse your ZENTRI_PORT in place of 8080 if you set one.
{"status":"ready"}migrate runs migrate up as the database owner. A dump from the same version has nothing to apply. A dump from an older version is brought up to the current schema. serve finds the restored admin, so it creates none and prints no token. Use the admin token you kept.
Ask an engineer to run zt status. It shows their user when their token came back with the database.
The audit chain and a restore
Section titled “The audit chain and a restore”The coordinator writes each audit row with the next number and the hash of the row before it. Its database role can add and read audit rows, but cannot change or delete them. audit verify recomputes every hash in order and stops at the first row that does not fit:
Reason in audit chain BROKEN at seq N: ... |
What it means |
|---|---|
expected seq N, found M: rows are missing |
Rows before row M were removed. |
prev_hash does not match the previous row's hash |
A row was changed, inserted, or removed. |
hash does not match the row's contents |
A row was changed. |
detail is not valid JSON |
A row’s detail was changed outside the coordinator. |
A restore changes the chain in ways that audit verify alone cannot show:
- Rows written after the dump are gone. The restored chain is shorter, and it still verifies, because the chain cannot show rows missing from the end. Comparing heads is what shows it.
- The coordinator goes on from the restored head. New rows take the numbers of the lost ones, with different hashes. A head you recorded after the dump will not match at its number any more. After a restore that is expected. Note the restore and the new head in your records.
- The hashes are plain SHA-256 with no secret key. Anyone with the database owner’s password can rewrite the whole chain so that it verifies. The head lines you keep off the host are what show such a rewrite.
- A dump of a broken chain restores broken. Step 1 of the backup tells you which kind you are keeping.
What can go wrong
Section titled “What can go wrong”| Symptom | Cause and fix |
|---|---|
pg_restore reports objects that already exist |
migrate or serve ran on the new volume before the restore. Go back to step 2 of the restore. |
pg_restore reports a missing role zentri_app |
The init scripts did not run, because the volume was not empty or the database is not the Compose one. Create the roles as deploy/postgres/init/002-coordinator-role.sh does, then restore again. |
The server cannot log in as zentri_coordinator |
ZENTRI_APP_DB_PASSWORD changed after the volume was created. The init script sets the password once. Use the value from the backup, or remove the volume and restore again. |
The server logs intents: raw prompt does not decrypt |
The data key is missing or different. Put back the key from the backup. Prompts sealed with a lost key cannot be recovered. |
serve printed a new bootstrap token |
The database was empty when serve started. Go back to step 2 of the restore. |
| An engineer’s token is refused | The token was made after the dump, so its hash is not in the restored database. An admin creates a new invite for the user, and creates the user first if it was added after the dump. The engineer runs zt login with it. |
| A revoked token works again | It was revoked after the dump. Revoke it again. |
| A session that started after the dump fails its hooks | Its session token is not in the restored database. End it on the engineer’s machine and start the task again. |
| Sessions show as running that are not | They were live in the dump. The coordinator marks a silent session abandoned after 10 minutes, counted from its own start at the earliest. |
Limitations
Section titled “Limitations”- Zentri has no backup command, no schedule, no retention, and no point-in-time recovery. For point-in-time recovery, set up Postgres WAL archiving yourself. Zentri does not configure it.
- The restore steps are not tested by Zentri.
- The Compose file calls itself a local development stack, and this guide covers only Compose. The Helm chart’s evaluation Postgres has no backups. For a Postgres you run yourself, with Compose or the Helm chart, run
pg_dumpandpg_restoreagainst it as the owner role, and create the roles before the restore. - The audit head is exported only when you run
audit verifyand keep its line. Zentri has no signed or remote anchor for the chain. zentri-serverhas no command to make a new admin token while an admin exists. If the restored database has an admin and no one holds a working admin token,zentri-serveroffers no way to make one.