Skip to content
Registry StackDocsv0.48.0

Back up, restore, and drill recovery

View as Markdown

Use this runbook when you operate Base Registry Engine (BReg), Registry Casework, Evidence, or Registry Messaging and need a recovery plan. Each product restores differently: BReg restores a database and then proves it is the one instance serving the registry, Casework returns to its database backup point and stays isolated while you reconcile later producer and source effects, and Evidence holds no database at all. Messaging restores a database whose dispatch state must be reconciled with sends and receipts the provider already holds. The procedures below link each product’s own guide for the details and state what a restore does not bring back. Source reads cannot reconstruct lost Casework reviews or decisions. The maintained logical-restore checks exercise backup-point state and independent audit continuity.

A PostgreSQL backup holds rows. It does not hold the audit files, the secrets, or the key material each runtime reads at startup, and several of those cannot be recreated once lost. Back up these alongside every database backup, on the same schedule:

  • The PostgreSQL database, taken with pg_dump before every activation, as an administrator:

    Terminal window
    pg_dump --format=custom --file=/srv/backup/registry-before-build-2.dump registry

    When the package declares an indexed external projection, exclude the data of its six projection and refresh tables with one pattern. The backup then holds no source values, bindings, refresh work, or selectors. Keep the tables themselves: use --exclude-table-data, never --exclude-table. Quote the pattern so the shell does not expand it.

    Terminal window
    pg_dump --format=custom \
    --exclude-table-data='registry_internal.registry_external_*' \
    --file=/srv/backup/registry-before-build-2.dump registry

    A restore then starts with an empty projection cache and no queued refresh work, as a fresh install does. BReg registers the plans from the runtime file at startup, and authorised refresh rebuilds the cache under the current binding and source grant; nothing is restored from the backup. See Back up logically in the external projections guide.

    The exclusion applies to pg_dump only. The projection tables are ordinary logged tables, so physical base backups, volume snapshots, WAL archives, and streaming replicas carry cached source values. Keep those copies no longer than the source grant permits storage. Before a physically restored copy or a promoted replica serves under changed source authority, run bregctl external-projection purge for each affected projection. See Physical backups, WAL, and replicas.

  • The package directory, the runtime file, and the secret files it references. A restore needs the package the backup was taken under.

  • The field-encryption key when the project encrypts a field: the Transit key, or the local data-key file. The database holds only a wrapped key or an identifier, so losing the custodian’s key loses every sealed value, in every backup.

  • The audit hash key named by audit.hashKeyRef. A restore under another key writes pseudonyms that no longer match the ones already in the archive.

  • The attachment bucket, when attachmentStorage binds an S3-compatible backend. The database holds references; the bucket holds the bytes, so back it up at the same point.

  • The PostgreSQL database, with a logical backup before every activation and your chosen recovery points. Record a snapshot identifier with caseworkctl apply --backup-reference.
  • The exact package directory, runtime file, and database identity, together with escrowed database credentials, audit key, optional task-authority signing key, and context-provider reader credentials.
  • The external audit journal and shipped archive. Preserve entries written after the database backup; a restore never rewinds that evidence.
  • The governed bundle, the runtime file, and the public JWK files.
  • The Transit signing key, which Transit keeps. Escrow it through your Transit backup; a local JWK signer is for local assurance only.
  • The audit master and subject-binding secrets, including every previous audit master whose pseudonyms must stay recomputable.
  • When evidence-oid4vci delivers to wallets, its separate audit journal and audit.hashKeyRef. The adapter records the authenticated offer origin and credential-release outcome under one opaque exchange identifier; Evidence’s journal records its separate authorisation and signed-response release.
  • Regular PostgreSQL backups on a schedule that meets your recovery-point objective, the maximum loss window you accept. Also take a stopped, pre-apply pg_dump for an upgrade rollback.
  • The active package directory, runtime file, and both matching binaries, messaging and messagingctl. Inspection with messagingctl needs no running send worker.
  • The referenced secret files, including the audit key (audit.hashKeyRef), database credentials, and provider credentials and callback secrets. Keep the audit key for as long as correlation with known callers or recipients is required.

A full dump contains recipient contacts, rendered parts, and submission receipts. Apply the shorter retention periods to archived copies too: a static dump never runs Messaging’s sweep. Retire Messaging describes replacing retained dumps with swept copies through the remaining payload and receipt periods.

