hairydalek
Posts: 13
Joined: Mon May 28, 2012 7:50 pm

Backing Up & Restoring

Thu May 31, 2012 8:10 am

Hi,
the answer to the question may be as simple as “just drag the files to your HD” - but I’m asking anyway.

I am wondering what the best way to back the Pi’s SD card is. I can, obviously, plug it into my Mac which sees it as a volume, and from there I could just drag the contents of that to a folder on my HD (which would then put it into the regular backup schedule). The reversal of this, to me, also seems possible - dragging the backup files onto an SD card to restore - or move it to a bigger SD card.

Are my assumptions correct? I am asking because when I set up the SD card for my Pi, I had to use some Terminal commands on my Mac to ensure the files were correctly written. Dragging & dropping files in Finder was, apparently, not the way to do it (the same applies to Windows as well).

So - backing up & restoring? Is this a mouse based operation, or some Terminal commands? If the latter, what would they be?
All the best,
Paul.

User avatar
RaTTuS
Posts: 10539
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Backing Up & Restoring

Thu May 31, 2012 8:39 am

yes that should work ...
however it may be worth looking at rsync
so you an rsync the image from your RPi to your Mac
[you can also use dd to duplicate across the network but that is much more involving ;-p]

for example
rsync -va /home [email protected]:/backup
where user is your username on the mac and mac.ip is the ip on the local network [assuming you can ssh into your mac ]
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Backing Up & Restoring

Thu May 31, 2012 8:49 am

To take a snapshot of your whole SD card, use either dd (like when you created the card) or tar (which converts the whole filesystem into a single file).

There are files in the filesystem that are links to other files. If you copy these files then they become separate files in their own right. There are "block special" and "character special" files in /dev that wont copy, and /sys and /proc will cause difficulties too.

However, if all you want to do is to backup your work in /home/pi, then you can do that by copying files.

hairydalek
Posts: 13
Joined: Mon May 28, 2012 7:50 pm

Re: Backing Up & Restoring

Thu May 31, 2012 4:57 pm

rurwin wrote:To take a snapshot of your whole SD card, use either dd (like when you created the card) or tar (which converts the whole filesystem into a single file).
Thanks - I think the tar route may be the best option here.
rurwin wrote:There are files in the filesystem that are links to other files. If you copy these files then they become separate files in their own right. There are "block special" and "character special" files in /dev that wont copy, and /sys and /proc will cause difficulties too.
That makes sense - when I move my Mac’s system to a new drive, I need to use software to clone the drive - a straight drag and drop copy in Finder won’t do the job for the same reasons.
All the best,
Paul.

Frogsiedoodle
Posts: 7
Joined: Wed Jul 04, 2012 3:56 am

Re: Backing Up & Restoring

Wed Jul 04, 2012 3:58 am

What about using terminal to make a disk image of the SD card would that work?

Frogsiedoodle
Posts: 7
Joined: Wed Jul 04, 2012 3:56 am

Re: Backing Up & Restoring

Wed Jul 04, 2012 3:58 am

Sorry not terminal disk utility.

User avatar
clickykbd
Posts: 117
Joined: Wed Jun 06, 2012 2:21 am
Location: Austin, Texas
Contact: Website

Re: Backing Up & Restoring

Wed Jul 04, 2012 7:09 am

I've gotten in the periodic habit of backing up my SD card on my windows box using the win32diskimager utility. One of my USB thumb drives will hold two images... so keeping them safe there.

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Backing Up & Restoring

Wed Jul 04, 2012 1:51 pm

dd is a better option than tar in my opinion.
Restoring is easier via dd as you can just write the whole SD card image back onto the SD card.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

TimGUK
Posts: 2
Joined: Tue Aug 07, 2012 5:57 pm

Re: Backing Up & Restoring

Sat Oct 06, 2012 10:18 am

Hi I doing my head in and this looks like you may be able to help!
I'm a teacher and I have 20 Pies. I have downloaded the image onto one SD card and got it working.
I now want to set up a complete environment with various bits and pieces. Once this is done I want to copy the image on the SD to 19 other SD cards.
I am working on a Mac with the latest OS and assumed that I could just do this with Disk Utility. After hours of mucking around I've come to the conclusion that this won't work. The Mac won't mount the Linux partition on the SD card (the image seems to have two partitions which I don't really understand).
I think from this discussion I just need to use DD to make a copy and then copy it to my other SDs.
Is that correct? Do I need to format the other SDs first?
Can you give me a really simple set of Terminal commands to do this?
Ideally I want some thing that is fool (pupil) proof and relatively quick.
Thanks

User avatar
rurwin
Forum Moderator
Forum Moderator
Posts: 4258
Joined: Mon Jan 09, 2012 3:16 pm
Contact: Website

Re: Backing Up & Restoring

Sat Oct 06, 2012 10:59 am

To back-up the existing SD card, just use the same dd command you used to create it, but with the "if" parameter being the card (the same as the "of" parameter you used originally), and the "of" parameter being a new file on the Mac (like the original "if" parameter, but of course you don't want to over-write the original card image.)

Then to create the clone cards, give a dd command with the "of" parameter being the card and the "if" parameter being the new card image file you created.

All the cards must be the same size. If the clones are bigger then you'll wasted space on all of them. If the master is bigger then you'll get corrupted file-systems on the clones.

If you are going to let the students do this then you'll have to make it bomb-proof. Write protect the image files ("chmod -w filename"), and encapsulate the dd command in a command file.

Return to “Troubleshooting”