To back up your raspberry pi remotely, you will need to know the ip address, then using the following command
ssh firstname.lastname@example.org “sudo dd if=/dev/mmcblk0 bs=1M | gzip -” | dd of=~/Desktop/pibackup.gz
Replace the xx.x.x.xx with the ip address of your pi, and the final image will be copied to your desktop.
To check from time to time the progress, press “Ctrl + T”, and you will see something like the following:
load: 0.98 cmd: dd 8967 running 0.17u 1.94s 317344+0 records in 317344+0 records out 162480128 bytes transferred in 167.835383 secs (968092 bytes/sec)
To restore the image back you need to restore to SD card
diskutil unmountDisk /dev/disk#
gzip -dc ~/Desktop/pibackup.gz | sudo dd of=/dev/rdisk# bs=1m conv=noerror,sync