How to transfer files over servers flawlessly.

If you followed the previous tutorial, you’d know how to transfer files over servers without passwords.

So to transfer a file from server to server issue the following command (USING SCP).

scp /path/to/my.file me@otherserver(link sends e-mail):/path/to/destination/my.file

Now the same using Rsync:

# apt-get install rsync


# apt-get install rsync


  • –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

Now copy to remote server:

Copy file from /www/backup.tar.gz to a remote server called

$ rsync -v -e ssh /www/backup.tar.gz sends e-mail):~


sent 19099 bytes  received 36 bytes  1093.43 bytes/sec
total size is 19014  speedup is 0.99

Copy file /home/user/webroot.txt from a remote server to a local computer’s /tmp directory:

rsync -v -e ssh (link sends e-mail):~/webroot.txt /tmp

Synchronize a local directory with a remote directory

rsync -r -a -v -e "ssh -l user" --delete /local/webroot

Synchronize a remote directory with a local directory

rsync -r -a -v -e "ssh -l user" --delete /local/webroot

Synchronize a local directory with a remote rsync server or vise-versa

rsync -r -a -v --delete rsync:// /home/cvs

Mirror a directory between my “old” and “new” web server/ftp

rsync -zavrR --delete --links --rsh="ssh -l user" /home/lighttpd

That pretty much summarizes everything you’ll need to do with files locally and remotely.


Sr. Software Engineer with over 10 years of experience. Hobbist photographer and mechanic. Tinkering soul in an endeavor to better understand this world. Love traveling, drinking coffee, and investments.

You may also like

Leave a Reply

Recent Comments

    %d bloggers like this: