pskl.us

Magic of RSYNC…

by on Sep.28, 2011, under Uncategorized

I routinely back up my RHEL boxes with RSYNC over SSH…   It’s just something I do.   Yeah, I know, I’m using “X” commercial backup application and it works well, yadda, yadda, yadda.   However, I still make at least weekly backups with RSYNC to a NAS.  It is a habit of mine, like hookers and blow.

Question came up, “how do you do a bare metal restore from that backup?” which tags along with the question “how do you do a bare metal copy from old server to brand new server?”

If the hardware isn’t too odd (usually hardware RAID controllers you have drivers in your initrd is the limiting factor here, but you can work around that too with some Linux foo skillz…), or it’s a bare metal restore to same hardware, yes, you can use RSYNC.

for my examples: “sourceserver” is the other running server that you want to bare metal copy to the destination.
“target” is the destination server.
First: boot the destination server with a rescue disk.   I use RHEL rescue CD.
Create your partitions to taste, and reboot again with the RHEL rescue CD.

Second: Mount partitions in the order you want them.  example: (I just picked an example partition table, seriously, match what you really need…)
mount /dev/sda2 /mnt/sysimage
mkdir /mnt/sysimage/boot
mount /dev/sda1 /mnt/sysimage/boot
mkdir /mnt/sysimage/home
mount /dev/sda5 /mnt/sysimage/home
mkdir /mnt/sysimage/var
mount /dev/sda6 /mnt/sysimage/var

this mounts all of the “target” under /mnt/sysimage on the rescue cd.
Third: I have this script I run:  (which you can make on the rescue disk, once again, a little bit of foo goes a long way…)

#!/bin/sh
rsync –verbose  –stats –owner –group –devices \
–recursive –times –perms –links \
–rsh=/usr/bin/ssh \
–delete \
–include=/opt/nfs \
–exclude=/proc \
–exclude=/sys \
root@”sourceserver”:/ /mnt/sysimage
#

enter your SSH password  (yes, you should allow root logon through SSH for this one, if you don’t know how to enable that, look it up on google, it’s braindead easy…)

Fourth: reset the permissions on the “/” share and make sure they are right:
chmod 755 /
Fifth: Finally, fix grub.  (this example is from my VMware ESX servers…)

From the linux rescue:

Issue the grub command:
grub

then type in these commands:  (depending on your hard drive layout and 0 = zero for those easily confused…)
device (hd0) /dev/sdm  (this server was /dev/sdm instead of something normal like /dev/sda…   salt to taste, or add butter like Paula Dean…)
root (hd0,0)
setup (hd0)
quit

then reboot and test, test again, enjoy!


Leave a Reply

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!