No database backup holds a product’s audit files. Ship them to append-only storage as the retention guides describe, so the archive, not the host, is the audit record: BReg, Casework, Evidence, and Messaging. For Messaging, preserve the active file and every sealed segment of both audit.path and its messagingctl sibling. A restore never replaces the live audit directory. Apply the same rule to evidence-oid4vci when it uses a file destination; when it uses stdout, the collector’s retained stream is the journal.

Stop every breg process that serves the registry before you restore. How you restore then depends on how the copy was taken, because BReg tells a logical copy from its original but cannot tell a physical one.

A copy restored from pg_dump carries the instance claim of the database it was dumped from, so it refuses to serve: breg exits at startup with the Registry database is not the instance its claim names, and bregctl doctor reports startup.instance-claim.mismatch. A runtime that is already serving checks the claim on every readiness probe as well, and answers GET /ready with 503 once the claim no longer names its database.

Point the restored runtime file at the new database and change nothing else in it. Keep identity.instanceId in particular: the webhook deliveries pending at the backup point were captured under the event source it derives, so while any of them remains, bregctl doctor refuses a changed value with startup.instance-id.pending-deliveries and breg refuses to start. Change it, if you must, only after those deliveries drain.

Recreate the database with the database-level statements from provision PostgreSQL, which a dump does not carry, and restore the dump into it as an administrator:

CREATE DATABASE registry_restored;
REVOKE ALL ON DATABASE registry_restored FROM PUBLIC;
GRANT CONNECT ON DATABASE registry_restored TO registry_migration, registry_runtime;
Terminal window
pg_restore --exit-on-error --dbname=registry_restored /srv/backup/registry-before-build-2.dump

Point the runtime file’s database references at the restored database, then check it before anything serves from it:

Terminal window
bregctl verify --runtime-config /etc/breg/runtime.yaml
bregctl --format json instance-claim status --runtime-config /etc/breg/runtime.yaml

A restored database pinned in maintenance needs migration reconcile first. Then retire the original for good and adopt the copy:

Terminal window
bregctl --format json instance-claim adopt \
--runtime-config /etc/breg/runtime.yaml \
--acknowledge-original-retired

Pass --acknowledge-original-retired only once no client can reach the original. Two databases serving one registry both accept writes, and nothing can merge their histories afterwards. Until the adopt, bregctl import-authority list shows every authority the backup held open as open, including one you closed after the backup point. Adopting supersedes every import authority the copy held open, so open again the ones you still need.

A base backup, a point-in-time recovery, a volume snapshot, or a promoted replica keeps the original’s identity, so nothing refuses it. Two things are then your job before it serves. Keep the original stopped or fenced from clients. And end the import authorities that come back open: an authority you closed after the backup point is open again in the copy, and would admit an import you already ended. Adopt the copy once, as for a logical restore:

Terminal window
bregctl --format json instance-claim adopt \
--runtime-config /etc/breg/runtime.yaml \
--acknowledge-original-retired

The claim already names the copy, so the adopt claims it again: it raises the claim’s epoch and supersedes every open import authority in one transaction, and the audit entry records the event reclaimed with the authorities it superseded. Open again the ones you still need.

A restore rewinds every row to the backup point, including the ones you erased or delivered since. Once the copy serves, work through these:

  • Erasures. Erasure does not reach backups, so a restore brings back erased history and expired Evidence uses. Repeat each history erase request you ran after the backup point. The runtime resumes bounded Evidence expiry after startup admission. To erase expired assertions before the next sweep, run bregctl evidence-retention erase-expired --runtime-config /etc/breg/runtime.yaml --before <now>. The same 24-hour acceptance window applies. See What cannot be undone.
  • Hooks. Deliveries still pending at the backup point are sent again once the copy serves, under the same Idempotency-Key they carried the first time, so a receiver that deduplicates by that key accepts each one once. Their attempt count is rewound with the rest of the row, so the audit records the same attempt number for each of them twice. Deliveries completed before the backup point are not sent again, and delivered events are not recalled. Inspect what is pending with bregctl hook list; see Inspect and recover deliveries.
  • The audit is not rewound. The runtime audit file and its companion keep every entry the original wrote after the backup point, including the commits and deliveries the restore lost, and the adopted copy appends to the same files. A delivery pending at the backup point is therefore recorded twice, once by each database. The adoption entry in the companion file (operation breg.instance_claim.adopt, event adopted) marks where the copy’s history resumes; record the backup time and the adoption time in the change record so the lost window can be read from the archive. Never restore an older audit file over the live one.
  • Reviews the authority lost. When a review environment such as Casework is restored from an older backup, BReg reports result-unknown-to-authority for each review it submitted after that backup. While the review environment is still unreachable, the code is result-lookup-uncertain instead, which resubmit refuses; it changes once the restored environment answers. Recover each with bregctl review-recovery resubmit or close.

