Raspberry Pi SD Card Backup

This post was originally published on golifelog.com.

I'll be working on a small Raspberry Pi project at my parent's home, so I thought it is time to backup my own home automation setup in case the SD card breaks. I had at least one of those cards break on me in the past without a backup, so I searched for the steps necessary to create disk images and restore procedures.

Every step was done on my M1 MacBook Pro. And I also tested the restore process (it doesn't help if you've got a backup you can't restore).

diskutil list check which /dev/ devices is the SD card
mount // boot disk is auto-mounted by macOS, unmount

sudo dd if=/dev/disk5 of=./20240418.img bs=1M status=progress // will create an image file inside the current directory

docker run --privileged=true --platform linux/x86_64 --rm --volume $(pwd):/workdir borgesnotes/pishrink pishrink -vrz 20240418.img // shrink the image and put it into a gz compressed file

The image can be restored via Balena Etcher onto a new SD card.

Subscribe to Philipp Haidenbauer | Blog

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
jamie@example.com
Subscribe