Windows Server 2012 兩台服務器文件同步


下載cwRsyncServer軟件安裝(這是Windows下的文件同步軟件)

一、(1)在文件客戶端服務器安裝該軟件,找到安裝位置下的rsyncd.conf,修改配置文件(注意在Windows下輸入位置時格式是:/cygdrive/c/ztb表示C盤下的ztb目錄)

use chroot = false strict modes = false hosts allow =* log file = rsyncd.log pid file = rsyncd.pid port = 873 uid = 0 gid = 0 max connections = 10

lock file = rsyncd.lock [backup] path = /cygdrive/c/ztb/ transfer logging = yes ignore errors list = no secrets file =/cygdrive/c/Rsync/rsyncd.secrets hosts allow = 192.168.0.2/255.255.255.0 hosts deny = *

(2)建立rsyncd.secrets

直接輸入: 

123456

 

二、在備份文件的服務器(數據庫服務器)安裝該軟件,新建密碼文件rsyncd.secrets,輸入格式為:

Administrator:123456

三、在備份文件服務器手動同步測試(建議先手動測試,如果出錯可以直接看出來)

在命令行界面(cmd)進入軟件安裝目錄C:\Program Files (x86)\ICW\bin;輸入命令

rsync.exe -avzPu--progress --delete rsync://192.168.0.2:873/backup /cygdrive/c/Appbackup--password-file=/cygdrive/c/Rsync/rsyncd.secrets

四、自動同步測試

備份文件服務器(數據庫服務器)新建文件同步腳本rsync.cmd,內容如下:

@echo off set rsynclog="C:\Rsync\rsync.log"

set nowtime=te:~0,10% %time% echo %nowtime% >> %rsynclog% cd /d C:\Program Files (x86)\ICW\bin rsync.exe -avzPu  --progress  --delete  rsync://192.168.0.2:873/backup/cygdrive/c/Appbackup --password-file=/cygdrive/c/Rsync/rsyncd.secrets

>> %rsynclog% @echo -------------------------------------------------- >>%rsynclog% @echo. >> %rsynclog%

五、加入系統任務計划

點擊任務計划程序,進入右鍵點擊【創建任務】

創建定時任務和數據庫差不多,可以參看另一篇博文

https://www.cnblogs.com/marshu/p/9842697.html

六、遇到問題及解決辦法本步驟參考了https://www.cnblogs.com/janas/p/3321087.html

 

錯誤1: rsync: read error: Connection reset by peer (104) 
rsync error: error in rsync protocol data stream (code 12) at io.c(794) [receive r=3.0.2] 
解決:很大可能是服務器端沒有開啟 rsync 服務。開啟服務。

  

錯誤2:@ERROR: chdir failed 
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2] 
解決:服務器端同步目錄沒有權限,cwrsync默認用戶是Svcwrsync。為同步目錄添加用戶Svcwrsync權限。

 

錯誤3:@ERROR: failed to open lock file 
rsync error: error starting client-server protocol (code 5) at main.c(1495) [receiver=3.0.2] 
解決:配置文件 rsync.conf中添加 lock file = rsyncd.lock 即可解決。

 

錯誤4: rsync: could not open password file "/cygwin/e/Setting/Rsync/rsync_db.pwd": No such file or directory (2)
解決:密碼文件的目錄一定要存在,而且要用POSIX風格的寫法:/cygdrive/e/Setting/Rsync/rsync_db.pwd

 

錯誤5:@ERROR: auth failed on module data_backup rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
解決:密碼錯誤,輸入正確的密碼即可。用戶名和密碼如果都正確,可能是遠程rsync服務器的帳戶密碼文件的權限必須為600。

  

錯誤6: password file must not be other-accessible
解決:這是因為rsyncd.pwd rsyncd.sec的權限不對,應該設置為600。如:chmod 600 rsyncd.pwd, Windows下應將密碼文件的所有者改成程序運行的用戶。

  

錯誤7:@ERROR: invalid uid nobody . rsync error: error starting client-server protocol (code 5) at main.c(1506) [Receiver=3.0.7]
解決:在rsyncd.conf文件中添加下面兩行即可
uid = 0
gid = 0 

 

問題8: @ERROR: chroot failed
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:服務器端的目錄不存在或無權限。創建目錄並修正權限可解決問題。

  

問題9:@ERROR: Unknown module ‘tee_nonexists’
rsync error: error starting client-server protocol (code 5) at main.c(1522) [receiver=3.0.3]
原因:服務器不存在指定模塊。提供正確的模塊名或在服務器端修改成你要的模塊以解決問題。

  

問題10:rsync: failed to connect to 218.107.243.2: No route to host (113)
rsync error: error in socket IO (code 10) at clientserver.c(104) [receiver=2.6.9]
原因:對方沒開機、防火牆阻擋、通過的網絡上有防火牆阻擋,都有可能。關閉防火牆,其實就是把tcp udp的873或者指定的rsync端口打開。

 

問題11:rsync error: error starting client-server protocol (code 5) at main.c(1524) [Receiver=3.0.7]
原因:/etc/rsyncd.conf配置文件內容有錯誤。請正確核對配置文件。

  

問題12:rsync: chown "" failed: Invalid argument (22)
原因:權限無法復制。去掉同步權限的參數即可。(這種情況多見於Linux向Windows的時候)

   

問題13:@ERROR: daemon security issue -- contact admin
rsync error: error starting client-server protocol (code 5) at main.c(1530) [sender=3.0.6]
原因:同步的目錄里面有軟連接文件,需要服務器端的/etc/rsyncd.conf打開use chroot = yes。掠過軟連接文件。

  

問題14:rsync: read error: Connection reset by peer (104)
rsync error: error in rsync protocol data stream (code 12) at io.c(794) [receiver=3.0.2]
解決:很大可能是服務器端沒有開啟 rsync 服務,開啟服務。

  

                                                                                         有夢可以跑回去,那自然是幸運!


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM