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服務,若是沒有設成自動啓動,須要設置一下,以下圖。
![](http://static.javashuo.com/static/loading.gif)
而後在安裝了同步Rsync Server和Rsync Client軟件的windows服務器上設置環境變量:
![](http://static.javashuo.com/static/loading.gif)
把目錄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 就知道同步是否正常運行了。