03-30-2011, 04:21 AM #1Junior Guru Wannabe
- Join Date
- Jan 2011
How to use rsync for transferring files under Linux or UNIX
How do you install and use rsyncto synchronize files and directories from one location (or one server) to another location? - A common question asked by new sys admin.
rsync is a free software computer program for Unix and Linux like systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate. An important feature of rsync not found in most similar programs/protocols is that the mirroring takes place with only one transmission in each direction.
So what is unique about rsync?
It can perform differential uploads and downloads (synchronization) of files across the network, transferring only data that has changed. The rsync remote-update protocol allows rsync to transfer just the differences between two sets of files across the network connection.
How do I install rsync?
Use any one of the following commands to install rsync.
If you are using Debian or Ubuntu Linux, type the following command
# apt-get install rsync
$ sudo apt-get install rsync
# up2date rsync
# yum install rsync
Since rsync does not provide any security while transferring data it is recommended that you use rsync over ssh . This allows a secure remote connection. Now let us see some examples of rsync.
rsync command common options
* --delete : delete files that don't exist on sender (system)
* -v : Verbose (try -vv for more detailed information)
* -e "ssh options" : specify the ssh as remote shell
* -a : archive mode
* -r : recurse into directories
* -z : compress file data
Task : Copy file from a local computer to a remote server
Copy file from /www/backup.tar.gz to a remote server called openbsd.purevm.com
$ rsync -v -e ssh /www/backup.tar.gz [email protected]:~Output:
sent 19099 bytes received 36 bytes 1093.43 bytes/sec
total size is 19014 speedup is 0.99
Please note that symbol ~ indicate the users home directory (/home/purevm).
Task : Copy file from a remote server to a local computer
Copy file /home/purevm/webroot.txt from a remote server openbsd.purevm.in to a local computer /tmp directory:
$ rsync -v -e ssh [email protected]:~/webroot.txt /tmp Password
$ rsync -r -a -v -e "ssh -l purevm" --delete openbsd.purevm.com:/webroot/ /local/webroot
$ rsync -r -a -v -e "ssh -l purevm" --delete /local/webroot openbsd.purevm.com:/webroot
$ rsync -r -a -v --delete rsync://rsync.purevm.com/cvs /home/cvs
You can mirror a directory between my "old" (my.old.server.com) and "new" web server with the command (assuming that ssh keys are set for password less authentication)
$ rsync -zavrR --delete --links --rsh="ssh -l vivek" my.old.server.com:/home/lighttpd /home/lighttpd
Thank you for reading this
Hope it will useful for you
Last edited by PureVM; 03-30-2011 at 04:25 AM.
03-30-2011, 08:26 AM #2
03-30-2011, 12:54 PM #3Web Hosting Master
- Join Date
- Oct 2010
nice tutorial, thanks for the share
03-30-2011, 08:16 PM #4Junior Guru Wannabe
- Join Date
- Mar 2011
useful post , but i think there is a wrong place , it has to be in technical forum tutorial ,www.selectbackup.com
Cheap and stable Backup service
FTP Access/SSH Access/Rsync Technology/Unlimited Bw
By chasebug in forum Hosting Security and TechnologyReplies: 11Last Post: 11-23-2009, 04:07 AM
By chasebug in forum Hosting Security and TechnologyReplies: 9Last Post: 11-11-2009, 05:50 AM
By BonsaiRack in forum Hosting Security and TechnologyReplies: 3Last Post: 03-29-2007, 05:16 AM
By wingtip in forum VPS HostingReplies: 3Last Post: 08-19-2005, 08:08 PM
By EssEss in forum Hosting Security and TechnologyReplies: 1Last Post: 11-01-2002, 01:09 PM