Skip to main content

Make a backup of your Raspberry Pi

It's always these small menial tasks that you do once and a while that costs so much time, because you can't remember how to do it and you run into the same culprits time and again.

Here's how to make a backup of the SD card of a Raspberry Pi.

  1. Make a clean shutdown of your Raspberry Pi.

    sudo /sbin/shutdown -h now
    
  2. Take our the SD card and input it into your Mac. This will cause the Mac to mount any partitions it see as mountable.

  3. List the partitions on your system.

    diskutil list
    
  4. Find the mounted partitions and unmount them. (can't use the Eject functionality from Finder)

    diskutil unmount /dev/disk<X>s<Y>
    

* Where is drive number and is partition.

  1. When all partitions are unmounted (mind you, not ejected) run the following command to read the SD card and write it to disc.

    sudo dd bs=4m if=/dev/disk<X> | gzip > ~/backup.img.gz
    
  2. After you're done you may eject the SD card with the following command.

    diskutil eject /dev/disk<X>
    

Now you're done and you may put the SD card back into your Raspberry Pi and boot it back up.

comments powered by Disqus