I’m all too aware of the frailties of the humble SD card when being used with a raspberry pi. There’s nothing more frustrating than getting your pi set up exactly how you would like it, only for your SD card to corrupt, for no apparent reason, but most probably because we’re using an SD card for something that it wasn’t designed (as a system disk).
As a result of bitter experience, I have started backing up my SD cards periodically so I can quickly restore them should they fail. I will take you through my process now. I’m hoping that this backup, that I’m about to make, will be used as an image that I can put onto a USB drive so I can start running from that. The how to for that will hopefully be in a later post.
SSH onto your pi from your mac
Open a terminal and ssh to your pi:
Now we need to shutdown your pi so we can remove the card and complete the backup.
sudo shutdown now
Wait for your pi to shutdown. Now you can unplug your pi and remove the SD card.
Take the SD card to your mac
Insert the SD card into your mac (using your usual card reader or the build in card reader if you have one). You should see a “boot” mount appear under “devices”.
Apple pi baker
The software I use for running backups (and putting images on SD cards) is apple pi baker
If you don’t already have it, download, install, and open.
You’ll be asked for your admin password to allow apple pi baker to access the SD card.
Select your SD card and click “Create Backup”.
Give your backup a name, select a save location, and click “Save”.
Let Apple Pi Baker create the backup for you.
After it completes, you can zip the image up to reduce it’s size before storing it.
Eject your SD card and put it back in your pi. Then power it back on.
Hopefully your SD won’t corrupt, but now if it does, you have a backup that you can use to get you up and running again quickly.
To restore from this backup you simply put an SD card (of the same size) in your card reader, select your image file and click “Restore Backup” on apple pi baker.