轉:使用rsync在linux(服務端)與windows(用戶端)之間同步

來源:互聯網
上載者:User

標籤:

轉自:http://blog.csdn.net/old_imp/article/details/8826396
一 在linux(我用的是centos系統)上安裝rsync和xinetd前先查看linux上是否已經安裝:
#rpm -qa|grep rsync#rpm -qa|grep xinetd若無則安裝,或者使用tar編譯安裝#rpm -ivh rsync-2.6.8-3.1.rpm或者yum install rsync(這是我使用的方法)yum  install xinetd(這是我使用的方法)
二 開啟rsync服務
#chkconfig xinetd on
#chkconfig rsync on

三 在/etc/目錄下建立 rsyncd.conf 設定檔(設定成600許可權)port =  873
uid = root
gid = root
use chroot=no
read only = yes
hosts allow=*
max connextions = 4

[www] 
path = /********/****l/****
comment = BACKUP WWW
ignore errors
read noly = yes
list = no
auth users = root
hosts allow = *
secrets file = /etc/rsync.pass(檔案名稱只是舉例,包括尾碼都可以自訂) 設定檔中的參數含義可以參考http://hi.baidu.com/setcookie/item/14f9e8998ad1028858146135 四 建立rsync.pass檔案(設定成600許可權)
,也就是rsync.conf檔案中secrets file 指定的路徑,輸入linux系統中存在的帳號密碼帳號:密碼 五 修改etc/xinetd/rsync 檔案把disable = yes 改成 disable = no六 啟動基於xinetd進程的rsync服務#/etc/init.d/xinetd start 七 windows機器上安裝cwrsync 八 開啟 linux上的873連接埠(rsync預設使用的連接埠) 九 開啟cmd 執行同步指令即可同步h:\cwRsync\bin\rsync.exe -vzrtopgu --progress --delete [email protected]::www /cygdrive/D/test然後就可以看到輸入密碼的提示,輸入密碼就開始同步了。解釋一下:h:\cwRsync\bin\rsync.exe是rsync.exe的路徑www就是rsync.conf檔案中指定的模組名[email protected]是linux機器使用者名稱,ip/cygdrive/D/test 的含義是備份到windows本地的D:\test路徑,其他路徑依葫蘆畫瓢即可,比如E:\test,寫成/cygdrive/E/test 十 windows用戶端設定cwRsync自動同步建立一個.bat檔案,編輯輸入以下命令內容後儲存:h:\cwRsync\bin\rsync.exe -vzrtopgu --progress --delete [email protected]::www /cygdrive/G/backup --password-file=/cygdrive/D/rsync.pass接下來按照需要建立windows的工作排程器,在巨集指令清單中添加啟動這個.bat檔案的操作。解釋:password-file=/cygdrive/D/rsync.pass 指定了windows用戶端機器上的密碼檔案位置。windows用戶端上的密碼檔案格式和linux服務端上的格式不一樣,只需要寫密碼即可。如果在cmd執行以上命令可以不輸入密碼,因為程式會自動讀取輸入的密碼檔案。 十一安全起見有時需要更改rsync使用的連接埠1把伺服器上需要使用的連接埠開啟2修改伺服器上的rsyncd.conf 設定檔port = (要使用的連接埠號碼)3本地用戶端連結的伺服器備份的口令也得修改,加入--port=(連接埠號碼)例如:h:\cwRsync\bin\rsync.exe -vzrtopgu  --port=(連接埠號碼) --progress --delete [email protected]::www /cygdrive/G/backup --password-file=/cygdrive/D/rsync.pass 十二 如果重啟了伺服器,用戶端備份時出現錯誤提示Connection refused (111) 的解決辦法完整錯誤提示:rsync: failed to connect to 10.10.10.170: Connection refused (111) 
rsync error: error in socket IO (code 10) at clientserver.c(124) [receiver=3.0.5] 
解決方案:服務端啟動服務:rsync --daemon --config=/etc/rsyncd.conf

轉:使用rsync在linux(服務端)與windows(用戶端)之間同步

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.