Backup and restore RPi SDCard on MAC OS

At first, find the disk corresponding to your Pi’s SD card:
Open Terminal, run diskutil list:

$ diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *320.1 GB   disk0
   1:                        EFI EFI                     209.7 MB   disk0s1
   2:                  Apple_HFS Macintosh HD            319.2 GB   disk0s2
   3:                 Apple_Boot Recovery HD             650.0 MB   disk0s3
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:                                                   *0 B        disk1
/dev/disk2
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *2.0 GB     disk2
   1:             Windows_FAT_32 boot                    58.7 MB    disk2s1
   2:                      Linux                         1.9 GB     disk2s2

Clearly /dev/disk2 is my 2GB SD card, the Linux partition name is also a bit of a clue.
However, instead of using /dev/disk2 with dd, you should use /dev/rdisk2

On the Mac you don’t want to be using /dev/diskn, you should use /dev/rdiskn instead, where n is the number the OS uses to identify your SD card. This decreases the time required to copy by a huge amount.

To Backup

To backup the SD card to image file:

sudo dd if=/dev/rdisk2 of=/path/to/backup.img bs=1m 

Or, with gzip, to save a substantial amount of space:

sudo dd if=/dev/rdisk2 bs=1m | gzip > /path/to/backup.gz 

To Restore

To restore the image back onto the SD card, you need to unmount the SD card first.
You can use Disk Utility to unmount it or use the command line as below:
Open Terminal, run mount | grep /dev/diskn to find out which partitions are mounted:

$ mount | grep /dev/disk2
/dev/disk2s1 on /Volumes/Untitled (msdos, local, nodev, nosuid, noowners)

The partition /dev/disk2s1 is mounted, just unmount it:

$ diskutil unmount /dev/disk2s1
Volume (null) on disk2s1 unmounted

After that, just swap the if (input file), and of (output file) parameters:

sudo dd if=/path/to/backup.img of=/dev/rdisk2 bs=1m 

Or, with compress image (.gz file):

gzip -dc /path/to/backup.gz | sudo dd of=/dev/rdisk2 bs=1m 

Sumber: https://www.skiews.com/backup-and-restore-rpi-sdcard-on-mac-os/

Leave a Reply