Pcornel
Linux

Backup & Restore

Cheat sheet · https://pcornel.dk/topic.php?topic=2902

Back to the Topic

Answer

Backup and restore on Linux means copying data (and enough of the system to rebuild it) to separate storage on a schedule, keeping versions, and proving that restores work.

Remember

Follow 3-2-1: three copies, two media, one off-site (or immutable). Back up configuration (/etc), data (/home, /var/lib, databases with their own dump tools) and the package list. A backup is only proven by a restore test.

First checks

  • rsync -aHAX --delete --dry-run <src> <dst> — preview a metadata-preserving sync
  • tar --acls --xattrs -czf <file> <dir> — archive with ACLs and xattrs
  • sha256sum <file> — checksum to verify copies
  • systemctl list-timers — scheduled backup jobs

Commands

tar
Create, inspect or extract archive streams while preserving selected filesystem metadata.
gzip
Compress or decompress gzip streams and files.
rsync
Synchronize files and directory trees while transferring only required differences and selected metadata.
dd
Copy raw byte ranges between files or devices with explicit block, offset and conversion controls.

Verify in this order

data selected → consistent copy (snapshot/dump) → transferred to separate storage → versions kept → restore tested

Where it usually breaks

First mismatch in persistent intent → provider/parser/generator → kernel/userspace runtime → dependency/security context → logs/counters → consumer-visible read-back; preserve identity/native diagnostic/pre-state before mutation.

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=2902

Confirmation

Confirm action

Continue?