Volume backup and verified restoration
A backup is a separate recoverable copy of data. A restore test proves that a selected copy can be read back into a new destination under stated conditions. Start with a closed, ordinary file: archive it, store its checksum separately, restore to an empty destination and compare the restored bytes. Never use a live database directory as a generic file-copy exercise.
Worked storage scenario
Use the synthetic scenario offline first. No real data, daemon changes, host mounts or production resources are required. Commands, if shown, are documented examples rather than observed output. Any real Docker check requires an approved disposable context. Keep the exercise offline. For any separately authorized Docker verification, identify the effective endpoint (including DOCKER_HOST and DOCKER_CONTEXT) before sending even read-only Engine requests. Record server version and platform; redact sensitive metadata.
Offline fixture: report.txt = "invoice-count=3\n"Source: closed file in synthetic data directoryBackup: report.tar + independent SHA-256 manifestRestore: new empty directoryAssertions: exact bytes, checksum match, corruption rejectedFor a real Docker file-volume backup, first confirm the isolated context and volume identity, stop or coordinate every writer and verify the source is stable. A reviewed helper container can mount the source volume read-only and write an archive to a separate, narrowly scoped backup destination. Restore only trusted archives into a new empty volume; reject unsafe paths and links and validate required permissions and metadata. Start an isolated application against the restored data and test expected behavior before switching any workload. Keep the original until recovery is accepted. The companion Python fixture operates only on self-created files in a temporary directory, not on Docker volumes. It demonstrates byte integrity and deliberate corruption detection; it does not preserve all filesystem metadata or prove application recovery. The fixture creates the digest and archive together in the same temporary failure domain. This is a separate checksum file, not an independently protected backup or authenticated manifest. It also rejects a nonempty destination. In a real plan protect the manifest separately, verify the restore and record recovery time and acceptable data loss.
Common mistake
Archive creation succeeding is not the same as recovery succeeding. A checksum detects changes relative to a trusted manifest; it does not prove completeness or consistency.
Manual practice
Run the optional local Python fixture with Python 3, or trace its assertions manually. Explain why the destination must be empty and why a backup should be kept outside the source failure domain.
Worksheet: lab-fixtures/docker-storage-engineering/03-backup-restore/scenario.txt.
Optional local exercise: from the package root, run python3 lab-fixtures/docker-storage-engineering/03-backup-restore/restore_demo.py. It creates its own temporary files, verifies a restored file and rejects a deliberately altered archive. No Docker or external input is used.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Volume backup and verified restoration — Knowledge check
Reason about storage behavior and recovery evidence.
What is stronger evidence than archive creation alone?
What does an archive checksum match establish relative to a trusted recorded digest?
Where should a test restoration go?