Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Backups and Recovery Basics

Backups are not optional once your Linux system contains work you care about. A good backup plan is simple, repeatable, and tested.

Backup Strategy for Desktop Users

Use the 3-2-1 mindset:

  • 3 copies of important data
  • 2 different storage types
  • 1 copy off-device

A practical setup:

  • Primary data in home directory
  • External drive backup weekly
  • Cloud or remote backup for critical documents

What to Back Up First

  • Home folders (Documents, Projects, Photos)
  • Browser profile data
  • SSH keys and password manager vault exports
  • Important config folders like .config

You usually do not need to back up cache directories such as ~/.cache.

Backup Scope Template

Define this once and keep it documented:

  • Must backup: personal files, project repos, keys, secrets
  • Nice to backup: desktop settings, app profiles
  • Do not backup: large regenerable caches and temporary files

Fast Backup with rsync

rsync -avh --delete /home/youruser/Documents /media/backup-drive/Documents

More practical home backup pattern with exclusions:

rsync -avh --delete \
	--exclude='.cache' \
	--exclude='Downloads' \
	/home/youruser/ /media/backup-drive/home-backup/

Run this manually first, then automate after you trust the result.

Warning: --delete removes files on the destination that no longer exist in source.

System Snapshots

Snapshots help with system rollback after bad updates, especially on snapshot-friendly filesystems.

  • Use snapshot tools supported by your distro.
  • Snapshot before major updates or driver changes.
  • Keep only a reasonable number of snapshots.

Snapshots are not a replacement for external backups.

Recovery Drill

A backup is only real after restore is tested.

  1. Restore one file to a test location.
  2. Restore one folder.
  3. Confirm file integrity.
  4. Document restore steps.

Example restore command:

rsync -avh /media/backup-drive/home-backup/Documents/ /home/youruser/Documents/

If restoring into an active system, confirm ownership and permissions after restore.

Scheduling Backups

Start manual, then automate with one method:

  • crontab for simple schedules
  • systemd timers for more robust Linux-native scheduling

Example weekly cron entry:

0 2 * * 0 /usr/local/bin/backup-home.sh

Keep scripts readable and log every run.

Disaster Recovery Checklist

If a disk fails or system becomes unbootable:

  1. Stop writing to damaged disks.
  2. Boot from live USB.
  3. Mount backup destination read-only first.
  4. Restore critical files before optional files.
  5. Rebuild user environment after data restore.

Common Backup Mistakes

  • Keeping backup on same physical disk as source
  • Never testing restore
  • Backing up too much and never cleaning old sets
  • Assuming RAID means backup

RAID improves availability, not historical recovery.

Key takeaways

  • Backup discipline is part of Linux reliability, not an optional extra.
  • Start with home data and scale gradually.
  • Rsync is a strong baseline tool for predictable backups.
  • Test restores regularly to verify your plan actually works.
Last change: