Linux - GeneralThis Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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?
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!
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).
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.
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?
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...
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:
...
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.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.