Filters
How to search
  • Plain words find names, texts and examples.
  • "two words" finds the exact phrase.
  • --name or -x finds an option.
  • #word looks only inside commands.
  • @grep finds lessons and labs that use grep.
  • Filters: cat:network · in:labs · in:notes · level:rhcsa · ch:8 · root:yes. Put ! before a word to leave it out. OR between words means one of them.
  • ↑ ↓ to move · Enter to open · Esc to close · / to search

Backup & recoveryPythonFixes series

The backup verification cheat sheet

A backup nobody opened is a hope with a schedule. Four blocks of commands turn the hope into evidence.

Quick reference

Archive

tar -czf /backup/etc.tgz /etc
tar -tzf /backup/etc.tgz | head
aws s3 cp etc.tgz s3://bkp/etc/
sha256sum /backup/etc.tgz

Test

tar -xzf /backup/etc.tgz -C /tmp/r
tar -df /backup/etc.tgz
sha256sum -c SHA256SUMS
diff -r /etc /tmp/r/etc | head

Retention

find /backup -mtime +30 -type f
find /backup -type f -ls
logrotate -d /etc/logrotate.d/bkp
aws s3 rm s3://bkp/old/ --dryrun

Cost

du -sh /backup/*
du -h --max-depth=1 /backup
aws s3 ls s3://bkp --recursive --summarize
aws s3 ls s3://bkp --recursive

Explained

Archive

tar -czf /backup/etc.tgz /etc builds the archive. tar -tzf /backup/etc.tgz | head lists it without writing a file. aws s3 cp etc.tgz s3://bkp/etc/ moves the copy off the host. sha256sum /backup/etc.tgz prints the digest, and the digest belongs beside the archive, not in a chat message.

Test

tar -xzf /backup/etc.tgz -C /tmp/r extracts to a scratch directory. tar -df /backup/etc.tgz compares the archive with the filesystem. sha256sum -c SHA256SUMS verifies the digest. diff -r /etc /tmp/r/etc | head shows what differs.

Retention

find /backup -mtime +30 -type f lists what is older than the policy. find /backup -type f -ls shows the size and the path. logrotate -d /etc/logrotate.d/bkp tests the rule without moving a file. aws s3 rm s3://bkp/old/ --dryrun shows what a delete would remove.

Cost

du -sh /backup/* shows the big directories. du -h --max-depth=1 /backup shows the split. aws s3 ls s3://bkp --recursive --summarize totals the objects. aws s3 ls s3://bkp --recursive lists every object and its size.

The honest caveat: a checksum proves the copy matches the digest, not that the archive holds the data you need. Only a restore into a scratch directory proves that.

The lesson: the archive is the easy part; the test is the work.

In one line

A backup you never opened is a hope. The commands are cheap; the restore is the proof.

Open one archive

tar -tzf /backup/etc.tgz | head

More notes: Backup & recovery

Open in the notes app: search, filters, copy This note on GitHub