This topic has been discussed numerous places throughout the Internet, but I always find myself having to re-google this every time I need it. For my own reference, the steps to backup an SD card on OS X are:
- Insert the SD card into your Mac (seems obvious)
- From terminal, run `df -h` and make note of your SD card. My shows up as “/dev/disk2s1”
- Launch Disk Utility, and “unmount” that partion. (Note: do not eject it).
- From terminal, run dd to backup. If the partion noted in df was “disk2s1” we’ll be backing up “disk2”. For example: “sudo dd if=/dev/disk2s1 of=my-backup.img bs=1m”
That is it for backing up. To restore an SD card from backup:
- Insert the target SD card into your Mac (again, obvious, right?)
- From terminal we’ll run `df -h` again to verify the correct device. Though unlikey to have changed from the restore step, it’s always good to double check this. A mistake here will result in you toasting something.
- From Disk Utility “unmount” the partion noted in step 2. (again, do not eject it)
- From terminal we’ll run dd to restore our SD card from backup. If the partiion noted in step 2 was “disk2s1” we’ll be restoring to “disk2”. For example:
When storing a backup image long term (e.g., for anything longer than simply backing up to immedately restore to a new SD card), I compress my backup files.
To compress, simply:
- gzip -9 my-backup.img
To decompress:
- gzip -d my-backup.img.gz
That should be it, have fun!