Restore is the only test that counts
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
- Take a full backup with tar:
tar czf full.tar.gz -C source .. List it withtar tzfbefore trusting it -- confirm the paths are what you expect. - 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 .. - Change again and take a second incremental the same way.
- Restore into an empty directory: extract the full, then each incremental in order. Confirm the result matches the final source state.
- 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.
- Repeat the whole exercise with a differential scheme and show that a restore needs only the full plus one differential -- larger backups, simpler restore.
- Learn the rsync traps on the copies: show that
rsync -a source destandrsync -a source/ destproduce different layouts, and thatrsync -a --deleteshould always be dry-run with-nfirst.
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.