Linux file system replication using Rsync


Steps to use rsync command:

Rsync between server1 and server2 with meadmin as common login user.
Steps to do server1
1. ssh-keygen -t rsa
Generating public/private rsa key pair.
Enter file in which to save the key (/home/meadmin/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /home/meadmin/.ssh/id_rsa.
Your public key has been saved in /home/meadmin/.ssh/
The key fingerprint is:
79:82:88:be:48:13:dc:73:b8:bd:d6:1f:7c:c5:54:e0 [email protected]

2.  scp ~/.ssh/ [email protected]:~/.ssh/authorized_keys2 (Public key needs to be copied)
[email protected]’s password:                                                                                                                 100%  419     0.4KB/s   00:00

3.  ssh server2 (Should log you in without asking for password)
Last login: Mon Feb 15 23:34:03 2010 from

4.  To resync
To do it Silently

rsync -az [email protected]:/opt/attachments/replic/     /opt/attachments/replic

To See Verbose output.
rsync -avz  –progress –stats [email protected]:/opt/attachments/replic/ /opt/attachments/replic

-avz –
a for archive mode (preserve all the attributes of each file and directory – ownership, permissions, etc).
v for verbose mode (report a list of files processed by rsync) and z for data compression to speed transfers up.

5. CronJob to set for 5minutes replication
i. crontab -e
ii. */5 * * * * rsync -az [email protected]:/opt/attachments/replic/     /opt/attachments/replic
iii. crontab -l
rsync -az [email protected]:/opt/attachments/replic/     /opt/attachments/replic

In case of any ©Copyright or missing credits issue please check CopyRights page for faster resolutions.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.