Tuesday, September 25, 2012

Backing up the Raspberry Pi

The code base for the Robot lives upstream from the RPi and is downloaded on update but there is a fair amount of other configuration that goes into the Raspberry Pi that really needs backing up!   Having done a re-install once already...I know this!

The easy way to do a backup is to copy the entire SD card.  You can do this from the RPi if you have a second card reader but between the speed of the Raspberry and the speed of the cards this makes a slow process even slower.   I make my backups on my Ubuntu machine as follows.

Insert your SD card and find out what the two device names you need to backup:


First Way:  Use the 'dd' command to make a full backup from the SD card to your hard drive (this will take a while):



Second Way:  Instead of using dd you can just do a cp (it will actually be quicker than dd if your disk is less than full but slower if your disk is more full than empty).  In the example below I have positioned myself in a sub-directory within which I want my backup to reside:

    sudo cp /media/10b4c001-2137-4418-b29e-57b7d15a6cbc . -r

The problem with the second way is that everything comes across in a restore as being owned by root.   I think, but could be wrong, that dd preserves ownership?  In any case I only use the default user of 'pi' so fixing this is easy:

    sudo chown -R pi .

What I wonder about both of the above is...does it really yield a perfect replica if I had to do a restore?   I am not sure that it would given rights in the second case.

1 comment:

  1. Type man cp or cp --help. You can prserver overship and attributes (suid, sgid) without your backup is useless.

    ReplyDelete