Backup a Raspbian Installation

I only have one decent sized SD card for use with my Raspberry Pi, a 32GB Sandisk SDHC card. I recently started looking at Raspbmc for XBMC use (as the installation looks better than installing XBMC on top of Raspbian).

As such, I googled it. Found it on stackexchange and an subsequently reposting what I have found, in a hopefully easier to read way.

To Backup

  1. Open Terminal
  2. Run diskutil list and select the /dev/DISKNAME that has a linux installation on it (see below,).

After running diskutil list I saw the below (top is my Internal HDD, bottom is the SD Card).

adamsmac:dev adam$ diskutil list
 0: GUID_partition_scheme *500.1 GB disk0
 1: EFI 209.7 MB disk0s1
 2: Apple_HFS Mac OS 424.0 GB disk0s2
 3: Apple_Boot Recovery HD 650.0 MB disk0s3
 4: Microsoft Basic Data BOOTCAMP 75.2 GB disk0s4
 0: FDisk_partition_scheme *31.9 GB disk1
 1: Windows_FAT_32 58.7 MB disk1s1
 2: Linux 31.9 GB disk1s2

3. we now need to run the dd command to copy the disk to our hard drive.

sudo dd if=/dev/disk1 of=/Users/adam/Desktop/rpi

The above will copy disk1 to an image called rpi on my desktop. I have about 4GBs on my installation, which took about 10 – 15 minutes to copy. I had NO prompts in Terminal as to progress, so just used Get Info on the image file to see if it was increasing in size.

You are now done!

To Restore

Run the commands in reverse. Using the above example, I would do:

sudo dd if=/Users/adam/Desktop/rpi of=/dev/disk1

Wait a similar length of time it took you to backup and you should be good to go.

NOTE: If you have your installation set to expand to the entire size of the disk (probably done when you installed Raspbian), dd will copy the whole 32GB regardless of if there is anything on there, which could take some time.


If you want to make your backups smaller, use gzip.

When backing up use: sudo dd if=/dev/disk1 | gzip > /Users/adam/Desktop/rpi

When restoring use: sudo gzip -dc /Users/adam/Desktop/rpi | dd if=/dev/disk1

NOTE: I have not tried the gzip yet, just letting you know it can be done.


Leave a Reply