How to transfer files using rsync by Tanseer

How to Transfer Files using rsync

Hello I am Tanseer and today I will be sharing with you a simple rsync command which is useful to transfer files from one Linux/Unix machine to another using command line.

What is rsync ?

rsync is a utility for efficiently transferring and synchronizing files across computer systems, by checking the timestamp and size of files. It is commonly found on Unix-like systems and functions as both a file synchronization and file transfer program. The rsync algorithm is a type of delta encoding, and is used for minimizing network usage. Zlib may be used for additional data compression and SSH or stunnel can be used for data security. ( Wikipedia )

Generic syntax:

Local use:

rsync [<i>OPTION</i>...] <i>SRC</i>... [<i>DEST</i>]

Access via remote shell (PULL):

rsync [<i>OPTION</i>...] [<i>USER</i>@]<i>HOST</i>:<i>SRC</i>... [<i>DEST</i>]

via remote shell (PUSH):

rsync [<i>OPTION</i>...] <i>SRC</i>... [<i>USER</i>@]<i>HOST</i>:<i>DEST</i>

Access via rsync daemon (PULL):

rsync [<i>OPTION</i>...] [<i>USER</i>@]<i>HOST</i>::<i>SRC</i>... [<i>DEST</i>]
rsync [<i>OPTION</i>...] rsync://[<i>USER</i>@]<i>HOST</i>[:<i>PORT</i>]/<i>SRC</i>... [<i>DEST</i>]

via rsync daemon (PUSH):

rsync [<i>OPTION</i>...] <i>SRC</i>... [<i>USER</i>@]<i>HOST</i>::<i>DEST</i>
rsync [<i>OPTION</i>...] <i>SRC</i>... rsync://[<i>USER</i>@]<i>HOST</i>[:<i>PORT</i>]/<i>DEST</i>

In simple rsync is used to transfer files from one computer to another (Unix/Linux). Most of the time we need to transfer our website from one server to another then rsync is the tool which make it faster to do file migrations. It can be used in both shared hosting and also in VPS/Dedicated server.

See below example which will transfer all files from one server to another:

rsync -av -r /home/tanseer/public_html root@192.168.0.11:/var/www/html/public_html

In above example I transfer all files and directories from /home/tanseer/public_html to remote server with ip (192.168.0.11) in location /var/ww/html/public_html

Note: Don’t put above IP address, you need to put your server ip address.

I pass -av and -r options, -v means verbose and -a means archive and -r means recursive. You can find more options here

I hope this will help you with server migrations and file transfer 🙂

If you have any issue ask me in comment and also visit our site for more tutorials.

Leave a Reply

Read previous post:
Setup Local Git Server - Tanseer
Setup Local Git Server for Team

Hello, Few days ago I setup Git Local Server for my team and all of our repository are store locally...

Close