Operations

Disaster Recovery and Evidence

Plan and rehearse recovery, restore services and records, and check that recovery objectives have been met.

Assurance boundary

AMCDR includes recovery planning, restore checks, integrity utilities, provider adapters and evidence reports. The Docker profile runs a plan only, and the optional Kubernetes controller starts suspended. Recovery execution requires explicit configuration and approval; the tools do not obtain cloud privileges automatically.

Use the deployment’s approved business-impact analysis to set recovery priorities. Controller, service-owner, security and clinical-safety approval is required before activation. NIST SP 800-34 Rev. 1 provides the contingency-planning model for impact analysis, recovery priorities, strategies, exercises and maintenance.

Default service tiers

TierServicesRPORTOPromotion rule
Tier 0 clinical identityMPI, patient/EHR identity, PostgreSQL, clinical read/write5 minutes30 minutesNo promotion until authority reconciliation and tenant-denial tests pass.
Tier 0 authenticationKeycloak/IdP, realms, signing keys and authorization claims15 minutes30 minutesFail closed; OIDC/RBAC bypass is prohibited.
Tier 1 documentsBinary clinical attachments and authoritative object storage15 minutes60 minutesRestore versions, metadata, checksums and controlled retrieval.
Tier 2 rebuildableValkey, OpenSearch, analytics and asynchronous reportingNo independent loss4 hoursRebuild from authority; never become a competing source.

Confirm these recovery objectives during the business-impact analysis. Store the approved values in the deployment configuration and change them only through the BIA and governance process.

Implementation inventory

ArtifactPurpose
config/disaster-recovery.example.jsonDisabled plan with tiers, approvals and every required scenario.
scripts/dr/recovery_control.pyConfiguration and activation validation, provider execution, objective measurement and evidence bundles.
scripts/dr/postgres_reconciliation.sqlSchema/WAL state, global and tenant counts, fingerprints and integrity failures.
scripts/dr/postgres_clean_restore_exercise.shChecksum, decrypt, fresh network-isolated PostgreSQL restore and strict reconciliation.
scripts/dr/object_manifest.pyDocument/object count, size and SHA-256 comparison.
scripts/dr/backup_corruption_exercise.pySafe corruption of a disposable copy and checksum-detection evidence.
scripts/dr/provider_adapter.example.shFail-closed contract for cloud, database, IdP, storage and KMS adapters.
docker-compose.dr.ymlRead-only, network-disabled plan profile.
k8s/optional/disaster-recoverySeparate recovery namespace and suspended controller, excluded from the application base.

Production configuration: where and what

Copy the example outside the source checkout and restrict it:

sudo install -d -m 0700 /etc/amcdr/dr
sudo install -m 0600 config/disaster-recovery.example.json \
  /etc/amcdr/dr/disaster-recovery.json

For Kubernetes, store the completed JSON as key disaster-recovery.json in Secret amcdr-dr-config in namespace amcdr-recovery-control and set evidence_directory to /evidence. The JSON may disclose topology but must contain no credentials.

FieldRequired production value
enabledtrue only after approval and adapter validation.
deployment_idStable ID such as ug-national-cdr-prod; used in typed confirmation.
source_environmentThe protected production source.
recovery_environmentA different clean, isolated target identity.
recovery_target_is_isolatedMust be true.
evidence_directoryEncrypted staging path; completed bundles move to immutable/WORM storage.
approval.*Controller, service owner, security owner, clinical-safety owner, approval time and record. Placeholders block activation.
service_tiersBIA-approved RPO/RTO values.
scenarios[].commandArgument array pointing to the approved provider adapter; no shell string.
evidence_signing_commandOptional signer reading AMCDR_DR_MANIFEST_PATH and writing AMCDR_DR_SIGNATURE_PATH.
{
  "id": "postgres_pitr",
  "command": ["/opt/amcdr/dr-adapters/postgres-pitr.sh"],
  "timeout_seconds": 3600
}

Credentials are supplied by recovery-only workload identity or secret-manager files/environment variables. Passwords, bearer tokens, client secrets, private keys and passphrases are prohibited in the JSON and command arguments.

Production exercise inputs and supply locations

