Tero Karvinen - Articles - Downloads - Courses - Contact

Table of Contents

Rsync from Windows

Rsync can synchronize files over network. Because only changed parts are transferred, rsync is very fast.

In Linux it’s easier, so you could just install Ubuntu. However, this article explains how to do this on Windows.

To follow this article, you need an ssh account (suitable for rsync) on a server. You also need to have Windows installed.

We first install Cygwin Linux compatibility layer, and remember to include openssh and rsync. Then we open rsync on command line and run it.

Install Cygwin with Rsync

Download and run http://www.cygwin.com/setup.exe.

In the installer, pay attention to “Select packages” screen. You have to manually select openssh and rsync. Use the search field to find them, then change the text “Skip” to chosen version number by clicking it.

Run Cygwin

Open Cygwin Bash Shell from Start Menu: Cygwin: Cygwin Bash Shell.

Run a command to test it, such as ‘pwd’. It should print your path, such as “/home/bar”.

Run ‘rsync’. As we did not tell it to do anything, it should just print help message and exit. If you get a help message, you are ready to start using it.

If you get an error message “bash: rsync: command not found”, go back to installation of cygwin, and remember to select rsync and openssh to be installed.

Synchronize

To synchronize, you of course need an ssh account on a server. Installing a server is out of the scope of this article. We’ll assume your server administrator gave you this account information

login: tero
password: samplePass492!
server: example.com
directory to be synchronized: /home/tero/foo/

So we simply run

$ rsync -vvazh --progress tero@example.com:/home/tero/foo .

As always, the dollar sign “$” is the prompt and you only type the command from “rsync...” on.

Because this is the first run, ssh asks you to accept server fingerprint - just say “yes”. The you can type your password, and the synchronization runs.

Meaning of each part of the command

$ rsync -vvazh --progress tero@example.com:/home/tero/foo .
Part Explanation
rsync The command, i.e. the program we run
 -v  Verbose, print more information. We specify it twice to get even more verbose.
-a Archive, get the whole directory as it is
 -z Compress to make it faster 
-h Human readable, say 1 GB instead of 1 000 000 000 B
--progress Show progress bar for each file
 tero@example.com  SSH account user name and server. You could also ‘ssh tero@example.com’ with this account 
/home/tero/foo  Directory path on remote server. Trailing slash is omitted on purpose to get directory foo and not just it’s contents
. This directory, where we are in local computer. This is the working directory, the same that ‘pwd’ prints. This is where we copy everything.

The first run will be very long, just like with any other file transfer program. The second run will be much faster, as only modified parts will be transferred.

After rsync has run, you can see your files with ‘ls’. The next updates will be very fast.

Well done, you have now configured the uncrowned king of synchronization programs.

Last modified: 2010-06-11. Permanent url: http://www.iki.fi/karvinen/rsync_from_windows.html

Tero Karvinen www.iki.fi/karvinen - Top - Validate HTML - Validate CSS