Setup Rsync in 5 Minutes – Centos 6

Scenario: I wanted to transfer a /data folder from one server to another on Centos 6.  Source is 10.0.43.2. Destination is 10.0.43.1

 

First of all we need to check rsync and xinetd are installed and working on the DESTINATION (receiving) server. To find out if the packages are installed type this:

yum list installed

Note: In the following screenshot I have grep'ed for 2 packages rather than reading the full list. Both show as installed:

If they aren't installed then you'll need to install them (eg yum install xinetd and yum install rsync)

Next we will need to enable the rsync server

vi /etc/xinetd.d/rsync

When inside the file ensure that the following flag is set

disable = no

Then restart xinetd to make sure the change is applied

/etc/rc.d//init.d/xinetd start 

 

The next step involves editing (or creating the rsyncd.conf)

vi /etc/rsyncd.conf

I have edited my file like so:

 

That's all we need to do on the destination host

On the SOURCE host we will just need to ensure rsync is installed.

yum list installed | grep rsync

If its not then just use (yum install rsync)

Now lets run the command to get the /data directory synced to the new server

Still on the SOURCE host:

rsync -avpro –delete /data 10.0.43.1::datadir

Flags:

a = archive

v = verbose

p = perms (preserve permissions

r = recursive

o = owner (preserver owner)