backup raspberry pi SD card into image on macos

backup

diskutil list
diskutil unmountDisk /dev/disk3
sudo dd bs=4m if=/dev/rdisk3 | gzip > rpi-backup-`date +%Y-%m-%d`.gz

restore

diskutil list
sudo diskutil unmountDisk /dev/disk3
sudo gzip -dc rpi-backup-`date +%Y-%m-%d`.gz | sudo dd bs=4m of=/dev/rdisk3