LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Using rsync to backup system. Good or bad? (https://www.linuxquestions.org/questions/linux-general-1/using-rsync-to-backup-system-good-or-bad-584795/)

antis 09-15-2007 02:44 AM

Using rsync to backup system. Good or bad?
 
Hi,

Some background first maybe...
I'm running a small server at home for mainly media and entertaing purposes. The system runs off a microdrive of 4Gb but the data on the drive is rarely over 1Gb. I keep the rest on a separate drive.

I have run this set up successfully for 6-8 months now but I can't get over the fact that using a microdrive still feels a bit shaky. I'd hate to do the install all over again in case of a crash so therefore I've been thinking about setting up a cronjob that backs up the entire disk maybe every two days or so.

I could probably use a raid1 set up but it feels abit overkill so I've been looking at using rsync for this.

My idea is to use something as simple as:
Code:

rsync -u -a --delete --exclude "sdb1" / sdb1/
Would this be a good idea?
If the drive should crash, would I be able to just buy a new one, set up the partitions and rsync it back and have a working system? Of course I'll have to activate a swap partition and install a boot loader... but is this a good idea or should I just toss it in the bin and work something else out?

lakris 09-15-2007 04:15 AM

just thinking out loud here... if You get an identical disk You can first go with dd to make an identical copy, preferably by working from a live cd/floppy. Then You will get everything including partitions and grub.
Then run in normal mode and cron Your rsync, but also exclude /proc. Very important!

serafean 09-15-2007 04:18 AM

Hi,

In my opinion, rsync is indeed the way to go in your case. I'd only suggest adding the -r option (recursive).

Seeing you want to rsync your / directory, in the case of a crash an rsync the opposite way would do the trick (actually, for this I suggest using the dd command).

Serafean

homey 09-15-2007 06:54 AM

I use rsync and it works great for backing up the system.
If you are running it from the OS that is live, then you need to exclude some things like /proc and /sys and any drives which are mounted in /mnt .
The x option does that nicely.
Code:

rsync -xav / /mnt/new_root_location
When you go to restore, a person would kind of assume that your system drive has died. In that case, you need to boot to a Linux live-cd and mount the backup location and the new drive partition before running rsync.

antis 09-15-2007 07:18 AM

Thanks for the replies so far. Looks like rsync is the way to go then.

Just a few more questions though.
My backup location will be mounted on /mnt so have I understood things correctly if I say that using the x option would make the exclude option unnecessary?

Would something like this work?
Code:

rsync -uax --delete  / /mnt/sdb1/

homey 09-15-2007 07:29 AM

Yes, the x causes it to skip mounted partitions. So, hopefully, sdb1 is actually mounted in /mnt .
If I use delete, I also use after so it's at the bottom of the list where I can easily see it.
Leave the last / off from the destination...
Code:

rsync -xav --delete-after  / /mnt/sdb1

antis 09-15-2007 11:56 AM

Alright, I've made a small script and took it for a test run and it worked beautifully. This will now run at 4am every Monday, Wednesday and Friday as a cron job.

But... what does it actually mean that I am not including /proc / and /sys in the backup? Will these directories be created automatically if I make a restore and boot the OS or do I have to take any extra steps?

homey 09-15-2007 12:13 PM

It will actually create the folder, just not the stuff inside it.
From the command: man rsync
Code:

...
it  includes  an empty  directory  at each mount-point it encounters
 (using the attributes of the mounted directory because  those  of
 the underlying mount-point directory are inaccessible)...

The system folders /proc and /sys are dynamically populated at bootup on the original or the restored system.

Glad it works for you! Hopefully, you will also test the restore part.
I would do that to another hard drive and make sure it boots and runs ok for you.


All times are GMT -5. The time now is 11:08 PM.