Rsync over SSH

Contributor Icon Contributed by abanks Date Icon January 30, 2004  
Tag Icon Tagged: UNIX software

How to use rsync to copy files over an SSH encrypted connection.


Rsync is a utility that will copy files from one machine to another. In addition, rsync will determine if it needs to copy the entire file, or just changes, making rsync very fast on subsequent transfers.

This recipe was assembled from using Cygwin’s rsync package on a Microsoft Windows XP machine. Your syntax may be slightly different on other platforms.

The command:
rsync -avz -e ssh user@remote:/desired/path
will copy the “” directory and its contents to the remote machine, in the specified path.

Slightly modified, the command:
ssh user@firsthost rsync -avz -e ssh user@secondhost:/desired/path
will establish an ssh connection to “firsthost”, then launch rsync over SSH to “secondhost”, copying “” to the desired path.

When combined with SSH public key authentication, it is possible to automate (cron) backups over the SSH secure connection without a password.

NOTE: The parameters mean:

    a = archive
    v = verbose
    z = compress file data
    e = specifies remote shell to use
Previous recipe | Next recipe |
 
blog comments powered by Disqus