Page 1 of 1

Backing up Entire Raspberry Pi

Posted: Wed Jun 06, 2018 9:39 pm
by creative-2008
A couple of times now I've messed things up on the Pi, and it's felt easier to wipe the card and start again. Ideally I don't want to keep repeating the same set-up each time, so I'd like to make snapshot backups of the entire card from time to time, so that I can restore to that back-up next time that something goes wrong.

In an ideal world, I'd like the Pi to copy backups to an external drive or cloud storage weekly without any user interaction. However, I *think* from my research that this is only able to copy the Home area etc, and wouldn't actually allow me to say return to a point where I hadn't edited fstab for example, or installed a new program. Is that correct?

I'm working on the assumption that it's not possible, and that I'm going to need to power down the device for each backup and physically remove the card. If so, what's the easiest thing for me to do? I'm thinking that having some sort of image file that I can just reinstall from is going to be easiest.

I have a Windows 10 laptop, and also have Ubuntu that I can run 'live' from a USB stick. Is using the SD card options from the bottom of this article on Linux the easiest thing to do?

https://www.raspberrypi.org/documentati ... /backup.md

Re: Backing up Entire Raspberry Pi

Posted: Wed Jun 06, 2018 10:19 pm
by MaxTheSpy
go to this page and then scroll down to SD card copier.

If you are running raspbian OS the easiest thing to do would be to get a USB to micro SD adapter and plug the micro SD carn into the adapter and then into the pi. Go to the start button and then down to SD card Copier. select your SD card, the frest one you just inserted and click go. It will copy everything, files and settings and whatnot. Its essentially making a 1:1 clone of your PI. Remember to keep that one safe, and after making any large changes with your OS, Overwrite that Sd card with the current state so your back ups stay up to date.

Let me know how this works out for you. If you need any help with that let me know.

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 5:35 pm
by creative-2008
Wow! That was incredibly easy, and being able to do it without physically needing to shutdown the Pi and remove the card, means I'm much more likely to do it. I have a few spare cards so I can keep a couple of backups.

If I wanted to archive off different backup points into say an archive file (the linux version of zip for example) how is this easiest achieved?

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 7:02 pm
by fbe
You are finished when you are able to create a bootable SD card from your backup. Did you try this?

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 7:04 pm
by JJL1
I think you would have to copy SD card to file then archive with archiver. I'm a noob so there may be a better answer

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 8:05 pm
by n67
Keep in mind that although the "SD card copier" (aka, piclone) is quickly becoming the canonical answer to this very-frequently-asked-question, it is true that it is copying a live system.

And, in theory, this can be a problem.

I remember very early on in the Pi days, when someone would suggest any backup method that involved copying a live system, all the regulars would go apoplectic in horror. But now that the method is enshrined in the system, all of a sudden, it's all OK.

I've also seen postings here to the effect that after selecting the piclone window and filling in the fields, you should sit and count to, say 15, before clicking the final OK - just to give things one more chance to "settle down".

Myself, I've never had any problems with copying the live system. Maybe I'm just lucky...

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 8:42 pm
by JJL1
n67 wrote:
Tue Jun 12, 2018 8:05 pm
Keep in mind that although the "SD card copier" (aka, piclone) is quickly becoming the canonical answer to this very-frequently-asked-question, it is true that it is copying a live system.

And, in theory, this can be a problem.

I remember very early on in the Pi days, when someone would suggest any backup method that involved copying a live system, all the regulars would go apoplectic in horror. But now that the method is enshrined in the system, all of a sudden, it's all OK.

I've also seen postings here to the effect that after selecting the piclone window and filling in the fields, you should sit and count to, say 15, before clicking the final OK - just to give things one more chance to "settle down".

Myself, I've never had any problems with copying the live system. Maybe I'm just lucky...
I've never had a problem with it. I'm amazed the SD cards don't have to be the same size. Must be image magic!!! :o

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 9:35 pm
by Roken
You can always use rsync to clone a live system whilst excluding dynamic directories (/dev etc.), which should also give a reliable backup solution.

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 11:06 pm
by n67
Roken wrote:
Tue Jun 12, 2018 9:35 pm
You can always use rsync to clone a live system whilst excluding dynamic directories (/dev etc.), which should also give a reliable backup solution.
I'm not much of a fan of rsync, but you would use whatever option it has to tell it not to cross filesystem boundaries. That will prevent it from copying /proc, /dev, /sys (and probably others), as well as anything else mounted (e.g, under /mnt or /media).

But that's not really the point. The point is that some background process could be writing to some arbitrary (normal) data file at the exact moment when your backup job is reading that file, and the result would be an indeterminate file in the backup. Not a catastrophe - presumably, only that one file would be affected, not the whole backup - but if that one file were important, then it would be a cause for concern.

Re: Backing up Entire Raspberry Pi

Posted: Tue Jun 12, 2018 11:07 pm
by n67
I've never had a problem with it. I'm amazed the SD cards don't have to be the same size. Must be image magic!!!
It's not. piclone does not do an "image" type backup. It does a file-by-file, using "cp".

You can verify this by doing "ps" (or "top") commands while it is running.