This guide covers setting up rsync on Windows using CwRsync for both server and client. Since the official site no longer provides free server downloads, a bundled archive containing server and client binaries is available.
1. Download and Installation
Get the archive from: http://files.cnblogs.com/files/assassin1994/cwRsync_4.0.5_server%E5%92%8Cclient.zip
Server Installation
Run the installer and proceed with default options. During installation, you must set a service account. The wizard offers a default system account SvcCWRSYNC with a random password. You can use an existing Windows account instead.
On Windows Server 2008 R2, the automatic account creation may fail. Workaround: during installation, specify an existing administrator account (e.g., administrator) and provide the correct password.
Client Installation
Run the client installer and click "Next" until finished.
2. Server Configuration
Navigate to the server installation directory (e.g., C:\Program Files\cwRsyncServer). Edit the file rsyncd.conf with the following content:
uid = 0
gid = 0
use chroot = false
strict modes = false
hosts allow = 192.168.1.150
log file = rsyncd.log
port = 873
[dataone]
path = /cygdrive/E/wwwfiles/File
read only = true
auth users = user1
secrets file = /etc/rsyncd.pw
transfer logging = yes
Important: Comments and configuraton directives must be on separate lines. Avoid inline comments like hosts allow = 192.168.1.150 # some comment, as they break parsing.
Path Mapping: path = /cygdrive/E/wwwfiles/File corresponds to Windows path E:\wwwfiles\File.
Step A: Set Directory Permissions
Grant the service account (set during installation) read/write permissions on the shared directory E:\wwwfiles\File.
Step B: Create Password File
In the server's etc subfolder (e.g., C:\Program Files\cwRsyncServer\etc), create a file rsyncd.pw with the content:
user1:pass1
Step C: Start the Service
Open services.msc, locate RsyncServer, set Start type to Automatic, and start the service.
3. Client Configuration
Step A: Password File
Create a directory etc inside the client installation folder (e.g., C:\cwrsync\etc). Inside it, create a file pass.txt containing only the password from the server (no username). Then set appropriate permissions for the Windows user that will run the sync.
Step B: Sync Command
Open a command prompt and run:
C:\cwrsync\bin\rsync.exe -avzP --progress --delete --port=873 --password-file=/cygdrive/c/cwrsync/etc/pass.txt user1@192.168.1.1::dataone /cygdrive/c/test
Explanation:
/cygdrive/c/cwrsync/etc/pass.txt– path to the password file (Cygwin style)user1@192.168.1.1::dataone– server authentication and module name/cygdrive/c/test– local destination directory (corresponds toC:\test)
4. Rsync Parameter Reference
| Parameter | Description |
|---|---|
-a |
Archive mode: equivalent to -rlptgoD |
-r |
Recursive into directories |
-l |
Copy symlinks as symlinks |
-p |
Preserve permissions |
-t |
Preserve modification times |
-g |
Preserve group |
-o |
Preserve owner |
-D |
Preserve device files (special) |
-v |
Verbose output |
-z |
Compress data during transfer |
-P |
Show transfer progress and keep partial files |
--progress |
Display detailed progress during sync |
--delete |
Delete files in client that no longer exist on server (maintains exact mirror) |