A logical restore returns review requests, task holdings, private drafts, decisions, results, clocks, Directory state, grants, and replay metadata to the backup point. Casework does not reconstruct lost reviews from the source. A producer may already have consumed a later result or applied its own business mutation, so keep the restored service isolated until you reconcile that window.

  1. Stop the original Casework service and preserve the surviving database when available. Restore the dump into a separately provisioned database with the matching schema ownership and runtime grants. Keep the exact package, identity.databaseId, runtime configuration, and audit key the backup used. Use your PostgreSQL client’s protected connection configuration, with no password in the command line. A custom-format backup and logical restore use:

    Terminal window
    pg_dump --format=custom --file=casework.dump '<source-database>'
    pg_restore --exit-on-error --single-transaction \
    --dbname='<fresh-database>' casework.dump

    Protect the dump as review data. Restore only into the new isolated database; never target the surviving operator database to test the procedure. A failed restore is a failed recovery, not permission to continue serving a partial copy.

  2. Run caseworkctl status --runtime-config FILE and caseworkctl plan --runtime-config FILE while the restored service remains stopped. Status must identify the backup-point activation. An unchanged restored package has changesPending: false, matching database identity, and only the already-active apply refusal in its plan. A different package, unsupported schema, or missing grants needs a supported activation recovery before service resumes.

  3. Reconcile every request and decision in the lost window with the producer’s retained request identifiers, results, and mutation records. Consult the surviving database and audit archive when available. A restored pending task does not prove that the producer never received its later result. A current-source read can establish current disclosure and reviewability; it cannot recreate a lost Casework decision.

  4. Recover missing producer submissions through that producer’s supported recovery mechanism. Casework’s own replay state is also at the backup point. Do not substitute a new idempotency key or edit database rows to manufacture a prior decision. If the supported interfaces cannot represent a known post-backup effect, keep the restore stopped and record the recovery limit.

  5. Once reconciliation permits service, run caseworkctl doctor --runtime-config FILE, start the matching runtime, and require /ready to succeed. Authenticate reviewers again, verify the restored task revision and holding, and use normal revision-fenced operations. Let maintenance repeat erasures whose deadlines the backup restored.

The external audit archive still records the original post-backup operations. Append the restored service’s entries after that history, keep both decision records when an authorised decision is repeated, and record backup and recovery times in your change record. Never overwrite the journal with its older backup.

The maintained Casework logical backup/restore drill in the matching release source tree uses a synthetic submitted review and an owned disposable Docker database. It checks a backup-point holding and activation ledger, loss of a later decision after logical restore, fresh readiness and reviewer authority, and continuation of the external audit journal.

If you run the drill from a matching source checkout, provide a running Docker daemon, Bash, Curl, jq, Python, and sha256sum, plus the documented native build prerequisites. The script builds the matching binaries, owns its local session and database, and removes them when it finishes. It is not a command for a retained operator database. Review the script before executing it, and isolate all drill identities and endpoints from production.

That submitted-context drill does not prove recovery of a producer’s business mutation, current-source authorisation, or an external task grant. Add those checks when your deployment uses them, and define how you will represent or refuse effects that happened after the backup.

The audit key pseudonymises identifiers; entries are not chained or signed and carry no key version. To rotate it:

  1. Provision a new owner-only secret file and update audit.hashKeyRef.
  2. Select a fresh audit.path in the same change, so the file boundary identifies the key boundary. After stopping the old process, ship its remaining active and sealed files.
  3. Restart, run caseworkctl doctor --runtime-config FILE, and check the live /ready endpoint. Record the rotation time, both file names, and the custodians of each key.
  4. Retain the old key under the same controls while you need to recompute references in entries written under it.

Prove archive continuity by retaining the old path through its final entry and the new path from its first entry. The key does not recover erased review payloads or recreate lost decisions.

Evidence keeps no application database, so a restore is a redeploy. Install the same release, bundle, runtime file, public JWK files, and secrets, then check them before serving:

Terminal window
evidence check --runtime-config /etc/evidence/runtime.yaml --require-runtime-dependencies

