From http://raspberrypi.stackexchange.com/a/312
If you are running Linux then you can use the dd command to make a full backup of the image:
dd if=/dev/diskx of=/path/to/image
or for compression:
dd if=/dev/diskx | gzip > /path/to/image.gz
Where sdx is your SD card.
To restore the backup, you reverse the commands:
dd if=/path/to/image of=/dev/rdiskx
or when compressed:
gzip -dc /path/to/image.gz | dd of=/dev/rdiskx
diskutil list