Recovery testing and continuity
Build the recovery sequence before an incident
Recovery is not finished when a virtual machine starts. For the fictional bookstore, an incident commander declares the recovery exercise, assigns an owner and uses an isolated destination. The recovery team follows the dependency order:
- Establish authorized emergency identity, access to backup catalog, encryption keys and trusted configuration. Verify separation from the failed or compromised environment.
- Prepare network, DNS records (without switching public traffic), certificates, quotas, images and runtime. Restore data into a new isolated target, check schema compatibility and replay permitted logs to a known safe point.
- Reconcile orders, payment identifiers and inventory. Test a synthetic authorized checkout, rejection of unauthorized requests, error and latency targets; keep external payment and email disabled.
- Review evidence, fence old writers and resolve ambiguous transactions before any authorized traffic cutover. Monitor outcomes, record objective misses and escalate; do not silently discard data to meet a timer.
A business continuity plan also records who communicates with staff and customers, an alternative order procedure with unique references and reconciliation, and which noncritical functions may be suspended. Never bypass payment or authorization to continue service.
Measure recovery on a timeline
Define incident time as minute 120. The selected clean backup is minute 100. Assume sequential recovery work: detection and decision 10 minutes, recovery identity and keys 10, network and infrastructure 15, restore and replay 25, application checks 10, controlled routing verification 5. Total 75 minutes; the synthetic verified service time is minute 195. Observed point age is 20 minutes and elapsed recovery time is 75 minutes, both within the 30 and 90 minute objectives. If restore grows to 45 minutes, total is 95 minutes and RTO is missed. Parallel tasks can reduce the critical path but only when their dependencies permit it. An estimated duration is not a measured drill result. Store simulated timestamps as simulated; a real exercise should record actual timestamps and evidence. If the clean point is minute 85, point age is 35 and RPO misses even when elapsed time is 75.
For an illustrative 60 GB restore with effective 0.5 GB/minute throughput, transfer alone takes 120 minutes. It cannot meet 90 minutes, before any other steps. If other sequential work takes 50 minutes, only 40 remain for transfer; 60 / 40 = 1.5 GB/minute minimum sustained effective throughput, ignoring overhead. Validate actual retrieval, replay and integrity overhead instead of assuming line rate.
Restore synthetic records locally
This Python 3 standard-library example uses a temporary directory, two fictional paid orders and no network or credentials. The backup is a deterministic byte representation of JSON. Restore writes a new temporary file, compares SHA-256 with the expected hash, parses it and checks unique order IDs and total cents against independent expected business values. This demonstrates both byte integrity and a small business invariant; it is not a real database backup, cryptographic signature, or proof of authenticity. A real manifest must be trustworthy and independently protected. The temporary directory is cleaned automatically. No existing files are overwritten.
import hashlibimport jsonfrom tempfile import TemporaryDirectoryfrom pathlib import Path
def canonical(records): return json.dumps(records, sort_keys=True, separators=(",", ":")).encode("utf-8")
def digest(data): return hashlib.sha256(data).hexdigest()
def verify_restore(payload, expected_hash, expected_ids, expected_total): if digest(payload) != expected_hash: return "HASH_MISMATCH" try: records = json.loads(payload) if not isinstance(records, list): return "INVALID_RECORDS" if any(not isinstance(r, dict) or type(r.get("id")) is not int or type(r.get("cents")) is not int or r["cents"] < 0 for r in records): return "INVALID_RECORDS" ids = [r["id"] for r in records] if len(set(ids)) != len(ids) or set(ids) != set(expected_ids): return "ID_MISMATCH" if sum(r["cents"] for r in records) != expected_total: return "TOTAL_MISMATCH" except (ValueError, TypeError, UnicodeError): return "INVALID_RECORDS" return "VERIFIED"
def recovery_gate(verified, dependencies_ready, transaction_ok, point_age, elapsed, rpo, rto): if not verified or not dependencies_ready or not transaction_ok: return "HOLD" if point_age is None or elapsed is None or min(point_age, elapsed) < 0: return "UNKNOWN" if point_age > rpo or elapsed > rto: return "OBJECTIVE_MISSED" return "OBJECTIVES_MET"
records = [{"id": 1, "cents": 1200}, {"id": 2, "cents": 800}]backup = canonical(records)# In a real system, protect this manifest separately from the backup.expected_hash = digest(backup)with TemporaryDirectory() as folder: restored = Path(folder) / "restored.json" restored.write_bytes(backup) payload = restored.read_bytes() print(verify_restore(payload, expected_hash, [1, 2], 2000)) print(verify_restore(payload + b"!", expected_hash, [1, 2], 2000))print(recovery_gate(True, True, True, 20, 75, 30, 90))print(recovery_gate(True, True, True, 35, 75, 30, 90))print(recovery_gate(True, False, True, 20, 75, 30, 90))Expected output:
VERIFIEDHASH_MISMATCHOBJECTIVES_METOBJECTIVE_MISSEDHOLDThe extra byte represents damaged data. A valid hash can still accompany semantically wrong records; the tests also exercise missing IDs, duplicate IDs, wrong amounts and invalid JSON using a newly computed expected hash to demonstrate the independent checks. The gate uses trusted synthetic boolean evidence and nonnegative minute targets. It reports objective misses even if technically recovered, and refuses to mark recovery when dependencies or transactions fail. It does not implement a production cutover controller. The example uses simulated times, not a measured cloud restore duration.
Test negative cases and diagnose failures
| Observation | Possible cause | Safe next action |
|---|---|---|
| Backup job succeeded but copy is not readable | Missing permissions, key version or inaccessible vault | Verify recovery role, retained key and copy availability in isolation |
| Hash differs | Damaged bytes or wrong point selected | Stop and preserve evidence; compare independent manifest; select another verified point |
| Hash matches but orders are missing | Wrong point or inconsistent application backup | Compare trusted ledger and expected IDs, reconcile with business owner |
| Restored app starts but checkout fails | DNS, certificates, secret, identity or dependency mismatch | Test each dependency and synthetic transaction; keep routing unchanged |
| RPO/RTO missed | Old clean point or slow critical path | Record actual gap, notify owner, revise design and retest |
Google Cloud's recovery testing guidance emphasizes verifying usable and consistent backups, not only backup jobs. Azure's backup resilience architecture distinguishes clean point selection and restore verification. AWS resilience testing guidance relates recovery tests to objectives. Start with tabletop exercises, then isolated restores of approved synthetic data; any live test requires explicit permission, bounded blast radius, cost, stop conditions and rollback. This lesson performs no cloud fault injection, real deletion, public routing or retention lock.
Plan failback as carefully as failover
Failback returns service from the recovery environment to the repaired preferred environment. It is not simply reversing DNS. Verify root cause removal, rebuild from trusted configuration, synchronize changes made during recovery, reconcile transactions, measure lag, fence writers and confirm capacity. Define who approves the cutover, stop conditions and rollback route. Validate a fresh synthetic business transaction after any authorized routing change; monitor cache and client behavior before declaring completion. Retain recovery evidence and protected backups according to policy, and clean only specifically approved temporary test resources. The Google Cloud DR planning guide covers the complete recovery process. Document a drill with scenario, chosen recovery point, measured RPO/RTO, objective gaps, restore results, decision log, communication, failback steps and action owners. Re-test after material dependency changes. This offline exercise ends with a local temporary-file cleanup, not real failback.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Recovery testing and continuity — knowledge check
Choose the best answer for each offline scenario.
Incident minute 120, clean point minute 85. What is the observed point age?
When should recovery be declared complete in this lesson?
What does a matching SHA-256 alone demonstrate against a trusted expected digest?
What is the gate result if data verifies but identity is unavailable?
What is essential before failback?