在Windows中配置Rsync同步文件的方法

Windows下cwRsyncServer雙機連續同步部署

下載cwRsyncServer服務器端與客戶端的安裝文件:

服務端下載:cwRsyncServer_4.0.5_Installer.zip
客戶端下載:cwRsync_4.0.5_Installer.zip
 
服務端的配置(192.168.0.21):
安裝服務端軟件cwRsyncServer_4.0.5,安裝時須要輸一個用戶名和密碼,輸入本機administrator的用戶名密碼便可。
rsync1
安裝完成後,在系統服務中,啓動RsyncServer服務,並設置爲開機自啓動
rsync2
測試RsyncServer是否運行正常,查看是否有873端口是監聽狀態
rsync3
進入到RsyncServer的安裝目錄,默認應該是C:\Program Files\ICW 編輯rsyncd.conf配置文件(用寫字板或者記事本打開便可),刪除裏面的全部配置,並添加下面的代碼,再修改path路徑便可(/cygdrive/C/heminjie表明C:\heminjie目錄)服務器

use chroot = false
strict modes = false
read only = yes
list = no
hosts allow = *
max connections = 10
lock file = rsyncd.lock
motd file = rsyncd.motd
log file = rsyncd.log
transfer logging = yes
uid = 0
gid = 0
auth users= rsyncuser
secrets file = rsyncd.secrets
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
path = /cygdrive/C/heminjie
read only = false
transfer logging = yes
ignore errors

再在安裝目錄下建立rsyncd.secrets密碼文件,裏面內容爲 用戶名:密碼測試

rsyncuser:rsyncuser

修改rsyncd.secrets權限爲600
rsync4
客戶端的配置(192.168.0.22):
安裝客戶端軟件cwRsync_4.0.5
rsync5
客戶端默認的安裝路徑爲C:\Program Files\cwRsync 在C盤根目錄下建立密碼文本password.txt,內容爲rsyncuser用戶的密碼rsyncuserui

rsyncuser

執行同步命令,輸入密碼rsyncuser,同步服務器上c:\heminjie到d:\heminjie
rsync6
批處理腳步運行(可設置計劃任務),建立.bat文件,裏面內容以下server

@echo off "C:\Program Files\cwRsync\bin\rsync.exe" -vzrtopg --progress rsyncuser@192.168.0.21::test "/cygdrive/D/heminjie" < c:\password.txt

常見錯誤:
@ERROR: auth failed on module test
rsync error: error starting client-server protocol (pre 5) at main.c(1506) [Receiver=3.0.7].
緣由:
驗證用戶名密碼錯誤 確認服務端用戶驗證文件rsyncd.secrets裏面的用戶名密碼與客戶端密碼文件rsyncd.secrets裏面的密碼同樣
 
password file must not be other-accessible
continuing without password file
緣由:
yrsyncd.secret未被設置爲rsyncuser可寫其餘不能讀(600)ip

相關文章
相關標籤/搜索