Restore is the only test that counts

short · 30 min · Objective 1.6

Task

Take an incremental backup set, then prove the thing people assume and rarely check: that you can actually restore from it, and that a missing increment breaks the chain. Learn the rsync trailing-slash and --delete traps on a copy you can afford to get wrong.

Steps

  1. Take a full backup with tar: tar czf full.tar.gz -C source .. List it with tar tzf before trusting it -- confirm the paths are what you expect.
  2. Change the source (add b.txt, edit a.txt) and take an incremental using a snapshot file: tar czg snapshot.snar -f inc1.tar.gz -C source ..
  3. Change again and take a second incremental the same way.
  4. Restore into an empty directory: extract the full, then each incremental in order. Confirm the result matches the final source state.
  5. Now break the chain: restore the full and the SECOND incremental only, skipping the first. Confirm the result is wrong or incomplete, and explain why an incremental chain must be replayed in full.
  6. Repeat the whole exercise with a differential scheme and show that a restore needs only the full plus one differential -- larger backups, simpler restore.
  7. Learn the rsync traps on the copies: show that rsync -a source dest and rsync -a source/ dest produce different layouts, and that rsync -a --delete should always be dry-run with -n first.

Verify

cd ~/lab-backup
tar tzf full.tar.gz >/dev/null && echo "archive is readable"
# full restore:
diff -r source restore && echo "restore matches source"
# after skipping an increment, the diff must FAIL:
diff -r source restore-broken >/dev/null 2>&1 || echo "broken chain detected"
rsync -an --delete source/ dest/ | head    # dry run shows what --delete would remove

The two diffs are the whole point: the complete chain must reproduce the source exactly, and the broken chain must not. A backup you have never restored is a hypothesis, and step 5 is why.

Notes

tar t before you trust an archive, rsync -n before you trust a --delete, and a real restore before you trust a backup. Each is the cheap check that turns an assumption into a fact, and each is the one skipped right up until the day it matters.