HostOnNet Blog

Copying files with rsync

Looking for Linux Server Admin or WordPress Expert? We can help.

rsync is very good command to copy files between two linux servers.

To move a folder from server1 to server2, login to server1 with ssh

Rrun

rsync -a -v --progress --timeout=0 -e "ssh -p 22" /path/to/source/folder/ user@server2-ip:/path/to/destination/folder/ 

Here ssh -p 22 is the default SSH port, if you use non standard ssh port, replace 22 with your ssh port number.

For example, if you want to copy (sync) folder /home/hoston/public_html/ on server 1 to server2, run

rsync -a -v --progress --timeout=0 -e "ssh -p 22" /home/hoston/public_html/ user@server2-ip:/home/hoston/public_html/ 

You need to run the command on the server where your files are in (source server).

rsync is not just copy, it do sync two folders, can be used for backup, so only changed files need to be transferred to remote server when you run rsync.

rsync can also used to mirror your web site to another web sever for load balancing.

Posted in Linux

Leave a Reply

Your email address will not be published. Required fields are marked *

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