Raspberry Pi Backup and Restore
Wednesday 4th March 2015

I've recently recieved a Raspberry Pi 2 (model b), a lovely little thing... and has been configured as a mini dev team server, a task which it is perfectly suited!

After a couple of hours setting up some scripts, intranet, samba shares extra I thought it would be a good idea to back it up... This is how it's done (on a Mac):

Insert the SD/MicroSD card into your work status, open up terminal and run:

diskutil list

Look for the card you've just inserted (usually a good indicator is the drive capacity) then make note of which disk it is labeled as (in my case /dev/disk4).

/dev/disk4
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *64.0 GB    disk4


Before we back this up you'll need to unmount the disk:

diskutil unmountDisk /dev/disk4

Now for the backup...

sudo dd if=/dev/disk4 of=Desktop/my-pi.img bs=1m

If you need to restore the image we simply switch around the if and of parameters:

sudo dd of=/dev/disk4 if=Desktop/my-pi.img bs=1m

Job done!