Thursday, June 7, 2007

Rsync on Windows

http://brentnorris.net/rsyncntdoc.html

Installing RSYNC on Windows 2003/2000/NT.

With thanks to "Mike McHenry" who wrote the original "Rsync on NT" document.
Modified 07/24/03 by Brent Norris for corrections and updates.
Modified 4/20/06 by Brent Norris to update files in rsync.zip to newest versions

This document assumes that you want to install rsync as a daemon on a Windows NT/2000/2003 server or XP, without installing the entire cygwin suite.

You will need the following files:
From Cygwin:

* cygpopt-0.dll
* cygwin1.dll
* rsync.exe

These are available from http://www.cygwin.com
A zip file containing the three files you need is available here.
(if you have done this before 4/20/06 get the newer rsync.zip as it contains newer rsync and cygwin1.dlls) -BN

From the Windows NT or 2000 Resource Kit.

* instsrv.exe
* srvany.exe
For simplicity I have zipped them up and made them available here. -BN

If you follow the following instructions you will an rsync service on your windows machine.
Please be careful where you place the server as any one who can see it can read from this service.

1. Place rsync where you want to run it from.
(I usually use C:\program files\rsync)
2. Put the two dll's anywhere in the path, usually C:\winnt\system32 or c:\windows\system32.
3. From a shell running in the directory containing instsrv and srvany type:
(Replace C:\DirectoryContaining\ as appropriate)

instsrv Rsync "C:\DirectoryContaining\srvany.exe"

4. You should now have a new service called Rsync and you can verify by looking in Start->Control Panel->Services (you can also open services.msc from a run command on 2000 or newer)
DON'T START IT YET!
5. If you want to run rsync in daemon mode you will need a configuration file. Here is the one I use, call it rsyncd.conf and place it in the same directory as rsync
(C:\Program files\rsync\rsyncd.conf)

use chroot = false
strict modes = false
hosts allow = *
log file = c:/rsyncd.log

[BackupArea]
path = C:/rsync/
read only = yes

(The command line to connect would look somthing like "rsync -avz server::BackupArea", where server is the name of the server running the rsync daemon.)
The first two lines are important for rsync to work on Windows.
6. You are going to need to hack some keys in the registry to make it work. Don't do this unless you are comfortable with the changes! Run regedit32 and add the following keys and values (quotation marks ARE IMPORTANT):

HKEY_LOCAL_MACHINE->SYSTEM->CurrentControlSet->Services->Rsync
Edit->Add Key-> Key Name: Parameters
Edit->Add Value-> Value Name: AppDirectory Value: "C:\Program Files\rsync"
Edit->Add Value-> Value Name: Application Value: "C:\Program Files\rsync\rsync.exe"
Edit->Add Value-> Value Name: AppParameters Value: --config="C:\Program Files\rsync\rsyncd.conf" --daemon --no-detach

If you would like to add these keys automatically, there is a .reg file in the rsync.zip file hosted at the top. Just double click on rsync-param.reg

Remember, unless you trust me implicitly, read the reg file and make sure you understand what it's doing before you run it, I will not be held responsible for idiots.
7.

You will probably have to open up the services control panel and double click on the Rsync service. Open the Log On tab and either change it to logon using the Local System account or edit the account information to a valid login account.
8. That's it, you should be able to start and stop the rsync service at will using the Services Control Panel. When running with the above configuration you should be able to test by attempting to telnet to port 873 from a remote machine. telnet rsync.server.com 873 (replacing rsync.server.com with your own server's address) You should get a connection to the rsync daemon running on your server.


I would love to hear from anyone who has any success with these instructions. Let me know if there is anything I missed in correcting this or editing it to host the files off of my site. -BN

No comments: