microSD cards fail, and almost always without warning: a power cut or a worn-out card and you lose weeks of configuration. A full backup gets your Pi running again in minutes. Here you will see how to clone the card on Windows, macOS and Linux, how to compress and restore the image, and how to back up only your data with rsync.
In short
- There are two strategies: a full image of the card (restore everything as it was) or a data backup with rsync (lighter and more frequent).
- Raspberry Pi Imager does not make backups: it only writes images. To read the card you need
dd, Win32 Disk Imager, SD Card Copier or rpi-clone.- With
dd, a mistake in the disk name erases the wrong disk. Check the device twice.
Full image or data backup

| Full image | Data backup with rsync | |
|---|---|---|
| What it keeps | Everything: system, partitions and data | The folders you choose |
| Size | That of the whole card (less if compressed) | Only what your files take |
| Restore | Write the image to a card | Install the system and copy files back |
| Sensible frequency | After big changes | Daily or weekly |
| Pi powered off | Yes, normally | No: done while running |
Ideally combine both: an image once your system is set up and rsync day to day.
Clone the card on Linux with dd
Shut down the Pi, take out the card and connect it to your computer with a reader.

- Identify the device. Look at the size, not just the name:
lsblk
The card shows up as something like /dev/sdb or /dev/mmcblk0, with two partitions (bootfs and rootfs).
- Unmount the partitions if the system mounted them automatically:
sudo umount /dev/sdb1 /dev/sdb2
- Read the whole card into a file:
sudo dd if=/dev/sdb of=~/raspberry-backup.img bs=4M status=progress conv=fsync
if is the source (the card) and of the destination (the file). If you swap them, you overwrite the card with the file. Always use the whole disk (/dev/sdb), never a partition (/dev/sdb1).
Clone the card on macOS
macOS also includes dd, with different disk names.
- List disks and find the card by its size:
diskutil list
- Unmount the card, do not eject it. Replace
disk4with yours:
diskutil unmountDisk /dev/disk4
- Copy using
rdisk, the raw access, which is much faster:
sudo dd if=/dev/rdisk4 of=~/raspberry-backup.img bs=4m
macOS dd does not always show progress. Press Ctrl+T in the terminal to see how many bytes it has copied.
Clone the card on Windows
Windows has no dd. The most used tool is Win32 Disk Imager, which can read a card:
- In Image File type the path and name of the file to create, ending in
.img. - In Device select the drive letter of the card’s
bootfspartition. - Click Read. Do not click Write: that writes the image to the card.
If Windows offers to format the card when you insert it, say no. It sees the rootfs partition (ext4) as unreadable; that is normal.
Clone from the Raspberry Pi itself
If you prefer not to remove the card, you can clone it to another card or a USB-connected SSD with the Pi running.
SD Card Copier (desktop)
Raspberry Pi OS with desktop includes SD Card Copier in the Accessories menu:
- Connect the destination card or drive with a USB adapter.
- In Copy From Device choose the internal card and in Copy To Device the destination.
- Click Start. It erases the destination completely.
It adjusts partition sizes to the destination, so you can copy to a smaller card if the data fits. The New Partition UUIDs option lets you use both cards on the same Pi at once.
rpi-clone (terminal)
rpi-clone is a script that does the same from the terminal and, on later runs, only copies changes with rsync, making it very fast for periodic backups. The original project is no longer maintained; use a maintained fork and read its install instructions. Basic use:
sudo rpi-clone sda
Where sda is the destination disk, without /dev/. The script shows what it will do and asks for confirmation.
Cloning a running system is convenient, but if a program is writing at that moment (a database, for example), those files may end up inconsistent. For critical services, stop them first or image the Pi powered off.
Compress the image
An image takes as much as the card, even half empty: a 64 GB card gives a 64 GB file. Empty space compresses very well:
| Tool | Command | Note |
|---|---|---|
| gzip | gzip -k raspberry-backup.img | Fast, compatible with everything |
| xz | xz -k -T0 raspberry-backup.img | Smaller files, slower; -T0 uses all cores |
| zip | zip backup.zip raspberry-backup.img | Handy to open on Windows |
You can also compress while copying, skipping the giant file:
sudo dd if=/dev/sdb bs=4M status=progress | xz -T0 > ~/raspberry-backup.img.xz
To shrink further, PiShrink (Linux) shrinks the system partition to the used space. The image then fits on smaller cards and expands again on first boot.
Restore the image
The safest way is Raspberry Pi Imager: in Choose OS scroll to Use custom and select your file. It accepts .img and compressed ones such as .img.xz, .gz or .zip.
With dd on Linux:
xzcat ~/raspberry-backup.img.xz | sudo dd of=/dev/sdb bs=4M status=progress conv=fsync
Note that two 32 GB cards do not have exactly the same capacity. If the destination is slightly smaller, restoring an unshrunk image fails at the end. Restoring to an equal or larger card avoids the problem.
Back up only your data with rsync
Day to day you do not need to clone the system. Just keep what cannot be reinstalled: your home folder, /etc and your services’ data. With a USB drive mounted at /mnt/backup:
sudo rsync -aAXH --delete /home/ /mnt/backup/home/
sudo rsync -aAXH --delete /etc/ /mnt/backup/etc/
| Option | What it does |
|---|---|
-a | Archive mode: recursive, keeps permissions, dates and links |
-A | Keeps ACLs |
-X | Keeps extended attributes |
-H | Keeps hard links |
--delete | Deletes at the destination what no longer exists at the source |
--dry-run | Simulates without copying |
The trailing slash on the source matters: /home/ copies the folder’s contents; /home would create home/home at the destination. Try --dry-run first, especially with --delete.
You can also send the backup to another computer on the network over SSH:
rsync -aAXH --delete /home/your-user/ user@192.168.1.50:/copias/raspberry/
To make it automatic, schedule these lines with cron or a systemd timer.
Common mistakes
- Picking the wrong disk in
dd. It is irreversible. Check size withlsblkordiskutil listright before and unplug external drives you do not need. - Thinking Raspberry Pi Imager makes backups. It only writes; it does not read the card.
- Keeping the backup on the same card. If the card dies, the backup dies with it.
- Never testing a restore. A backup you have not restored is a guess. Write it to another card once and boot from it.
- Using
--deletewithout--dry-runthe first time, with source and destination swapped. - Running out of space on the computer. The uncompressed image takes the whole card; compress on the fly if you are short.



