使用RSync同步Linux和Windows檔案

來源:互聯網
上載者:User

一、linux 用戶端安裝
命令列下輸入:yum install rsync

二、windows服務端安裝

1.下載:http://sourceforge.net/projects/sereds/files/cwRsync/4.1.0/cwRsyncServer_4.1.0_Installer.zip
解壓後安裝,安裝過程會提示建立一個使用者,也可以用已經有的使用者,但需要該使用者有各相應目錄的讀寫權限。

2.開啟程式檔案目錄,編輯rsyncd.conf
參考配置如下:

#======================================================================

uid=0
gid=0
use chroot = no             #不使用chroot
read only = false           #唯讀模式,因為要上傳,所以沒開 
strict modes = false       #沒查過,不知道什麼意思
hosts allow = *               #存取控制,支援子網
log file = rsyncd.log       #記錄檔
pid file = rsyncd.pid       #進程ID檔案
lock file= rsync.lock       #鎖定檔案,不寫會報錯
max connections = 4  # 最大串連數為4

# Module definitions
# Remember cygwin naming conventions : c:/work becomes /cygwin/c/work
#
[test]    #定義節點
path = /cygdrive/D/bak/    #等價於D:/bak,將這個作為上傳時的根目錄,不能包含中文字元

read only = false                 
ignore errors                         #忽略一些錯誤
auth users=root                     #認證用的使用者名稱
hosts allow=*                         #同樣是存取控制
secrets file=rsync.pass     #指定root使用者的密碼儲存位置
transfer logging = yes           #日誌開啟

 

==========================================================================

3.程式檔案目錄下建立密碼檔案rsync.pass
內容格式:root:123456

4.確認配置無誤後,啟動rsync服務

5.在linux用戶端測試:

上傳測試:
rsync -vzrt 本地檔案路徑 登入使用者名稱@ip:連接埠::節點

說明:

A、本地路徑如果是上傳整個檔案夾的,本地路徑最後不加/;如本地路徑寫為:/etc,此時,伺服器上會在根目錄下建立一個etc檔案夾

B、本地路徑如果是上傳整個檔案夾下的所有檔案,本地路徑要以/結尾;如本地路徑寫為:/etc/,此時會將etc目錄下的所有檔案上傳至伺服器的根目錄
C、登陸使用者名稱為之前配置的使用者名稱,如root

D、IP是伺服器的IP地址,連接埠如果是預設的873則可以不加,如果不是,則需要在IP後加上連接埠號碼

E、節點,設定檔中[]定義的,如test

如果不想在串連時輸入密碼,可在linux上建立一個密碼檔案,把密碼寫入其中,
然後用--password-file = path/to/password/file來讀入密碼。
例:
rsync -vzrt --password-file=/root/rsync.pass  /root/  root@ip::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.