Here’s a compact, reliable playbook to back up and restore a [Raspberry Pi](https://www.ampheo.com/c/raspberry-pi/raspberry-pi-boards) (SD card, USB SSD, or NVMe on [Pi 5](https://www.ampheo.com/search/Pi%205)). Pick the method that fits your setup and OS.

**Option A — Full-disk image (best “snapshot” backup)**
**On Windows**
1. Remove the Pi’s card/drive and plug it into your PC.
2. Use Win32 Disk Imager (or HDD Raw Copy):
* Select the device (e.g., E:).
* Choose a filename like pi-YYYYMMDD.img.
* Click Read to create the image.
3. Restore: Pick the image file and your target card/drive, click Write.
**On macOS / Linux**
1. Identify the device:
* macOS: diskutil list (e.g., /dev/disk2 → use rdisk2 for speed).
* Linux: lsblk (e.g., /dev/sdb).
2. Unmount it:
* macOS: diskutil unmountDisk /dev/disk2
* Linux: sudo umount /dev/sdb? (all partitions)
3. Create the image:
```
sudo dd if=/dev/rdisk2 of=~/pi-$(date +%Y%m%d).img bs=4m conv=sync,noerror status=progress
sync
```
4. Restore to a new card/drive:
```
sudo dd if=~/pi-20250820.img of=/dev/rdisk2 bs=4m conv=sync status=progress
sync
```
**Tips**
* You can’t write a bigger image to a smaller card unless you shrink the source first (use gparted to shrink the ext4 partition, or a script like PiShrink before imaging).
* After restore, Pi OS usually expands rootfs on first boot; if not, run sudo raspi-config → Advanced Options → Expand Filesystem.
**Option B — Clone live to another card/drive (no PC needed)**
On Raspberry Pi OS with Desktop: Accessories → SD Card Copier (aka piclone).
* Source: your current disk.
* Destination: USB card reader / [SSD](https://www.onzuu.com/category/ssds-hdds).
* Click Start to make a bootable clone.
This is great for creating a ready-to-swap spare.
**Option C — Incremental/file-level backups (fast, space-efficient)**
**1) Rsync to USB drive (from the Pi)**
```
# Mount backup drive at /mnt/backup first
sudo rsync -aAXH --info=progress2 \
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} \
/ /mnt/backup/rootfs/
sudo rsync -aAXH /boot/ /mnt/backup/boot/
```
Restoring means installing a fresh Pi OS and then rsyncing the folders back (or just copying targeted files like /home, /etc).
**2) Rsync over the network (from a PC)**
```
# On your PC (Linux/macOS), pull from the Pi:
rsync -aAXH --numeric-ids pi@raspberrypi:/ /backups/pi-root/ \
--exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"}
rsync -aAXH --numeric-ids pi@raspberrypi:/boot/ /backups/pi-boot/
```
**What to always save (even if you don’t image)**
* Home & data: /home/pi/…
* Network & system config: /etc/wpa_supplicant/wpa_supplicant.conf, /etc/dhcpcd.conf, /etc/hostname, /etc/hosts, /etc/fstab, any /etc/systemd/system/*.service
* Package list (for re-install):
```
dpkg --get-selections > packages.list
# restore on fresh OS:
sudo apt-get update
sudo dpkg --set-selections < packages.list
sudo apt-get dselect-upgrade -y
```
* Docker / compose: your docker-compose.yml and named volumes (or docker volume backup).
* Custom kernels/overlays: /boot/config.txt, /boot/cmdline.txt, /boot/overlays/.
**NVMe/USB SSD (Pi 4/5) specifics**
* Treat the disk like an SD card: image/clone the whole device (/dev/sdX or /dev/nvme0n1) using dd/Win32 Disk Imager, or clone with SD Card Copier (source = NVMe, dest = USB).
* If the target is smaller, shrink partitions first (gparted) before imaging.
**Verify your backup (recommended)**
Mount and inspect the image:
* Linux: sudo kpartx -av pi.img → mounts partitions under /dev/mapper/…
* Or use a tool (7-Zip/OSFMount on Windows) to open the FAT32 /boot and ext4 root.
Checksum: sha256sum pi-YYYYMMDD.img > pi-YYYYMMDD.img.sha256 and keep both.
**Common restore pitfalls (and fixes)**
* Different-size cards: shrink first (source), or restore to equal/larger media.
* Cloned many Pis? Change hostname, static IPs, and regenerate SSH host keys:
```
sudo rm /etc/ssh/ssh_host_*
sudo dpkg-reconfigure openssh-server
```
* Headless boot lost SSH/Wi-Fi: ensure /boot/ssh file exists and wpa_supplicant.conf is in /boot (for first-boot copy) or in /etc/wpa_supplicant/.
**Quick choices**
* Want a set-and-forget spare? → SD Card Copier to a second card/SSD.
* Need an off-device snapshot? → Disk image with Win32 Disk Imager or dd.
* Want frequent, small backups? → rsync (cron job) of /home + /etc (+ package list).