Back Up and Restore a Raspberry Pi SD Card Safely

SD cards fail quietly and often, especially on always-on Pis. An hour spent building a backup routine saves a weekend of rebuilding a configured server. Two approaches cover different needs: full disk images for exact clones, and rsync snapshots for frequent incremental backups.

What you need

  • Your working microSD card
  • A second SD card or external drive large enough for the image
  • A card reader on a separate computer, or the Pi itself with a USB card reader
  • For scheduled backups: destination storage such as [[raspberry-pi-network-storage]]

Step by step

  1. Shut down the Pi cleanly with sudo shutdown -h now; imaging a running filesystem risks corruption mid-copy.
  2. Move the card to another computer's reader and list disks carefully with lsblk or Disk Utility to identify the card, not your own drive. Overwriting the wrong disk destroys data.
  3. Create a full image: on Linux/Mac run sudo dd if=/dev/sdX of=pi-backup.img bs=4M status=progress replacing sdX with your card. On Windows use Raspberry Pi Imager's "Use custom" plus a cloning tool like Win32DiskImager.
  4. Compress the result (zip pi-backup.zip pi-backup.img) since blank space compresses heavily; label it with the date and what the Pi does.
  5. To restore, flash the image back with dd reversed (of= the card) or via Raspberry Pi Imager choosing your .img as custom OS.
  6. Verify a restore by booting the restored card in the Pi and logging in; a backup you never tested is a hope, not a plan.
  7. For live incremental backups without downtime, set up rsync over SSH from the Pi to a NAS: rsync -avz --delete /home/youruser/ nas:/backups/pi-home/ in a cron job nightly.
  8. Include critical config directories in rsync jobs too: /etc tweaks, crontabs (crontab -l > ~/crontab.txt), and any service databases like Pi-hole's /etc/pihole.
  9. Keep at least two generations of backups on separate physical drives; cards sometimes die while being read.

Common mistakes

  • Guessing device names in dd; one wrong letter erases a laptop drive. Triple-check lsblk output.
  • Backing up only /home and losing installed packages; export a package list with dpkg --get-selections > packages.txt as a rebuild recipe.
  • Leaving a full-image cron job writing to the live SD card, wearing it out faster than normal use.
  • Storing the only copy of the backup on the same Pi that could die.

Related guides

The destination for these backups is usually [[raspberry-pi-network-storage]], and services worth protecting include [[pi-hole-network-ad-blocking]] configs. Rebuilding from scratch after a loss means redoing [[raspberry-pi-headless-setup]] anyway, so image first.