Backup verification and restore
Quick answer
A backup is useful only when the required data can be restored. Test into a fresh destination, verify file contents and metadata, and validate the application before cutover.
Prepare the practice environment
Run python3 lab-fixtures/backup/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Only disposable regular files may be written. Optional examples require an authorized snapshot VM. Never substitute real devices, mount remote shares or change storage configuration. Review the lab guide.
How it works
Use a trusted manifest produced from a consistent source, then verify restored bytes. Compare expected paths, permissions, timestamps and link handling as needed; a checksum alone does not verify metadata or authenticity. rsync -a preserves many ordinary attributes but not ACLs, extended attributes or hard-link relationships by default. Tar archives can preserve ordinary mode and timestamp information; extraction must use trusted archives and a private destination. Restic and Borg store snapshots or archives in repositories with deduplication and encryption options; inspect exact version syntax (Borg 1.x differs from 2.x). Repository checks complement rather than replace restore tests. The lab tests regular-file content and mode only, not a database or real disaster recovery.
A manifest covering report.txt can detect changed bytes in that file, but cannot discover an unexpected extra file on its own. Compare the complete intended inventory as well as hashes and required metadata. In a separate restored copy, alter one byte and require a nonzero checksum-check status; this proves the check detects that specific change. Validate service behavior separately, and do not replace the original source during the drill.
Try the examples
tar -cf backup.tar datamkdir restoredtar -xpf backup.tar -C restoredcmp data/report.txt restored/data/report.txttest "$(stat -c '%a' data/report.txt)" = "$(stat -c '%a' restored/data/report.txt)"printf 'bytes and mode verified\n'Restore the trusted fixture archive into a new directory. Use -p to preserve recorded permission bits; compare bytes and mode, not all metadata.
Expected stdout:
bytes and mode verified(cd data && sha256sum report.txt) > manifest.sha256mkdir restoredrsync -a data/ restored/(cd restored && sha256sum -c ../manifest.sha256)The manifest contains the relative path so verification is run from the restore root.
Expected stdout:
report.txt: OKrestic -r ./restic-repo snapshotsrestic -r ./restic-repo checkVM-only: use an instructor-provided disposable encrypted repository, enter the passphrase at the prompt, do not store it in commands. Check does not replace restore and full data verification.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Never restore over the only live copy during a drill. Do not trust a manifest from the same untrusted source without independent authentication. Do not run repair or prune until retention and recovery are understood.
Practice
Create a fresh restore from the supplied data; verify report.txt bytes and mode. Alter only a separate restored copy and show checksum validation fails. Record limitations and cleanup the private workspace.
Related references
Study: rsync, restic, borg, sha256sum. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Backup verification and restore — Knowledge Check
Apply advanced storage and backup concepts to synthetic fixtures and VM-only scenarios.
Where should a restore drill write?
What does a matching SHA-256 manifest establish when trusted?
Does rsync -a preserve hard links by default?
What complements repository checks?