HOT CLONE A CENT OS SERVER WITH RSYNC Print

  • 0

Hot Clone is the term used to describe to completely clone a Linux server using r-sync across the network. This is useful in situations which you would like to create a clone with little to no downtime that would be typical of taking the original server offline. You can use this to perhaps move a single server in to a cluster environment or certain situation in which you want to upgrade or reduce drives etc.

THIS GUIDE MAKES A COUPLE ASSUMPTIONS:

First both servers need to have the same disk configuration. Either both servers use hardware raid, software raid, or single disks. They typically need to match.

The new server should have the same major install release as the source server.  So both servers would be CentOS 6.x or both need to be 7.x.

The new server has hard drive partitions in a the same format as the old server and they are either the same size or can accommodate all of the used space on the source system.

Services which are writing data should be stopped at the time of the sync (ie mail, databases etc).

PREPARE THE SYSTEMS:

Install needed software packages on both servers:

yum install -y rsync

On the server you want to copy from perform the following:

Create and edit /root/exclude-files.txt and add the following:

/boot
/dev
/tmp
/sys
/proc
/backup
/etc/fstab
/etc/mtab
/etc/mdadm.conf
/etc/sysconfig/network*

This excludes files which directly pertain to the source system and should not be copied to the new system.

HOT CLONE THE SERVER:

Once you have saved that file you can go ahead and rsync to the server you want to copy to:

rsync -vPa -e 'ssh -o StrictHostKeyChecking=no' --exclude-from=/root/exclude-files.txt / DESTINATIONIP:/

This will rsync over everything from the source system to the new system. The size of the drives and load on the servers will determine how long the copy will take.  Be sure to update DESTINATIONIP with the IP address or hostname of the server you are copying to.

After the rsync has completed you can reboot the freshly copied system to have it load everything that has been copied. If you were going to replace the old system with the new system and wanted the same IP addresses, host name etc to be used,  you would then remove /etc/sysconfig/network* from the exclusion file.

Once the new server is back up from the reboot. Go ahead and login using the old servers login credentials and verify everything is working as expected.


Was this answer helpful?

« Back