windows做為檔案伺服器,使用rsync的windows服務版本:cwRsyncServer 下載地址:http://rsync.samba.org
安裝過程要設定用於系統服務的帳號和密碼,可以預設。
註:此帳號用於啟用crsync server服務,需要分配給帳號對要同步檔案的相應許可權,否則無法操作被同步的檔案。
安裝完成後修改設定檔 rsyncd.conf, 設定檔內容如下:
port = 52326
use chroot = false
strict modes = false
#hosts allow = * #允許所有的訪問
hosts allow = 192.168.10.2 #指定特定的IP允許訪問
log file = rsyncd.log
lock file = rsyncd.lock
max connections = 10
UID = 0
GID = 0
# Module definitions
# Remember cygwin naming conventions : c:work becomes /cygwin/c/work
#
[test]
path = /cygdrive/c/work
read only = false
transfer logging = no
[test2]
path = /cygdrive/d/wwwroot/yanghengfei_com
read only = yes
transfer logging = no
auth users = coldstar #同步使用的帳號
secrets file = rsyncd.secrets #密碼檔案
註:
rsyncd.secrets設定檔的格式為 使用者名稱:密碼,如:
coldstar:123456
即添加了一個使用者 coldstar,密碼為 123456。
現在來看個執行個體
兩台伺服器都是windows2003 Enterprise Edition R2,都放在美國,一台在美國AK機房,另一台在佛羅里達州,兩台網路的相互ping值大概在60-70毫秒
同步140G的檔案,虛擬機器主機的目錄,檔案不是一般的多… 讓rsync停在receiving file list … 停了好久 起碼20分鐘 -_-!
第一次不會快到什麼程度,但是以後的增量或差異效果就很明顯了!
Rsync for windows : Server端
Rsync for windows : Client端
下載Server端安裝
開始 -> 所有程式 -> cwRsync Server -> 05. Start a Unix BASH Shell
輸入: /bin/activate-user.sh
按l 選擇本機使用者 (本機使用者名過多會報錯?我這邊200個左右的使用者,但是提示“命令運行完畢,但發生一個或多個錯誤”)
Enter a user account for activation: 輸入本地一個賬戶名
建立key後面也可以加的
exit退出
用ssh協議傳輸檔案,需要啟動opensshd服務,在services.msc裡啟動
編輯rsyncd.conf
開始 -> 所有程式 -> cwRsync Server -> 01. rsyncd.conf
use chroot = false
strict modes = false #strict 模式是不是效驗檔案? (未測試)
hosts allow = * #允許哪個IP
log file = rsyncd.log
pid file = rsyncd.pid
[test]
path = /cygdrive/f/backup #路徑
read only = false #是否唯讀,不是為yes
transfer logging = yes #是否記錄日誌? (沒去看)
開始 -> 運行 -> services.msc -> 啟動rsync server的服務
用戶端:
C:Program FilescwRsyncbin>rsync.exe -zvrtopg 管理員帳號@IP地址:/cygdr
ive/f盤/backup /cygdrive/f盤/backup
同步遠端伺服器的f盤的backup檔案夾到本地的f盤的backup檔案夾裡