Votes: 0Posted On: Sep 23, 2015 01:52:19
Rsync (Remote Sync) is commonly used for copying and synchronizing files and directories remotely as well as locally in Linux/Unix systems
Rsync can be use to pull and send data over local and remote networks. Rsync is not secure unlike SCP the risk of traffic being spoof is high, you should always make sure that both local and remote locations
are secure prior to using this command.
0. login to the machine where you will be operating this command
1. Check if rsycn is installed
2. Installing Rsync
RPM base OS# yum -y install rsync
Debian / Ubuntu family# apt-get install rsync -y
NOTE: Before sending data across machines, make sure that the local firewall on both servers have the incoming IP address whitelisted to avoid being block by the firewall.
Rsync has many flags which can be use to send files over the network, well demonstrate a series of live examples our engineers use to send large files when performing customer migrations.
NOTE: We recommend to use the screen command to start a screen session when migrating large amounts of data across networks otherwise a disconnect can suddenly killed your migration.
example1: Sending the entire content of a directory using 10Mbps transfer rate. Replace the X with the destination IP address.
rsync -apW --progress --bwlimit=10000 /file/* email@example.com:/home/file
example2: Sending files and showing a progress bar of the amount of data being transfer and elapse time
rsync -pavW --progress /home/file/* firstname.lastname@example.org.:/home/file
slow network connections
rsync -pavz --progress /home/file/* email@example.com.:/home/file
Flags of interest:
-v: verbose is optional to show logs in case errors occur when transferring data
-a: archive the files for data transfer to increase transfer speed
-W: This rule is consider the whole option, its use to speed up the transfer speed by keeping the whole files intact instead. This is perfect when both sides don’t have limits
-z: this option is use to compress data for slow connections
-p: to retain permissions, this is use if both end will have the same ownership and permissions
--progress: shows the progress of the download
example3: Sending files to remote machines who ssh port are not port 22
rsync -pavW --progress --inplace --rsh='ssh -p 2244' file/* firstname.lastname@example.org:/file
NOTE: when sending files using this syntax rsync -pavW --progress /home/file/* email@example.com.:/home/file/* you are telling rsnc to create another file folder within the remote server ending with a /file/file. Never end the destination path with a wildcard only as the source path.
NOTE: You do not need to pre-create the destination path prior to migrating the data, you can simply do rsync -pavW --progress /home/file/* firstname.lastname@example.org.:/home/file ; if the file doesn't exist it will create it and move the data to the new directory.