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:


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?

2 / 0

Leave a Reply 0

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