第一步就是準(zhǔn)備兩臺(tái)電腦: 一臺(tái)作為Server,一臺(tái)作為Client 本次的實(shí)例是:
Server cwRsync:192.168.6.18 Client cwRsync:192.168.6.15
1.服務(wù)端的安裝與配置
a、安裝cwRsyncServer-v4.1.0.zip里的軟件;
b.配置rsyncd.conf配置文件
編輯C:\Program Files\ICWrsyncd.conf,(在安裝該軟件目錄下)內(nèi)容如下:
use chroot = false strict modes = false hosts allow = * secrets file=pw.txt log file = rsyncd.log pid file = rsyncd.pid #port = 52326 #max connections = 4 uid = 0 gid = 0 # Module definitions # Remember cygwin naming conventions : c:\work becomes /cygwin/c/work # [test] path = /cygdrive/d/host ignore errors read only = yes transfer logging = yes list = no #lock file = rsyncd.lock
c.在安裝目錄下創(chuàng)建pw.txt文件,內(nèi)容如下:donfag:12344321
以上分別是用戶名和密碼。其中需要備份的目錄需要給donfag這個(gè)用戶的讀權(quán)限。這里是d:\host.
d.啟動(dòng)rsync服務(wù):
在系統(tǒng)服務(wù)里將RsyncServer服務(wù)設(shè)置為自動(dòng)并啟動(dòng)。
到此server端配置結(jié)束,接下來(lái)配置client端 。
2.客戶端安裝于配置:
a.安裝client端軟件包:cwRsync-v4.1.0.zip;
b.在安裝目錄創(chuàng)建pw.txt內(nèi)容是上面設(shè)置的密碼,這里是:12344321
b.進(jìn)行安裝目錄的bin目錄,運(yùn)行下面命令看是否可以正常同步:
Rsync -vzrtopg --progress --delete --password-file=pw.txt donfag@192.168.6.18::test /cygdrive/d/temp
上面這個(gè)命令行中-vzrtopg里的v是verbose,z是壓縮,r是recursive,topg都是保持文件原有屬性如屬主、時(shí)間 的參數(shù)。--progress是指顯示出詳細(xì)的進(jìn)度情況,--delete是指如果服務(wù)器端刪除了這一文件,那么客戶端也相應(yīng)把文件刪除,保持真正的一致。