Clone a CentOS Server by Rsync

First set the source & destination server & Both servers need to be running on the same release of the operating system centos 7 or 8.

Before cloning, ensure you disable all the services that involve shipping or writing data e.g databases, mail service, etc.

For cloning successfully the rsync command-line tool needs to be present on both servers. It will mirror the source server to the destination server and sync all between the two systems. On all modern systems rsync already pre-installed.

If rsync is missing, run the following command to install it in CentOS systems.

$ sudo yum install rsync

To check the version of rsync installed run:

$ rsync --version

If you want to view additional information about rsync, execute the following rpm-command :

$ rpm -qi rsync

Now Configure the Source Server

Some directories and files are already available in the destination server or autogenerated. These include the /boot/tmp and /dev directories.

Therefore, create an exclusion file /root/exclude-files.txt and add the following entries:

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

Save and exit the configuration file.

Now Clone the CentOS Server

After everything set, proceed rsync to the remote or destination server using the command:

$ sudo rsync -vPa -e 'ssh -o StrictHostKeyChecking=no' --exclude-from=/root/exclude-files.txt / REMOTE-IP:/

The command rsync will sync everything from the source server to the destination server with your defined excluding files and directories. Replace the REMOTE-IP: option with your destination server’s IP address.

After the synching is done, reboot the destination system to reload the changes and thereafter, boot into the server using the source server’s credentials. Now you have a mirror copy of your source server.

Thank you for reading this article.

Was this helpful?

6 / 2

Leave a Reply 3

Your email address will not be published. Required fields are marked *


zortilonrel

zortilonrel

I’m still learning from you, but I’m making my way to the top as well. I definitely enjoy reading everything that is written on your site.Keep the aarticles coming. I loved it!

David

David

Impossible to login on destination server.
Seems the credentials are no more working. Even if with source cred.

stigeautodetam

stigeautodetam

I really enjoy the article.Much thanks again. Much obliged.