DataCareerHub
Explore learning
← Cloud & OperationsFree companion · 55 minute suggested activity

4. Prove a backup by restoring into a separate target

Cloud & Operations · Validate recovered content without overwriting the current source.

Learn → Try → ExplainReviewed 2026-10-15
01

Objective & prerequisites

Validate recovered content without overwriting the current source. Prerequisites: Python functions, JSON, basic SQL, Git and the existing software/testing workshops. Extract the full kit and open a terminal in cloud-operations-kit. Python 3.10+ with its standard SQLite module is sufficient for the executed labs; no cloud account, credentials, package installation or network is needed. All data and prices are invented teaching fixtures. The runnable drills use new temporary folders and databases, never the website or hosting. These free companions retain existing course progress/access. Payments and public registration remain disabled.

python3 lab.py
python3 -m unittest discover -s tests -v
02

Understand the concept

A backup file existing is not proof that it can restore the required records. Define the backup boundary, capture a consistent snapshot using the database’s supported mechanism and restore into a separate controlled target first. Check structural integrity and domain controls such as row identities, count and totals. A logical row hash compares the declared content; it is different from expecting two database files to have identical binary layout. Keep RPO and RTO distinct: a fast restore may still omit important changes after the snapshot. Production backups also require protected storage, retention, access, encryption, offsite/failure-domain planning and regular drills, none of which a temporary local file establishes.

03

Worked example

The drill creates two fictional orders worth 30000 and 40000 cents, then uses SQLite’s backup API. It subsequently adds a third source order of 5000. Restoring the snapshot into a new database yields two rows and 70000 cents with integrity_check=ok and matching logical row hash. The source remains three rows and 75000 cents. The restored snapshot omits one post-backup record, making the recovery-point limitation visible. The drill’s measured seconds describe one tiny local execution, not a promised RTO.

from lab import restore_drill
r=restore_drill()
assert r["restored_count"]==2 and r["restored_total_cents"]==70000
assert r["live_count_still"]==3 and r["live_total_still"]==75000
assert r["snapshot_logical_hash_matches"] and r["integrity"]=="ok"
04

Try it yourself

Run restore_drill and reconcile both databases. Explain why promoting the restored snapshot would omit the third order, and how you would document that decision. Complete backup-restore-worksheet.txt with scope, snapshot marker, controls, separate restore target, actual timing, loss window and recovery acceptance. Predict the result first, keep the original fixture, and record the exact command and observed outcome from your practice copy.

Worked solution

The restored controls are count 2 and total 70000; the current source stays count 3 and total 75000. Matching the snapshot’s logical content proves the stated local snapshot was recovered, not that all current changes were preserved. A real recovery decision must consider replay/reconciliation of later legitimate changes. Never test by restoring an old full production database over current accounts and uploads.

06

Knowledge check

If integrity_check returns ok, does that establish that every business record expected at the recovery point is present?

Check and explain

No. Structural integrity and business completeness are separate. Compare the declared snapshot identities, totals and scope.

08

Evidence, mistakes & handover

State whether an activity was executed locally, reviewed as a design, or left unexecuted. A successful local drill does not verify a cloud provider, container, hosted pipeline or production recovery. Keep an owner, acceptance criteria, known failures and rollback/cleanup evidence with the work. The download includes source fixtures, runnable drills/tests, separate exercises and solutions, a runbook, a resource plan, an optional container/CI review pack and a capstone rubric. Credit the teaching baseline and your own contribution; no certification, commercial service or employment guarantee follows.

09

Authoritative reference

Read the official reference ↗

— primary/official reference for the mechanism. Lesson explanations and fictional cases are original. Provider details can differ; this lesson does not configure or provision an account. No production access, payment, public registration or live deployment is activated.

Make the reasoning yours.

Try the activity before reading its reference. Keep your sources, commands and assumptions with your work. Companion activities are unsaved self-practice and do not award a certificate or change lesson progress.

Resume guidance and examples are for learning and preparation only. They do not guarantee interviews, a job offer or employment.

Public registration, payments and new paid enrolment remain disabled. These free resources do not grant access to protected course modules.

Learner dashboard ↗ · Ask a question ↗