Backup and restore
A backup captures three things from a running deployment: the database, the world-model folder (a Docker volume holding the domain model plus every generated migration an approved model publish has ever written), and the Keycloak realm. Restoring onto a clean host needs all three — without the world-model folder a restored deployment cannot boot, because the database records a schema version whose file lives only there. A nightly timer runs the same backup script an operator would run by hand, so the scheduled path never drifts from the tested one.
Backups are written to the same disk as the deployment they protect. Losing the host loses both. The schedule protects against operator error, bad migrations and corruption — not against losing the machine.
The bundle is sensitive. It holds a full database dump, and Keycloak
shares that database, so its credential and client tables are in there. It is
written mode 0600 and must stay unreadable to other accounts. What is not
in it is the encryption key (KEK): a restored database is unreadable for
vault data without it, which is deliberate. A restore of a bundle needs the key
of the Key version line in its BACKUP_INFO.txt, and each older key
(docs/runbooks/vault-key-rotation.md).
How much work can be lost, and how long until you are back
Two numbers every operator is entitled to before an incident, not during one. The industry names them RPO (recovery point objective — how much recent work a recovery may lose) and RTO (recovery time objective — how long being back takes).
| Today’s honest answer | |
|---|---|
| How much work can be lost | Up to 24 hours. The timer runs nightly, so anything done since the last successful run is gone. |
| How long recovery takes | Not yet measured on a country-sized deployment. The drill restores a freshly migrated database in well under a minute; that is a floor, not a promise. Restore time grows with the size of the dump. |
| If the machine itself is lost | Everything is lost. Bundles are written to the same disk as the deployment. There is no offsite copy and nothing in this repo makes one. |
The last row is the one to act on. The nightly schedule protects against operator error, a bad migration and corruption. It does not protect against losing the host, and no amount of scheduling changes that — copying bundles somewhere else is a separate decision nobody has taken yet.
These are stated rather than implied because an unstated objective is agreed to by nobody and discovered during the incident.
Proving a bundle can actually be restored
A backup nobody has restored is a hypothesis. scripts/restore_drill.sh turns it
into a fact: it brings up a throwaway deployment, runs the real migration chain,
writes a sentinel value invented for that run, takes a bundle, destroys the
deployment including its volumes, restores from the bundle, and checks the
sentinel came back with the value that run invented — so a restore that quietly
kept the original database still fails.
bash scripts/restore_drill.sh # must exit 0
bash scripts/restore_drill.sh --corrupt # truncates the bundle; restore must refuse
The second command is not optional. A drill that only ever runs the happy path
cannot tell “restore works” from “the check is vacuous”. .github/workflows/ nightly-restore-drill.yml runs both every night. The workflow deliberately has no PR trigger under the current runner policy; dispatch it against a changed branch before landing with gh workflow run nightly-restore-drill.yml --ref <branch>, or run the isolated drill locally.
--skip-oidc is refused: a drill without the identity server cannot establish recovery of either population. The default drill verifies existing passwords and signing keys for both realms after the volumes are destroyed and restored.
The default drill also tests an older backup over later vault erasures.
After scripts/backup.sh creates the bundle, the drill erases one full vault
and one second card. Next, the drill runs scripts/restore.sh over that live
database and runs the startup database seed. The drill checks that the carried
erasures repeat, the remaining vault data stays readable, and the vault opens
again. For fault cases such as a stopped load, run
scripts/restore_vault_proof.py as well. Read “Proving that a restore repeats
the vault erasures” below.
Taking a backup
bash scripts/backup.sh
Writes backups/opengov-<timestamp>.tar.gz, containing:
| File | What it is |
|---|---|
db.dump | pg_dump custom-format snapshot of the opengov database |
worldmodel.tar.gz | Every file in the world-model folder — the domain model plus generated migrations |
keycloak-realm.json | Staff realm export; configuration-only fallback requires verified shared-database recovery |
keycloak-applicants-realm.json | Applicant realm export when installed, required even with registration closed |
KEYCLOAK_CAPTURE.json | Checksummed required-realm inventory and recovery mode (live_export or shared_database) |
SECRETS_MANIFEST.md | What to capture out-of-band (the KEK is NOT bundled — see above) |
BACKUP_INFO.txt | Timestamp, git SHA, container/volume names, which deployment it is, and the schema versions the database recorded |
SHA256SUMS | Checksums for every file above, BACKUP_INFO.txt included |
Container and volume names are resolved from docker compose automatically
— override with PG_CONTAINER=, KC_CONTAINER=, or WM_VOLUME= only when
Postgres or Keycloak runs outside compose.
Before the bundle is sealed, the script checks that every schema version the dump records has its migration file in the folder it just copied. If a publish lands mid-capture it retries up to three times; if it still cannot get a consistent pair it writes nothing and says so. A bundle that fails this check is one that would not boot, so shipping it would be worse than shipping none.
Old bundles are pruned by count, not age: the last OPENGOV_BACKUP_KEEP
bundles are kept (default 14, minimum 1 — 0 and typos are refused rather
than silently deleting everything). Age-based pruning on a host whose timer
has been broken for a month would delete the last good backup.
Restoring
Destructive twice over. It drops and recreates the opengov database,
and it erases the world-model folder, replacing it with the bundle’s copy.
Any model publish made after the bundle was taken is gone and cannot be
recovered from anywhere.
bash scripts/restore.sh backups/opengov-<timestamp>.tar.gz
The script prompts for the database name before doing anything destructive. To run it unattended, set the confirmation to the bundle’s own filename:
OPENGOV_RESTORE_CONFIRM=opengov-<timestamp>.tar.gz \
bash scripts/restore.sh backups/opengov-<timestamp>.tar.gz
It names the bundle on purpose. A fixed word left in a shell profile or a unit’s environment file would pre-authorise every future restore on every host; a filename authorises exactly one.
Refusals, all of them before anything is touched:
| It refuses when | Why |
|---|---|
opengov, worker or init are running | Wiping the folder under a live publish manufactures the corruption you are recovering from |
| any container at all still mounts the world-model volume | The compose check only sees the project it resolves to; this one cannot fail open when the stack was started under a different project name |
| the database container is unreachable | Discovered up front, so the folder is never erased by a run that then aborts |
| the database answers the question about its deployment, and does not give its list of vault erasures | Nobody then knows who erased. The script stops and changes nothing. Run it again. See “After a restore: the vault erasures” below |
| the bundle names a different deployment than this host already runs | Every deployment resolves to the same volume and database names, so nothing else would notice the wrong bundle. Override with OPENGOV_RESTORE_ALLOW_FOREIGN=yes. A host with no deployment rows yet — a genuine clean-host recovery — is allowed straight through |
Order matters: the world-model folder is restored before the database is
dropped, so a bad or missing volume archive aborts before the irreversible
DROP DATABASE. Keycloak’s realm lives in the same database as the app, so
pg_restore already restores it — the script detects this and skips a
redundant realm import (re-importing on top races the app’s own realm
reconcile and can fail).
Right after pg_restore, the script restarts the running Keycloak container
(by container id, so an out-of-compose Keycloak works too) and waits for it to
report healthy. This is not optional: Keycloak keeps a live connection pool and
in-memory session state against the database that was just dropped and
recreated underneath it, and its next admin login otherwise fails with
401 Unauthorized — observed live during the acceptance rehearsal.
Finally it re-checks the pair from the other side: every schema version the restored database records must have its file in the folder. If one is missing it says so and tells you not to start the deployment.
A bundle taken before world-model capture shipped has no worldmodel.tar.gz.
If its database records an approved model publish, that bundle cannot be
restored — the migration it needs exists nowhere. Otherwise the restore
proceeds and leaves the world-model folder untouched.
After a restore: the vault erasures
The vault is the applicant’s personal encrypted storage on the government server. An applicant can erase it, and can remove one card from it. A bundle that is older than an erase still holds the erased data. So a restore brings that data back.
The restore script and the application stop that together. The script carries the list of erasures across the replacement. The application erases again at its next start.
What happens
- The script reads the list of erasures from the database that it replaces. It reads the list before it changes anything.
- The script writes the list into the new, empty database. It does that before it loads the bundle. The list goes in a schema of its own, the carry.
- After a load with no error, the script marks the carry.
- At its next start, the application moves the list into the table
vault_restore_events. - Then the application repeats each erasure: it erases again, and it removes again each card that an applicant removed. When the applicant also erased her signed records, the repeat erases them again. The receipt of the erase records that choice.
While the list waits, the vault alone is closed. Each vault route answers 503, and each vault job does nothing. The portal, the editor and the approval workspace work as before.
No person is in these steps. A fault in one of them leaves the vault closed. It does not open a vault that holds erased data.
Step 2 is one transaction. The list is in the new database in full, or that database stays empty.
For that, the script uses the form that the psql manual promises: the
options -1 and -f - together. The option -1 puts the commands of each
-f option in one transaction. The option -f - reads the commands from
standard input. A run on PostgreSQL 18.6 with one wrong line in the list
proved it. The script stopped, and the new database had no schema and no
table.
Read the start line
The start of the application prints one line that holds vault_restore=.
Find the line in the log of the opengov container.
| The line holds | Meaning | Do this |
|---|---|---|
adopted=<n>; repeated=<n>; waiting=0 | The application repeated each erasure. | Nothing. Read the next section if a lost list waits. |
waiting= with a number above 0 | The application could not repeat one erasure or more. The vault is closed. | Read the log. Correct the cause. Start the application again. |
adopted=<n>; repeat=off | The vault is off. The erasures wait. | Nothing. The start that turns the vault on repeats them. |
unfinished | The restore did not finish. The application changed nothing. The vault is closed. | Run the restore again. |
failed | The step had a fault. The start continued. The vault is closed. | Read the log. Correct the cause. Start the application again. |
This command gives the same state at any time:
docker compose exec opengov python3 -m opengov.vault.restore status
The command prints one line that says if the vault is closed. Then it prints three numbers: the acts that wait, the lost lists with no acknowledgement, and the carry schemas. Then it lists each act that waits: the id of the row, the kind and the time of the act. It prints no login id.
The log of a deployment replaces each id with [redacted]. So a log line
about one act gives the kind of the act and the class of the fault. It does
not give the row. Use the list of the command to find the row.
When the script stops
| The script prints | Meaning | Do this |
|---|---|---|
STOPPED: this database answers, but the restore could not read its list of vault erasures. | The old database answered one question and not the next one. The script changed nothing. | Run the restore again. |
STOPPED: the old database is gone, and the list of vault erasures is not in the new one. | The script could not write the list. The new database is empty. | Run the restore again. It then records a restore with a lost list. |
STOPPED: the bundle is loaded, but the restore did not finish. | The script could not mark the carry. | Run the restore again. |
Run the restore again before you start the application. If the application starts between the two runs, the vault stays closed. The second run can then record a restore with a lost list.
Three limits
- A restore brings back a draft that the applicant deleted. It also brings back an office-held key that the applicant gave up. The application does not repeat these two acts.
- An older version of the application does not know the carry. It opens the
vault with the erased data in it. So keep the vault off until a version that
has this step runs. That version prints
vault_restore=in its start line. - The list is complete only when it comes from the database that continued from the bundle. The next section says what happens in each other case.
A restore with a lost list
Sometimes the list of erasures is lost: nobody can read who erased after the time of the bundle. This is a restore with a lost list. Treat it as a data incident. The vault can then hold data that an applicant erased, and nobody can name the persons.
The three causes
- The old database is damaged or absent.
- The host is new. Its database is empty, or the application made it a short time before.
- The old database is a different one from the database of the bundle.
How you know
The script can end with these lines. It prints them when it could read no list:
VAULT: this restore could not read the list of vault erasures. If this deployment holds vault data, the vault stays closed after the start. Read docs/runbooks/backup-restore.md, "A restore with a lost list".The application judges the list at its next start. It compares the identity of the old database with the identity of the loaded one, and two counts. So it can find a lost list that the script did not report. The log then holds the line
recorded a restore with a lost list.The
statuscommand printsLost lists with no acknowledgement: 1, or a larger number.
The application records nothing when the loaded database holds no vault data.
Open the vault again
The vault alone stays closed until an operator acknowledges the lost list.
Follow the data incident procedure of your office.
Run this command, with your own name:
docker compose exec opengov python3 -m opengov.vault.restore acknowledge --by "<your name>"Run the
statuscommand. Make sure that it printsThe vault is open.
The command writes your name and the time into the audit log. It erases nothing. It does not open the vault while an erasure waits.
What the applicants see
For 30 days after the acknowledgement, the summary of the vault gives the time
of the bundle to the portal, in the field restore_notice. The sentence for
the applicant is: “We restored an older copy on {date}. If you erased your
saved data after that date, erase it again.”
The portal shows this sentence at the top of the vault panel.
Proving that a restore repeats the vault erasures
A good run ends with a line such as 74 checks, 0 failed, and its exit
status is 0. The proof runs the vault steps of scripts/restore.sh. It does
not start that script as a whole: read “What the proof does not show”.
No automatic check starts the proof. A person starts it: read “When to run the proof”.
scripts/restore_vault_proof.py restores a backup that is older than an
erase, on a real PostgreSQL. Then it checks that the application erases
again. This section calls that run the proof. The proof uses the real
psql, pg_restore and pg_dump.
The proof holds no copy of the SQL of the restore. It cuts the shell of each
step out of scripts/restore.sh, by the first line of the step. Then it
runs that shell as it is. So the proof tests the text of the script, and
not a copy of it.
What the proof does not show
The proof does not start scripts/restore.sh as a whole. It runs the vault
steps of the script: step 3b, step 5, step 5-carry and step 5-loaded.
- Steps 3 to 7a, 8 and 9 of the run take these steps one at a time. The proof does checks between them, and it gives the values of one step to the next. The proof must stop between the load and the mark, to act as a load that stopped. A whole run of the script cannot stop there.
- Steps 7b, 7c and 7d of the run give steps 3b to 5-loaded to one shell, as one piece. The script then sets the order, and its own variables give the values. The bundle of the proof has no world-model archive, so step 4 of the script does nothing in that piece.
- No step of the run does the first part of the script. That part has the guards, the checksums, the checks of the identity files and the confirmation. No step does the last part: Keycloak and the check of the schema versions.
Two other runs start the script as a whole:
| Run | What it uses | What it does not show |
|---|---|---|
tests/test_dual_realm_restore.py | A fake docker. The test checks the order of the vault steps and the header of the carry. | The run has no real database, so no row moves. |
scripts/restore_drill.sh, in Nightly restore drill | A real PostgreSQL, the world-model volume, and both identity realms. It restores an older bundle over post-backup erasures, runs the startup seed, and tests an empty host. | It does not stop a load midway or test a second restore over a waiting carry. |
scripts/restore_vault_proof.py tests those fault cases.
When to run the proof
No pull-request check runs scripts/restore_vault_proof.py, because it needs
Docker and a test server. Run the proof before you publish a stable release,
and after each of these changes:
- a change to step 3b, step 4 or step 5 of
scripts/restore.sh - a change to
src/opengov/vault/restore.pyor tosrc/opengov/vault/erasure.py - a change to the step of the start that adopts the carry, in
src/opengov/bootstrap_deployment.py - a new major version of PostgreSQL
The automatic tests check the parts of the restore, and not the whole:
tests/vault/test_restore_read_sql.pyandtests/vault/test_restore_repeat.pytake the SQL of the script between its marker lines. They run that SQL in a test session, and they test the code that adopts the list and repeats each erasure.tests/test_dual_realm_restore.pystarts the whole script with a fakedocker.tests/test_restore_vault_proof.pyfails whenscripts/restore.shno longer has a line that the proof cuts at. It restores nothing.
Only the proof uses the real psql, pg_restore and pg_dump for the
vault steps. So a change can break the repeat of the erasures while each
automatic test passes. On 2026-10-11, one new line in scripts/restore.sh
emptied the list between two steps. Each automatic test of the restore
passed, and the proof failed 9 checks.
What the proof needs
- Docker. The command
dockermust be on thePATH. The proof callspsql,pg_restoreandpg_dumpinside a container. So the host needs no PostgreSQL client. - The shared test Postgres. This is the PostgreSQL server that the test
suite uses on a developer machine. Its container is
opengov-test-postgres-test-1, on port 5433 of the host. The container must run. It is the container thatscripts/test_local.shstarts. - A checkout with its
.venvfolder.make setupmakes that folder. The proof startsalembicand the application code from the checkout. - The password of the test account, in the environment variable
OPENGOV_RESTORE_PROOF_DB_PASSWORD. The account isopengov_test. Its password is the value ofPOSTGRES_PASSWORDfor the servicepostgres-testindocker-compose.test.yml. Set the variable in the shell. Do not put it in the.envfile of the checkout. The application reads that file, and it does not start when the file holds a name that it does not know. - No key. The proof makes three keys for each run, in the environment of its own processes. No key is in a file. Each key is gone when the run ends.
- Space on the disk of the test server. The proof starts only when less than 60 % of that disk is in use.
Start the proof
If you can, wait until no test suite uses the shared test Postgres.
Go to the root of the checkout.
Set the password of the test account:
export OPENGOV_RESTORE_PROOF_DB_PASSWORD='<the password of the test account>'Start the run:
.venv/bin/python scripts/restore_vault_proof.py
On 2026-10-11, a good run took about one minute. It took more time when a different test run used the server. It prints one line for each check.
The proof uses the checkout that holds the script. To test a different checkout, set its full path before you start the run:
export OPENGOV_RESTORE_PROOF_CHECKOUT='<full path of the checkout>'
Do not start the proof while a different person or agent writes in the checkout. The proof starts Python from that checkout.
What a good run prints
The last line of a good run is:
74 checks, 0 failed
The run had 74 checks on 2026-10-11. A change to the proof can change that number. The number of failed checks must be 0.
The last check line before it is
[ok] no probe database is left on the test server -> 0.
| Exit status | Meaning |
|---|---|
| 0 | Each check passed. |
| 1 | One check or more failed, or a command of the run had a fault. |
| 2 | The run could not start. It changed nothing. |
These are the ten steps of the run:
- Create a database, migrate it, seed it, and make a dump. The dump is the bundle.
- One applicant erases. A second applicant removes a card.
- Run step 3b of the script. It reads the list of erasures from the old database.
- Drop and create the database. Write the carry. Load the dump.
- Start the application before the script marks the carry. The application must adopt nothing.
- Run step 3b again, as a second run of the restore does.
- Mark the carry. The application must adopt the list and repeat each erasure. Then restore three more times, with steps 3b to 5-loaded of the script as one piece. The first time uses the same dump: the application must erase again. The two other times use a dump from after an erase: the application must keep the newer data.
- Restore the bundle on a new host. The application must record a restore with a lost list.
- Put one wrong line in the list. The script must stop, and the new database must stay empty.
- Drop each database.
What the proof changes on the test server
- The proof creates three databases:
restore_probe,restore_probe_newhostandrestore_probe_broken. It drops each one at its end, also after a fault. - The proof changes no other database. It does not start or stop the container.
- The proof uses space on the disk of the server while it runs. On 2026-10-11, the highest use in each of ten runs was 1 to 4 points of 100 above the use at the start. Other test runs used the server at the same time, so these numbers are not exact.
- The proof writes no file in the checkout. Its work files are in a
temporary folder with the name
vault-restore-proof-.... The proof deletes that folder at its end.
The disk of the test server is a memory disk of 1 GiB. When that disk is
full, the test Postgres stops, and each test run that uses the server fails.
The server can then start again with no database. That is the reason for
the limit of 60 %. docs/runbooks/testing-patterns.md §3.5 has the
measurements of that disk.
When the run cannot start
The run then prints one line that starts with CANNOT START:. Its exit
status is 2, and it changed nothing.
| The line holds | Do this |
|---|---|
set OPENGOV_RESTORE_PROOF_DB_PASSWORD | Set the variable. Then start the run again. |
The checkout ... has no | Run make setup in the checkout. |
The fragment | scripts/restore.sh changed. Read “When the restore script changes” below. |
does not answer | Start the shared test Postgres. The procedure is below. |
The disk of the test server is at | Wait until the other test runs end. Then start the run again. |
The test server holds | A run left its databases, or a different run is active. The procedure is below. |
To start the shared test Postgres:
Run
docker ps --filter name=opengov-test-postgres-test-1.If the list has the container, do not start it again.
If the list is empty, run this command from the root of the checkout:
OPENGOV_TEST_DB_PORT=5433 docker compose -p opengov-test \ -f docker-compose.test.yml up -d --wait postgres-test
Step 2 is important. scripts/test_local.sh uses the same command. When the
container runs, a different version of docker-compose.test.yml can make
Docker replace it. Each database on the server is then lost.
To drop the databases that a run left:
Make sure that no run of the proof is active on the machine.
Run this command:
docker exec opengov-test-postgres-test-1 psql -U opengov_test -d postgres \ -c 'DROP DATABASE IF EXISTS restore_probe WITH (FORCE)' \ -c 'DROP DATABASE IF EXISTS restore_probe_newhost WITH (FORCE)' \ -c 'DROP DATABASE IF EXISTS restore_probe_broken WITH (FORCE)'Delete each folder with the name
vault-restore-proof-...in the temporary folder of the machine.
A run can leave its databases and its folder when the operating system
stops it before its last step. On 2026-10-11, a person stopped a run with
SIGKILL. That run left one database and one folder. The next run did not
start, and the command of step 2 dropped the database.
When a check fails
A check that fails prints [FAIL]. The last lines of the run name each
failed check again, with its step and the value that the run got. The exit
status is 1.
- Keep the output of the run.
- Find the first
[FAIL]line. The later ones are frequently results of the first one. - Find the step of that check in the list of ten steps.
- Read what the step must do, in “After a restore: the vault erasures”.
- Find the change that caused the failure, and correct it.
- Run the proof again. A good run has 0 failed checks.
A line with DRIVER STOPPED means that a command of the run had a fault.
The text after it gives the last lines of that command. The run then drops
its databases.
Do not change a check to make it pass. Change a check only when the result of the step changed on purpose. Do not release a change to the restore script or to the vault restore code while a check fails. A failed check can mean that a restore puts erased data of an applicant in the vault again.
A run does not continue an earlier run. Each run makes new databases and new keys.
The proof can fail. On 2026-10-11, four faults that a person made on
purpose each gave [FAIL] lines and exit status 1:
| The fault | Failed checks |
|---|---|
The mark statement of scripts/restore.sh wrote a wrong kind. | 25 of 74 |
| The application marked an erase as repeated, and it did not erase. | 6 of 74 |
| One check of the proof expected a wrong number. | 1 of 74 |
A new line between step 4 and step 5 of scripts/restore.sh emptied the list. | 9 of 74 |
Only steps 7b to 7d of the run found the last fault. Steps 3 to 7a take the steps of the script one at a time, so they do not run a line between two steps.
When the restore script changes
The proof cuts scripts/restore.sh at the first line of each step that it
runs. The table FRAGMENT_CUTS in scripts/restore_vault_proof.py holds
these lines.
- When you change one of these lines in the script, change the same text
in
FRAGMENT_CUTS. Do it in the same change. - Run
pytest tests/test_restore_vault_proof.py. It fails until the two files agree. - Run the proof.
When the two files do not agree, the proof does not start. It does not run a fragment that is longer or shorter than the step.
Installing the nightly schedule
One command, run once per deployment host, from that deployment’s own checkout:
sudo bash scripts/install-backup-timer.sh
It installs the units, fills in this host’s account and checkout path, enables the timer, runs the first backup immediately and fails unless a new bundle actually appears. An installer that reports success without running the thing it scheduled is how a host ends up believing it has backups.
Prerequisites it checks for you, rather than letting them surface at 03:17:
- systemd, and root (
sudo) to install into/etc/systemd/system. - The account that will run the backup must be in the
dockergroup — every step of the script talks to the Docker socket. It defaults to whoever owns the checkout; override withBACKUP_USER=<account>.
Re-run it any time to pick up a change to the units; it is idempotent.
Runs nightly at 03:17 plus up to 20 minutes of jitter, and catches up on next
boot if the host was powered off at the scheduled time (Persistent=true).
When a night fails
The backup unit declares OnFailure=, which starts a small handler unit that
writes backups/LAST_FAILURE.txt on the host. That makes a broken schedule
visible to anyone who looks at the backup directory — the minimum on a host
that may have no mail and no agent.
To make it reach a person, put a command in /etc/opengov-backup.env:
OPENGOV_BACKUP_ALERT_CMD='curl -s -X POST -H "Content-Type: text/plain" --data-binary @- https://your-webhook'
It is run with the failure summary on standard input.
Check the schedule at any time with:
systemctl list-timers opengov-backup.timer
ls -l backups/ # newest bundle should be from last night
Why a timer and not a compose service
A compose sidecar was considered and rejected: it would need the Docker socket
mounted (root on the host), which is unacceptable for a self-hosted government
deployment, and still can’t run kc.sh for the realm export. A scheduled
GitHub workflow can’t reach a self-hosted host at all.
What this does not cover
- Offsite copies. Nothing moves bundles off the host. Losing the machine loses the deployment and its backups together.
- The Coolify-deployed sandbox. Its image ships no
scripts/directory, so the installer has nothing to install there. The sandbox is disposable by design; a country deployment running from a checkout is the target here. - Hosts without systemd. The installer says so and points you at
scripts/backup.shto schedule with whatever the host does use.
Two-realm identity recovery
OPENGOV_BACKUP_ROOT optionally selects an isolated output directory (default backups); bundling and retention operate only within that directory. The recovery drill uses a private directory so it cannot select or prune another run’s bundle, and forces the legacy override off.
New default backups require both realms even if a local import file is missing, and validate each independently, including user arrays, stored credentials and private key material in live exports. A configuration-only fallback is accepted only when the captured shared database actually contains every required realm; external identity databases cannot use that fallback. Restore checks the capture manifest, artifact checksums and realm membership before destruction. Existing legacy single-realm bundles retain their prior compatibility path. Only an old deployment that has never provisioned applicants may deliberately set OPENGOV_BACKUP_LEGACY_SINGLE_REALM=true; it produces a warning and cannot capture applicant identities. Never use that override to bypass a failed dual-realm export.
Shared-database recovery restores accounts and keys with the application data. For external identity databases, new bundles stage every complete realm artifact and return nonzero with identity recovery pending; startup import skips realms that already exist, so staging is not evidence of recovered users. Complete the identity-server operator restore on a clean isolated host, verify both populations and canonical ownership, then resume traffic. Do not wipe or overwrite an existing realm automatically. See applicant realm activation.
The default scripts/restore_drill.sh rehearses both identity populations: disposable accounts with stored passwords, identity-table fingerprints and public signing keys are checked after recovery alongside application/world-model sentinels. It refuses --skip-oidc, because that cannot establish account recovery. scripts/wipe_deployment.sh --keep-accounts retains both realm exports; a destructive wipe without that option removes both populations.