Backup Raspberry Pi using macOS
Looking to backup your SD card for your Raspberry Pi? Want to make an exact image of the drive? Well here are some steps on how to backup your Raspberry Pi using macOS and the Unix utility “dd”.
First get a list of available disks on your Mac by running the command below.
$ diskutil list /dev/disk5 (internal, physical): #: TYPE NAME SIZE IDENTIFIER 0: FDisk_partition_scheme *31.9 GB disk5 1: Windows_FAT_32 boot 268.4 MB disk5s1 2: Linux 31.6 GB disk5s2
Note down the disks ID for the drive you want to backup. In this case the largest disk for the 32GB SD card is “disk5”. Please note that your disk ID may be different.
Next you are going to run the following command to back your disk. Note that the command may vary based on what the disk ID is for your SD card.
sudo dd if=/dev/disk[x] of=~/Desktop/Pi_Image.img
Next wait for the backup to complete and you should then have a backup disk image on your desktop for you Raspberry Pi.
Restore from Backup
First you need to identify the disk ID for the SD card you will be restoring the backup image to.
$ diskutil list
Next you want to unmount the SD card before doing the restore. Take note of the disk ID you identified earlier and replace the disk ID with your using the command below.
sudo diskutil unmountDisk /dev/disk[x]
Now run the command to restore the backup image to your SD card. Once again note that your disk ID may be different. Replace the disk ID in the command below with the disk ID you identified earlier.
sudo dd if=~/Desktop/Pi_Image.img of=/dev/rdisk[x] bs=5m