MaterialRequired contentSupply location
Exercise controlCompleted JSON, objectives, scenarios, provider commands and governance reference./etc/amcdr/dr/disaster-recovery.json; Kubernetes amcdr-dr-config.
Execution confirmationActivation phrase, unique exercise ID, change ticket, approved operator and exact <deployment_id>/<exercise_id>.Operator environment/CLI; short-lived Kubernetes amcdr-dr-runtime.
Provider credentialsRecovery-only database, cloud, backup, object-store, KMS/HSM and IdP identities.Approved secret manager/workload identity; never JSON or evidence.
Recovery inventoryClean target accounts, regions, clusters, buckets and network routes.Protected operations repository and provider adapter configuration.
Evidence controlsEncrypted staging, immutable/WORM destination, retention, hold and reviewer policy.evidence_directory and the approved evidence repository.
Approvals and independent confirmationNamed owners, timestamp, reconciliation decision, RPO/RTO acceptance, discrepancies and go/no-go.Configuration approval object, signed evidence review and authoritative change/governance record.

The runtime Secret is short-lived and must be deleted or rotated after the job. Secret manifests and provider values belong in the deployment organisation's protected operations repository, not the AMCDR source repository.

Provider-adapter result contract

The controller supplies bundle, exercise, scenario, evidence-directory, result-file, ticket, deployment, source/target and target-objective environment variables. Each adapter must exit non-zero on failure and write AMCDR_DR_RESULT_FILE:

{
  "status": "passed",
  "observed_rpo_seconds": 42,
  "observed_rto_seconds": 812,
  "assertions": [
    {"name": "clinical_reconciliation", "passed": true},
    {"name": "cross_tenant_denial", "passed": true}
  ],
  "evidence_files": [
    "provider-recovery-job.json",
    "recovered-reconciliation.json",
    "clinical-smoke-test.json"
  ],
  "metadata": {
    "provider_job_id": "non-secret-reference",
    "recovery_point": "2026-07-22T01:55:00Z"
  }
}

Evidence paths must be relative to the scenario directory and must exist. Failed/empty assertions, missing evidence, objective breaches, timeout or non-zero exit fail the scenario.

Activation and confirmation

Safe plan

python3 scripts/dr/recovery_control.py validate \
  --config config/disaster-recovery.example.json
python3 scripts/dr/recovery_control.py plan \
  --config config/disaster-recovery.example.json

Production activation validation

python3 scripts/dr/recovery_control.py validate \
  --config /etc/amcdr/dr/disaster-recovery.json \
  --activation

Execution requires all four independent controls:

  1. enabled=true in the approved configuration.
  2. AMCDR_DR_ACTIVATION=APPROVED_ISOLATED_RECOVERY_EXERCISE from the recovery runtime secret.
  3. --execute, a change ticket and a named operator.
  4. --confirmation exactly equal to <deployment_id>/<exercise_id>.
export AMCDR_DR_ACTIVATION=APPROVED_ISOLATED_RECOVERY_EXERCISE
EXERCISE_ID=quarterly-dr-2026q3

python3 scripts/dr/recovery_control.py run \
  --config /etc/amcdr/dr/disaster-recovery.json \
  --exercise-id "$EXERCISE_ID" \
  --change-ticket CHG-2026-00421 \
  --approved-by operator.name \
  --confirmation "ug-national-cdr-prod/${EXERCISE_ID}" \
  --execute

Omit --scenario for the full exercise. A selected-scenario run is labelled passed_partial and cannot be represented as a complete DR test.

Docker activation location

The included profile performs only a network-disabled plan:

docker compose -f docker-compose.dr.yml --profile disaster-recovery \
  run --rm dr-controller

Actual execution requires a separately reviewed override with the approved configuration, recovery-only identity and narrowly approved egress. Do not mount the Docker socket into the controller. Run clean-container restore tooling from a controlled operator host.

Kubernetes activation location

kubectl apply -k k8s/optional/disaster-recovery
kubectl -n amcdr-recovery-control create secret generic amcdr-dr-config \
  --from-file=disaster-recovery.json=/etc/amcdr/dr/disaster-recovery.json

Create amcdr-dr-runtime through External Secrets, Secrets Store CSI or the approved secret workflow with the activation phrase, exercise ID, ticket, operator and exact confirmation. The package denies all network traffic by default; add only DNS and explicitly approved recovery/evidence egress. Before setting suspend=false, use a signed image digest, encrypted evidence storage, provider adapters/CLIs and recovery-only workload identity. Operate from a failure domain that survives loss of the primary cluster/region. The default controller service account has no Kubernetes API token.

