I’ve started using a Raspberry Pi 3 to learn some new technologies. I want to be able to backup the files from the SD card used by the system because I don’t want to lose the configure and startup files and have to start from scratch if something goes awry.
The easiest process that I found was to load the SD card into my MacBook, which has a SD slot, and just copy the image. After inserting the card, you need to determine the name of the drive to be backed up. From a bash prompt, use the diskutil utility to list the drives in your machine.
From these results, you can see that 16 GB Linux disk is disk2. You feed this value into the dd command and use the rdisk (raw disk) to speed up the operation:
sudo dd if=/dev/rdisk2 of=raspbian.stretch.setup bs=1m
This will create the file raspbian.stretch.setup in the current directory:
To reduce the size of the backup, you can use the zip command to compress the file.
zip -r stretch.setup raspbian.stretch.setup
You can see that the filesize has been deflated 86% from 16 GB to 2 GB. The next step in the process would be to delete the original file.
I plan to try and write a Python script to automate this process. Maybe you’ll see a blog post on that process if I do.