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/ 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? |
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! |
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 |
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 |
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/ |
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 |
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? |
It will actually create the folder, just not the stuff inside it.
From the command: man rsync Code:
... 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. |