伺服器端:
http://rsync.samba.org/ 伺服器端(cwRsyncServer)。
安裝目錄: E:\cwRsyncServer
連接埠: 52326
ip: 219.152.120.82
一:修改cwRsyncServer設定檔 E:\cwRsyncServer\rsyncd.conf
#########
port = 52326
use chroot = false
strict modes = false
read only = yes
list = no
hosts allow = *
max connections = 10
secrets file = rsyncd.secrets #指定使用者登入的密碼檔案
motd file = rsyncd.motd #串連上rsync server時顯示的歡迎資訊
log file = rsyncd.log
pid file = rsyncd.pid
transfer logging = yes
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
#
[test]
path = /cygdrive/c/work
read only = false
transfer logging = yes
[t_task]
path = /cygdrive/c/work
read only = false
transfer logging = yes
#################################
二:在E:\cwRsyncServer目錄下建立密碼檔案 rsyncd.secrets 內容為使用者名稱:密碼
如: tly:fjs249slke
用戶端:
http://rsync.samba.org/ 下載cwRsync用戶端(cwRsync)
安裝目錄: E:\cwRsync
三:在E:\cwRsyncServer目錄下建立密碼檔案 rsyncd.secrets 內容為密碼
如:fjs249slke
四:開始–>運行–>cmd 輸入以下命令即可同步伺服器端t_task模組到用戶端e:/y目錄下。
E:\cwRsync\bin\rsync.exe -vazu –exclude article/ –progress –delete –
password-file=E:\cwRsync\rsyncd.secrets
rsync://odinxu@219.152.120.82:52326/t_task /cygdrive/e/y
照做可同步服務了,如果不行,1.檢查伺服器是否有開服務連接埠,命令列輸入( netstat -a ) 可查看伺服器開的連接埠。就是上面的52326連接埠。2.用戶端命令列輸入( telnet 服務端ip 服務連接埠 ) 能否串連伺服器端。3.檢查設定檔是否跟上面一樣。
註:以上為匿名串連入伺服器端,一般會在模組裡添加 auth user= odinxu 指定使用者,一定要注意,指定的使用者必須要登陸才能進行同步服務。 我在這裡掐了很久,模組裡指定了使用者,使用者又沒有登陸,導致出錯。
新手常出現的錯誤:
錯誤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) [rec
eiver=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) [rec
eiver=3.0.2]
解決:設定檔 rsync.conf中添加 lock file = rsyncd.lock 即可解決。
更具體的實現方法可以參考:http://www.jb51.net/article/19663.htm