Rate limits and caches start empty. Restore audit history into your archive, never into the live audit directory. When evidence-oid4vci delivers credentials, start it after Evidence is ready: its offers live in memory, so a restart invalidates every outstanding offer and wallets must ask for a fresh one. Preserve and resume the adapter’s separate audit journal and hash key. The audit survives restart; the exchange state does not, so an outstanding exchange can remain recorded as attempted or unfinished without becoming valid after recovery. See Serve.

Stop every messaging runtime. If the current database survives, preserve it unchanged. Restore the dump into a separate fresh database provisioned as Provision PostgreSQL describes. Point a copy of the backed-up runtime file at that database, keeping its package and identity.databaseId. With the matching messagingctl, run status --runtime-config FILE, messages list --runtime-config FILE, and messages show --runtime-config FILE MESSAGE_ID while the restored runtime remains stopped. Check that the activation ledger names the backed-up package before you consider serving it.

A restore rewinds submissions, dispatch jobs, attempts, receipts, and idempotency state. It cannot recall a provider send. Establish what happened after the backup from the audit archive, provider records, and the current database when it survives. The list is bounded and newest first, so use the message identifiers from those records for messages show rather than treating one list as the complete lost window. Follow the Messaging rollback procedure to reconcile eligible states. If the current database survives, fix forward with it when the backup cannot represent those effects.

If the current database was lost, resume only when the evidence establishes that no post-backup message effects occurred, or that every effect can be represented through the supported actions. This release has no import for a missing post-backup submission and no action to mark an already-sent message restored as queued as submitted. When either gap exists, or the evidence cannot establish the lost window, keep the restore stopped and record that recovery from this backup cannot safely resume service. Do not rewrite database rows to bypass that limit. A stopped snapshot taken after the submission and dispatch drain and the callback providers’ receipt cutoff and reconciliation, with no later submissions, sends, or receipts, avoids those gaps.

Do not start the restored runtime merely to inspect it: the worker resumes queued dispatch as soon as it starts. Serve only after reconciliation shows the restored state can safely resume. Repeat erasures the restore undid with the matching messagingctl retention erase-expired, and keep the audit archive rather than replacing it with older files.

A drill proves the backups restore, the key material is recoverable, and your team can do it within the recovery time you promise. Run it at least before going live and after every change to the backup tooling.

  1. Restore the latest BReg and Casework backups onto drill hosts, and redeploy Evidence, using only what your backup store and secret escrow hold. A secret you have to fetch from a production host is a gap in the backup set. When Messaging runs, restore its dump into a fresh drill database, keep messaging stopped, and follow Restore Registry Messaging with the backed-up messagingctl. Compare the lost window with the archived audit and provider records, and record whether the supported actions can reconcile the restored dispatch state.
  2. Run bregctl verify and bregctl instance-claim status, and confirm the status reports that the claim names another database, then adopt the copy. Passing --acknowledge-original-retired is sound here only because the drill network cannot reach production or its clients.
  3. Run bregctl doctor, caseworkctl doctor, and evidence check --require-runtime-dependencies, start BReg, Casework, and Evidence, and wait for GET /ready on each. Keep Messaging stopped until step 5.
  4. Read a known record through BReg, a known review task through Casework, and a synthetic assertion through Evidence. Read one encrypted field, when the project encrypts one, to prove the field-encryption key restored.
  5. For Messaging, keep the restored runtime stopped until reconciliation succeeds. For an upgrade rehearsal, first make the project and runtime-file changes the target release’s notes list on the drill copy, and build the package again with the target release’s messagingctl package when they call for it, as v0.40.0 does; Upgrade in this order gives the sequence. Then use that messagingctl to run plan --runtime-config FILE and apply --runtime-config FILE on the drill copy, and inspect status, messages list, and messages show again with that file. When the notes have you apply to a new database, as the v0.40.0 notes do for a database v0.39.0 wrote, the restored copy has no upgrade to rehearse. Configure its providers to use the isolated capture sinks. For a local plaintext SMTP sink, use a loopback listener with tlsTermination: development-loopback, and set the provider’s tls: development-loopback and explicit port. An HTTP sink may use a loopback http base URL. After checking the activation, dispatch state, and isolation, start the matching messaging --runtime-config FILE serve, require GET /ready to answer 200, then stop it gracefully. Failed reconciliation or readiness makes the drill fail; do not record a successful service recovery from stopped-copy inspection alone.
  6. Open the shipped audit archive for the period before the backup, and confirm every file is there and ends with a complete entry, including both Messaging streams when it runs.
  7. Record the backup time, the restore time, the measured recovery time, and every step that failed, and destroy the drill hosts and their copies of the secrets.