Windows下也有相似unix下的rsync软件,最近我试用了cwRsync软件,把配置和使用方法介绍一下,使用它确实比较方便!
同步Rsync Server软件下载
cwRsync_Server_2.0.10_Installer.zip
同步Rsync Client软件下载
cwRsync_Client_2.0.10_Installer.zip
在须要传同步文件出来的windows服务器上安装同步Rsync Server软件cwRsync_Server_2.0.10_Installer后,
会在服务器上建一个管理员级别的SvcwRsync用户,咱们最好修改一下这个用户的密码。
在此服务器上还增长了一个RsyncServer服务,若是没有设成自动启动,须要设置一下,以下图。

而后在安装了同步Rsync Server和Rsync Client软件的windows服务器上设置环境变量:

把目录C:\Program Files\cwRsyncServer\bin填加到当前用户的path里。
同步Rsync Server上配置文件rsyncd.conf的通常格式相似:
###############################################################
use chroot = false
strict modes = false
#hosts allow = 192.168.0.2
hosts allow = *
log file = rsyncd.log
pid file = rsyncd.pid
secrets file = password
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[dbbackup]
path = /cygdrive/d/sqlserver_backup
read only = true
list = no
auth users = fengyu
transfer logging = yes
[test]
path = /cygdrive/d/ying
read only = true
list = no
auth users = ying
transfer logging = yes
###############################################################
在Rsync Server的C:\Program Files\cwRsyncServer\目录下密码文件password里面内容以下:
fengyu:dbbackup_test
ying:maggie678
这里面的用户名和密码能够任意设定,跟windwos和unix账号没有任何关系。记住用冒号:分割用户名和密码 在Rsync Client端写一个包含rsync命令的批处理程序rsync_test.bat rsync -vzrtopg --progress --delete --password-file=/cygdrive/f/fengyu/password2 fengyu@192.168.0.10::dbbackup /cygdrive/f/fengyu/dbbackup_test 请注意在Rsync Client端windows服务器f:\fengyu\password2文件里只须要填写密码dbbackup_test,以下: dbbackup_test 固然在unix机器上也能够用相似的方法获取在Windows服务器Rsync Server配置文件里设置好的同步文件夹 rsync -vzrtopg --progress --delete --password-file=/home/ying/ying_passwd ying@192.168.0.10::test /home/ying/ying_test 密码/home/ying/ying_passwd文件里也只须要填maggie678,以下: maggie678 若是想把同步操做定时完成,能够在Windows服务器上设定任务计划,在unix机器上配置cron做业。 最后管理员按期查看Rsync Server上的同步日志文件C:\Program Files\cwRsyncServer\rsyncd.log 就知道同步是否正常运行了。