Recovery controls — revision delivered in draft MR !38
Date: 18 October 2026. This document describes code and local tests. No UAT or production activation is included. Live ILYGO operations and host inventory remain governed by Outline. Protocol read at revision 69 during this intervention.
Protection and deletion
- Apply migrations 0025–0029 before running the new API/workers. New tenant tables have forced RLS and grants to the existing application role.
minimum_lock_daysaffects new backups. Existingprotected_untilcannot be reduced, even after it expires. The database rejects deletion/purge while the lock is active.MINIO_OBJECT_LOCK_ENABLEDdefaults to false. The application then offers a database retention lock, not a storage WORM guarantee.- Enabling storage WORM requires a separate approved storage change: inventory buckets/versioning/IAM/consumers, verify support for Object Lock, validate COMPLIANCE retention on an isolated bucket, prove recovery by version ID, measure retained-version growth, and review lifecycle/GC. Existing buckets are checked; the API does not silently reconfigure them.
- With Object Lock enabled, encrypted chunks and the encrypted manifest are retained under COMPLIANCE; pinned version IDs remain readable after a delete marker. The local integration test proves that the test storage administrator cannot delete a protected version.
DELETE /backups/{id}requests deletion (202). Two different human administrators must approve. A 24-hour cancellation period starts after the second approval. The worker rechecks active locks, latest copy, chain dependencies and recovery work, then performs logical deletion. Physical GC retains its configured grace (default 72 hours). There is no direct request-time purge.- A mirror has its own local minimum retention floor. A shorter value from the control plane cannot reduce that floor or an already observed protection date. Protect the mirror host/credentials separately; server logic cannot establish an independent failure domain by itself.
Verification and rollback before a future activation
- Export the control database and prove restore into an isolated environment. Keep the existing bridge binaries/configuration and image digests.
- Review the migration SQL, new constraints and forced RLS as the application role. Rehearse upgrades on a disposable PostgreSQL 16 instance and verify the cross-tenant tests.
- Disable schedulers/GC while validating a future promotion; establish an agreed maintenance window. This MR does not execute this step.
- Deploy compatible API/workers/UI/bridges together through the approved MR/pipeline path. Test one fictional source and a complete isolated recovery before enabling per-source locks or physical PITR.
- For application rollback, stop new work, preserve the database schema and version IDs, and restore the previous compatible images/configuration. Keep WORM buckets and retained bytes intact. Database downgrade deliberately refuses to remove protection/version fields while active locks exist. An enabled COMPLIANCE lock is irreversible until its expiry; rollback does not shorten it.
- Reconcile pending deletion/restore jobs and verify both control metadata and recovered content. Do not infer successful recovery from HTTP health or CI alone.
Versioned keys and separate custody
The source key never enters the API, configuration records or screenshots. Store a private keyring as a regular file with mode 0600 (a filesystem enforcing these permissions is required). ILYGO_KEYRING_FILE points to that file. The bridge encrypts with its current version and decrypts historical versions automatically.
For an existing source, expose its original ILYGO_PASSPHRASE only through its local secret manager, then run:
ilygo-bridge keyring-rotate /private/backup/source-keyring.json
For a new source with no historical key, the explicit --new-source option creates its first key. Rotation appends a new version; it never drops old keys. Import historical keys locally on an authorized replacement bridge. Keep encrypted independent custody in ILYGO Vault using its normal approved workflow; this tool does not write Vault or rotate central credentials.
The Recovery centre records only vault://… references, version names, custodians, handover date and optional successful recovery command. A recorded handover is a declaration, not recovery proof. Run a recovery with the old key before accepting the record. The old Python Shamir implementation used a defective field generator; existing shares from that implementation require verification against the original key. No automatic reconstruction/migration of defective shares is claimed.
Portable offline recovery
From a completed copy, download the recovery kit for the recovery host platform. It contains the exact encrypted ancestry, manifests, chunks, hashes and a static ilygo-bridge built from the same revision. Export refuses an incomplete chain or a missing matching tool artifact. The API image must contain recovery-tools/ from the CI artifact; no executable is committed to Git.
Keep the kit and its independently recorded digest in protected storage, separate from the keyring. Preposition database tools/engines and application dependencies, recording their versions in the application recovery plan. The kit does not embed PostgreSQL/MySQL/MongoDB servers or a container registry.
On the recovery host, with central API and registry unavailable:
chmod +x tools/ilygo-bridge
# ILYGO_KEYRING_FILE is injected locally; its value is a private file path.
tools/ilygo-bridge recover-kit . /private/recovery/new-plaintext-file
The output must not already exist. It is private plaintext: a tar for files/S3/physical PostgreSQL, or the original logical database dump. The tool checks inventory hashes, AEAD and ancestry before creating output. Inventory digests must be kept independently: an editable inventory cannot establish the provenance of a replacement executable. Restore into a new destination, validate content, retain the evidence, and clean plaintext according to the local policy. Physical PostgreSQL output can be applied with recover-pitr below.
PostgreSQL physical PITR
Scope and prerequisites
PostgreSQL 16 or newer, matching server major version and local tools (pg_basebackup, pg_receivewal when enabled, pg_switch_wal through SQL, pg_waldump, pg_controldata, pg_verifybackup, pg_ctl, postgres, psql). This implementation supports the default tablespace, one source system ID and its current timeline. External tablespaces and timeline changes require a new validated base; they are refused rather than silently flattened. Logical pg_dump copies cannot accept a target time.
PITR is opt-in on the source bridge. Changes to replication rights, WAL configuration, slots, archive capacity and production credentials require their own approved operations plan. A pre-created slot is optional; this bridge never creates one. Monitor WAL disk/slot growth independently and size storage for cumulative journals.
Local environment, injected through the approved secret/configuration manager:
| Setting | Meaning |
|---|---|
PG_PITR_ENABLED=1 |
Enables physical base/WAL mode instead of logical dumps |
PG_PITR_CONN_URL |
Optional replication connection; falls back to PG_CONN_URL; password stays in the child environment |
PG_PITR_STATE_DIR |
Existing private directory for accepted-base metadata and local diagnostics |
PG_PITR_WAL_ARCHIVE_DIR |
Existing private directory containing complete WAL segments |
PG_PITR_RECEIVE_WAL=1 |
Run a supervised synchronous pg_receivewal; otherwise use an independently managed archive |
PG_PITR_SLOT |
Optional existing replication slot |
PG_PITR_BASE_INTERVAL_HOURS |
New-base interval, default 24 hours |
PG_PITR_RESTORE_ROOT |
Existing private directory for new isolated recovery clusters |
PG_PITR_RESTORE_PORT |
Locally reserved loopback TCP port, 1024–65535 |
PG_PITR_START_TIMEOUT_SECONDS |
Local PostgreSQL startup deadline, default 60 seconds, bounded to 30–600; CI uses 180 on shared storage. Content, WAL and cleanup checks remain mandatory. |
The bridge waits for collector readiness, creates a physical base with streamed WAL and a SHA-256 backup manifest, encrypts/uploads it, then persists its accepted base state. Later jobs upload a cumulative archive of all complete WAL segments since that base. Missing/partial segments and incompatible system IDs/timelines fail the backup. The advertised time interval is derived from parsed transaction commits, not from upload time. A quiet system may have no new recoverable commit interval until activity is archived.
Recovery procedure
- Select a journal in the catalogue and inspect its verified commit interval. Choose an instant within that interval. Select a compatible bridge advertising
pitr_postgres_v1and the same major version; provide the historical key locally. - Create a restore job, obtain the required human approvals, then sign the persisted command locally. The RAT binds the copy, exact paths/scopes, target bridge and target time. A replacement bridge always uses a new isolated destination. Its read grant covers only the selected ancestry while the linked command is active, for at most 24 hours from dispatch; a longer interrupted recovery needs a new authorized request.
- The bridge verifies base files and complete WAL continuity, extracts regular files only, replaces archived startup configuration, and starts a new local loopback cluster. It does not overwrite the original database. Its temporary HBA trusts loopback on the reserved port: use a dedicated recovery host/network boundary and restrict local users before any future activation.
- Wait for recovery to reach/promote at the requested instant. Run the private local validation profile. A stopped server, missing WAL, target outside the interval or failed check fails the job.
- Drills remove their private cluster after shutting it down. A cleanup failure is reported; uncertain/running clusters are retained for local intervention. Startup diagnostics are private at
PG_PITR_STATE_DIR/last-recovery-error.log. A real successful recovery retains its new cluster; promotion to a business endpoint is a separate operator decision.
Offline, after recover-kit produced a physical tar:
ilygo-bridge recover-pitr /private/recovery/physical.tar 2026-10-18T09:15:00Z
Same local tools/configuration/profile are required. No API/registry is contacted. Keep the new isolated cluster and complete business acceptance before switching an endpoint.
Local proof: an encrypted base and WAL journal were created on disposable PostgreSQL 16; one row was inserted then deleted; two drills recovered the exact before/after counts, verified base files and reported real cleanup. Removing a required WAL segment caused backup failure. This is not a production load/HA qualification.
References: PostgreSQL continuous archiving, pg_basebackup, pg_waldump.
Local validation profiles and application plans
ILYGO_RESTORE_CHECKS_FILE references a private regular 0600 JSON file. The control plane cannot send SQL or shell commands. Supported checks are deliberately declarative:
{
"postgres": [{"name":"orders-present","type":"table_min_rows","schema":"public","table":"orders","min_rows":1}],
"files": [{"name":"receipt-present","type":"file_exists","path":"receipts/example.txt"}],
"minio": [{"name":"object-present","type":"object_exists","path":"documents/example.txt"}]
}
Optional SHA-256 checks use file_sha256 / object_sha256 and sha256; PostgreSQL row checks accept optional max_rows. Verify the exact profile on fictional data before adopting it. Only check names and booleans are reported, not row contents or key material. No profile means application validation is unknown. RTO compares the full measured technical drill duration with the declared objective only when fresh successful local checks exist; business switchover time remains outside this measurement.
Declare expected assets independently of existing sources; missing source, first backup, RPO breach, expired proof and temporary exclusion remain distinguishable. Exclusions need a reason and expiry. Multi-source plans form a DAG with a maximum timestamp skew. Isolated drills run in dependency order, stop launching after failure and preserve in-flight evidence/retention pins. All source checks passing is distinct from atomic cross-engine recovery or an integrated application test. The plan's recorded atomic_snapshot is false.
Schedules, alerts, capacity and membership
- Schedules store UTC instants and an IANA timezone plus local allowed weekdays/hours. Spring DST nonexistent slots are skipped; repeated autumn slots represent two UTC instants. Overnight windows are supported. Catch-up is opt-in, at most 24 hours old, within the allowed window and without piling up commands. There is no network-rate guarantee; the accepted alternative here is bounded catch-up, pending measured load.
- Channel tests target one configured channel. Each channel has its own receipt; retries skip channels already sent. Non-2xx webhooks fail; signing failure never downgrades to unsigned. Maintenance defers normal delivery while retaining events; tests remain available. Unacknowledged incidents escalate once to configured backup channels; acknowledgement prevents future escalation. Notification receipt means delivery attempt accepted by the channel, not human reading.
- Capacity is sampled daily from actual primary object versions and per-tenant mirror agent statistics. Failed collection never creates a zero sample. A projection requires at least three measurements spanning two days; reserve is configurable. A daily warning is queued when the reserve is reached or its projection is within 14 days. Mirror date/freshness is visible. This compares tenant bytes with quota; physical host/mirror free disk may remain unknown.
- Delegated membership only assigns viewer/tenant_admin to an existing active Keycloak identity by exact email. It cannot create identities/passwords, assign operator/superadmin or remove the last active tenant administrator. Changes remain tenant-scoped and audited.
- FR/EN covers client/operator screens, dynamic messages and locale formats. Guides use local fictional API fixtures. No real credentials or customer data are used in captures.