Recovery procedures

ScenarioRequired procedure and acceptance
Clean PostgreSQL restoreQuiesce logical writes or use a consistent physical snapshot; verify portable backup/reconciliation checksums and the quiesced evidence manifest; restore to fresh isolated PostgreSQL; compare authority; measure; destroy or legally hold target.
PostgreSQL PITRFence source; choose good timestamp/LSN; restore base and replay WAL; record provider job/LSN; reconcile; run schema, RLS, openEHR and MPI smoke tests; keep outbound delivery disabled until promotion.
Replica promotionRecord lag; fence old primary; promote one candidate; prove timeline/write authority/split-brain prevention; reconcile and test; reseed and document failback.
Keycloak/IdPRestore database/realm/key material; reconcile clients, roles, groups/accounts; verify discovery/JWKS, login, refresh, logout, revocation, rollover and AMCDR claims.
Valkey/RedisExercise failover/cold start; verify TLS/auth, tenant keys, invalidation, leases and queues; prove scheduled work is not duplicated.
OpenSearchCreate empty generation; reindex from PostgreSQL; compare per tenant; sample IDs; run cross-tenant denials; atomically move alias.
Documents/objectsRestore versions and database links; compare object count, size and SHA-256; validate quarantine metadata and allowed/denied retrieval.
Key recoveryUse dual control; prove backup/object decryption, token/signature and certificate trust; log access; rotate exposed recovery credentials and reseal.
RansomwareUse tabletop/provider chaos, never malware; isolate control/data planes and credentials; stop corrupt replication; preserve forensics; restore immutable good point; rebuild from signed assets; rotate trust; obtain reopening approval.
Corrupted backupCorrupt a disposable copy; prove rejection; select previous verified point; perform full clean restore/reconciliation; measure additional RPO/RTO.

Strict PostgreSQL reconciliation

The snapshot reconciles tenant, person, patient, Party/VersionedParty/PartyVersion, EHR/EHR_STATUS/EHR_ACCESS versions, contributions, compositions/versions, audit and lifecycle events, deletion tombstones, authentication events and binary objects. It includes per-tenant counts, stable-ID aggregate fingerprints, relational-integrity failures, Alembic revision, WAL position, recovery state and latest authoritative record time.

The comparison snapshot must belong to the selected recovery point. Live-source counts taken after later writes are invalid. Logical-backup evidence therefore requires a controlled write quiesce; physical snapshot/PITR adapters must capture a snapshot-consistent manifest.

AMCDR_BACKUP_CAPTURE_DR_EVIDENCE=true \
AMCDR_BACKUP_WRITES_QUIESCED=true \
AMCDR_BACKUP_DIR=/approved/encrypted/location \
AMCDR_BACKUP_PASSPHRASE_FILE=/run/secrets/amcdr-backup-passphrase \
scripts/postgres_encrypted_backup.sh

Generated evidence

configuration-snapshot.json
evidence.json
summary.md
manifest.json
manifest.sha256
manifest.sig                       # optional detached signature
scenarios/<scenario>/stdout.log
scenarios/<scenario>/stderr.log
scenarios/<scenario>/provider-result.json
scenarios/<scenario>/result.json
scenarios/<scenario>/<provider evidence>

The manifest records byte size and SHA-256 for every evidence file. Verify it with:

python3 scripts/dr/recovery_control.py verify \
  --bundle /controlled/evidence/dr-20260722T020000Z-0123456789

Transfer completed bundles to approved immutable/WORM storage. Restrict writes to the controller, reads to named assurance roles, apply the evidence retention/hold schedule and never include credentials, private keys, patient payloads or database dumps.

Acceptance and frequency

A complete exercise passes only when every required scenario executes, assertions and evidence pass, measured RPO/RTO meet the approved tier, the manifest verifies and independent reviewers accept residual discrepancies. Run a representative clean restore quarterly, complete regional recovery at least annually and after material topology changes, and targeted exercises after significant database, identity, key, storage or network changes. The BIA or regulator may require shorter intervals.

Related guidance