Rsync for Windows – what a great tool. CWRSync – The package that is rsync for Windows (bundled with Cygwin, OpenSSH, OpenSSL, Rsync). Pretty easy to install (latest version here).
Can be a PITA to set up correctly. I am trying to rsync from Windows Server 2003 to my Centos VPS via SSH, which after a few hours of head bashing finally works. The command line help could be a little bit more infomative!

There is a batch file template included, and the forums can be found on the download site linked to above, and of course Google. The gist of getting this to work is along the lines of:

SET HOME=%HOMEDRIVE%%HOMEPATH%

(Sets environment variable)

 cd "c:\program files\cwrsync\bin"
 ssh-keygen -t rsa -N ''

(just go with the defaults, or change the file location)

Copy the SSH keys to your server:

C:\Program Files\cwRsync\bin>rsync -avz -e "./ssh -p xxxxx" "./id_rsa.pub" user@hostname.com:.ssh/authorized_keys

xxxxx=port SSH is listening on if changed away from default

Restart SSH on the server and it should pick up the new keys

To then sync stuff, try the following syntax which worked for me:

C:\Program Files\cwRsync\bin>rsync -av --chmod u+rwx -e "./ssh -i id_rsa -p xxxxx" user@hostname.com:/var/www/ "/cygdrive/d/backup/www"

xxxxx=port SSH is listening on if changed away from default

Change the paths as requred and you should be good to go. This works quite nicely, especially when scheduled as a scheduled task.

You must be logged in to leave a reply.