Search tutorial by keyword

How to install RSYNC and sync two folders

 

RSYNC is an application used in Linux to sync two folders with bundle of options. Two folders can be present on two different servers. The best thing about it is that it is incremental sync so it will sync from time to time if its scheduled and will only sync the files added and will not sync the files which are already present before. There is another option available that comes into use a lot is the delete function in which all the files are deleted the next time rsync is called. Let’s see the installation and various functions used in rsync

To install rsync use the following command

#yum install rsync

While doing local sync you can use the following command 

#rsync –azvv /home/micheal /data /home/ahmed/data2

This command will sync all the files present in “data” to “data2” while the parameters which are used are explained as follows

a: It syncs the data with the same permissions in the parent folder

z: it compresses the data and then sync and decompresses the data on the destination folder

vv: It increases verbosity which helps you troubleshoot if any errors occur

If we want to sync two folders on different servers we will use the following command

We are taking 192.168.21.2 as the IP of second server

#rsync –azvv /home/micheal/data This email address is being protected from spambots. You need JavaScript enabled to view it..2:/home/ahmed/data2

This will sync two folders which are present on two different servers. Now we will see if someone wants to delete the data on the destination folder which is not present on the parent folder. 

#rsync –azvv –delete /home/micheal/data This email address is being protected from spambots. You need JavaScript enabled to view it..2:/home/ahmed/data2

 

Michael Dudli

Cloud Specialist with more than 10 years experience in the Hosting Business.

Website: www.cloudserver24.com

Contact

Sales

sales@cloudserver24.com

Support

support@cloudserver24.com