Backup raspberry pi image

Creating a disk image will preserve not only files but also the filesystem structure and when you decide to flash your new SD card, you will be able to just plug it in and it will work.

Mac Plug in your SD card and find out the disk name by enter diskutil list and then:

$ sudo dd if=/dev/rdiskx of=/path/to/new_backup_image.img bs=1m

Where /dev/rdiskx is your SD card.

To restore the image, just type:

$ diskutil unmount /dev/disk1sx
$ sudo dd if=/path/to/new_backup_image.img of=/dev/rdiskx bs=1m

That's all folks