Home > Raspberry Pi, Uncategorized > Backing up your Pi’s

Backing up your Pi’s

Backing up your Raspberry Pi isn’t very straight forward on a Mac, but if like me you’re short on memory cards and you want to keep what you’ve been working on so that you can go back to it later, then you’ll need to start backing them up.

The easiest way is going to be to make a full disk image of the memory card, so that you can be sure you have an exact replica of the file system.

Here’s how I do mine now.

Open a Terminal window and type “diskutil /list”. This will give you a list of disks currently attached to your Mac. The first one will be the main disk inside the Mac, and then any after that will either be your SD card, or could also be another disk image you have mounted. If you look at the Size column, you should be able to find which one matches the size of your SD card.
Once you’ve found the right card, over on the left is the device number that the MacOS allocated it when you plugged it in. In my case, my 8GB SD Card is allocated to /dev/disk1
diskutil list
/dev/disk0
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:      GUID_partition_scheme                        *250.1 GB   disk0
   1:                        EFI                         209.7 MB   disk0s1
   2:                  Apple_HFS MacOS                   249.7 GB   disk0s2
/dev/disk1
   #:                       TYPE NAME                    SIZE       IDENTIFIER
   0:     FDisk_partition_scheme                        *7.9 GB     disk1
   1:             Windows_FAT_32                         73.4 MB    disk1s1
   2:                      Linux
Once we know the disk number, we’re going to add an ‘r’ in front of the disk part to access it much quicker (just means that your back up will be quicker.  To back up the disk use this command:
sudo dd if=/dev/rdisk1 of=media.img bs=1m
This will create a file called ‘media.img’ which is an image of your SD card (you can call it whatever you like).
To restore the image you’d just use
sudo dd if=image of=/dev/rdisk1 bs=1m
(assuming that your SD card is still /dev/disk1 when you plug it back in).
Notes
  • On my Mac, the 8GB card took about 20 mins to back up.
  • If you want to compress the image, you can use something like this: udo dd if=/dev/rdisk1 bs=1m | gzip > media.img.gz (to restore an compressed image with “bunzip2 -dc media.img.bz2 | dd of=/dev/disk1”
Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: