List and unmount disk
sudo diskutil list
sudo diskutil unmountDisk /dev/disk2
Backup SD card
sudo dd if=/dev/rdisk2 of=./sd_card.img bs=4m
Restore SD card
sudo diskutil list
sudo diskutil unmountDisk /dev/disk2
sudo dd if=./sd_card.img of=/dev/rdisk2 bs=4m