Rsync在linux與windows間的同步

來源:互聯網
上載者:User

一、windows與windows同步
1.準備兩台機器:
server-----192.168.0.201
client-----192.168.0.202

2.下載windows版的rsync工具
具體軟體下載連結我也忘了,不過在google應該可以搜尋到。
我也將它上傳到CU上……

檔案: cwRsync_2.0.10_Installer.zip
大小: 2953KB
下載: 下載
檔案: cwRsync_Server_2.0.10_Installer.zip
大小: 2821KB
下載: 下載

server端:cwRsync_Server_2.0.10_Installer.zip
client端:cwRsync_2.0.10_Installer.zip

3.安裝 與配置
SERVER:
(1)安裝cwRsync_Server_2.0.10_Installer.zip
在開始程式中開啟“start a unix bash shell”程式:
進入一個類似cmd的終端,輸入如下命令:
$/bin/activate-user.sh
輸入l
輸入administrator
後面全按回來結束

(2)啟動opensshd
開啟“控制台”-->“管理工具”-->“服務”:
找到一個opensshd的服務,啟動它

(3)配置rsyncd.conf設定檔
編輯C:\Program Files\cwRsyncServer\rsyncd.conf,內容如下:
use chroot = false
strict modes = false
hosts allow = *
log file = rsyncd.log
pid file = rsyncd.pid
# Module definitions
# Remember cygwin naming conventions : c:\work becomes /cygwin/c/work
[rsync] 
path = /cygdrive/f/rsync   (此處路徑代表f:\rsync目錄)
read only = yes
transfer logging = yes
secrets file = /cygdrive/f/rsyncd.secrets 

(4)啟動rsync服務
開啟“控制台”-->“管理工具”-->“服務”:
找到一個RsyncServer的服務,啟動它
到此server端配置結束,接下來配置client端 。

CLIENT:
(1)安裝client端軟體包:cwRsync_2.0.10_Installer.zip
(2)開啟cmd,執行如下操作,測試服務端是否正常 啟動服務 了:
cd C:\Program Files\cwRsync\bin
telnet 192.168.0.201 22
telnet 192.168.0.201 873
若上述測試成功,此時可執行同步計劃:
rsync -vzrtopg --progress --delete 192.168.0.201::rsync /cygdrive/d/test
或者是:
rsync -vzrtopg --progress --delete 192.168.0.201:/cygdrive/d/rsync /cygdrive/d/test
(此時,會提示輸入密碼,使用者名稱為administrator,密碼則為192.168.0.201的管理員登入密碼)
至此,安裝配置windows到windows間的同步已經OK
如果定時同步server上的檔案,可將其加入任務計劃中。

二、windows作為server時與linux間的同步
1、準備機器,此時使用windows作為server
server---192.168.0.201 (windows)
client---192.168.0.132 (linux)

2、經過上文的操作,此時可簡化操作了
進入linux主機client同步server:
#rsync -vzrtopg --progress --delete 192.168.0.201::rsync /test 

三、linux作為server時與windows間的同步
1、準備機器,此時使用linux作為server
server---192.168.0.132 (linux)
client---192.168.0.202 (windows)

2、安裝與配置linux主機的rsync
(1)查看linux上是否安裝rsync:
#rpm -qa|grep rsync
若無則安裝,或者使用tar編譯安裝
#rpm -ivh rsync-2.6.8-3.1.rpm

(2)開啟rsync服務
#chkconfig xinetd on
#chkconfig rsync on

(3)建立 rsyncd.conf 檔案
#touch /etc/rsyncd.conf
#vi /etc/rsyncd.conf(內容如下:)
uid = nobody
gid = nobody
max connections = 4

[www]
path = /www
comment = BACKUP WWW
ignore errors
read only = yes
list = no
auth users = wwwuser
hosts allow=192.168.0.202
secrets file = /etc/wwwuser.pass

(4)啟動基於xinetd進程的rsync服務
#/etc/init.d/xinetd start

3、配置windows的rsync用戶端 
(1)安裝client端的rsync包
(2)開啟cmd,執行同步計劃:
cd C:\Program Files\cwRsync\bin
rsync -vzrtopg --progress --delete root@192.168.0.132::www /cygdrive/d/test
(此時須輸入root使用者的密碼,就可進行同步了。)

至此,全部配置完成。

註:
要使用加密的同步,可使用……
rsync -e 'ssh -p 2002' -vzrtopg --progress --delete root@192.168.0.132::www /cygdrive/d/test

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.