RPi3 MicroSD Backup and Transfer, the Easy Way (Mac OSX El Capitan)

Author profile picture

@attilavagoAttila Vago

Writer of codes, blogs and things that live on the web. Loves craft beer!

The Raspberry Pi3 Board

One detail we often forget in web and software development is how much we rely on the OS we use, be that MacOS, Windows or Linux. When that OS is actually running our tiny but mighty web server, the reasons to have things backed up and readily available, are tenfold. So without further ado, this is the easy way of backing up your entire MicroSD and transfer onto another card. Why you’d want to transfer it to another card? Well, first of all to have that above-mentioned backup ready to go at any time and also you might find yourself needing a larger card, say a 64GB instead of the old 8 or 16GB. This will quite possibly also improve the speed of your Pi as newer, high storage card tend to have higher transfer speeds.

The mighty backup process is actually quite simple and requires just a few commands in your Terminal.

  1. Power off your Pi, pop the card out, and then into your card reader.
  2. Type the below command into the Terminal window. This will show you all your disk drives. Make sure you find the the disk that represents your card in the list. Misidentifying it may cause you to mess up your actual computer’s storage, so do please double and triple-check. You should see something like /dev/disk followed by a number. In my case it was /dev/disk3
diskutil list

3. Now, pay really good attention to the next command. And USE THE DISK NUMBER OF YOUR SPECIFIC CARD. Failing to do that will bring cylons down from above into your computer and trash it. Honest!

This command will copy the entire microSD card’s content into a .dmg file into your home directory. The command itself does not provide any feedback in the terminal, so just wait until you get the prompt again. For your peace of mind, in order to verify that things are happening, go into your home directory, right click on the SDCardBackup.dmg file and click “get info”, you’ll see the size growing. It will take a good while. In my case, an 8GB (and quite old) card took about 20 minutes to transfer.

sudo dd if=/dev/disk3 of=~/SDCardBackup.dmg

4. Unmount your card to safely remove it. Again, be extra careful about the disk number!

diskutil unmountDisk /dev/disk3

Excellent. Now the initial backup has been created, and you’re ready to roll things onto a new card. At this point you actually have 2 backups. One on the old card and one on your machine. That’s what I call having a backup for the backup. ;)

To get the backup from your machine onto the new card, you need to ensure it’s formatted correctly. Now, what most people seem not to be aware of is that on a Mac you actually don’t need any app to format a card, and you can set the file system as well. This is important because by default cards larger than 32GB tend to get formatted into NTFS. You want FAT32, and that’s very important.

  1. Find your new card:
diskutil list

2. Like in the previous section, make sure you identify the right disk number, otherwise you may run into massive problems. If you want to name it something else than “Raspbian”, feel free to change the name.

sudo diskutil eraseDisk FAT32 RASPBIAN MBRFormat /dev/diskNUMBER

3. You can test it worked, by running the

diskutil list

command again. You should see the card now being a FAT32 card.

4. Make sure the card is unmounted:

diskutil unmountDisk /dev/disk3

5. Then run the below command (again, make sure you’re using the right disk number). This will copy everything from that image on your machine to the new card. This will take a while and you can’t really verify how far along it is, but just wait until you get the prompt again in your terminal.

sudo dd if=~/SDCardBackup.dmg of=/dev/diskNUMBER

6. Once that’s finished, eject safely your card:

sudo diskutil eject /dev/rdisk3

And that’s that. Quite simple and effortless if you ask me. Takes a couple of hours due to the flashing and copying, but it’s worth it. You can now pop the new card into the Pi and run it just like you would have with the old card.



The Noonification banner

Subscribe to get your daily round-up of top tech stories!