rsync實現linux檔案同步到windows配置詳解

來源:互聯網
上載者:User

說明:
本篇文章實現linux定時將www,msyql,svn目錄rsync到win2003指定目錄上。
win2003安裝CWRsync,做為rsync的server端,運行CWRsync守護進程daemon,接受linux同步過來的檔案;
linux為centos,本身就有rsync,按時rsync檔案到win上。

環境:
win2003 192.168.1.2 CWRsync rsyncd服務端,以daemon守護進程運行
linux 192.168.1.3 rsync用戶端

實現:
1.win2003安裝CWRsync及防火牆設定
請參照:CWRsync圖文安裝

2.修改CWRsync設定檔rsyncd.conf(CWRsync安裝目錄下,我這裡的安裝目錄是:D:CWRsync)

 代碼如下 複製代碼

uid = 0
gid = 0
use chroot = false
strict modes = false
hosts allow = 192.168.1.3
log file = rsyncd.log

# Module definitions
# Remember cygwin naming conventions : c:work becomes /cygwin/c/work
#
[www]
path = /cygdrive/e/bakup/1_3/www  //CWRsync會自動將系統上所有的盤mount成/cygwin/x,因此/cygdrive/e/bakup/1_3/www指的是e:bakup1_3www目錄
read only = false
transfer logging = yes
auth users = rsyncd
secrets file = /cygdrive/D/CWRsync/rsyncd.secrets

[mysql]
path = /cygdrive/e/bakup/1_3/mysql
read only = false
transfer logging = yes
auth users = rsyncd
secrets file = /cygdrive/D/CWRsync/rsyncd.secrets

[svn]
path = /cygdrive/e/bakup/1_3/
read only = false
transfer logging = yes
auth users = rsyncd
secrets file = /cygdrive/D/CWRsync/rsyncd.secrets

 
3.添加CWRsync密碼檔案D:CWRsyncrsyncd.secrets
rsyncd:rsyncd //使用者:密碼

以上都是win2003的操作,下面是linux下的操作
4.添加rsync密碼檔案,這樣linux定時rsync目錄到win2003時就不需要輸入密碼

 代碼如下 複製代碼
# cat /root/rsyncd.secrets

rsyncd  //直接輸入密碼

 
5.修改crontab,定時激發rsync同步

 代碼如下 複製代碼

# crontab -e  //添加以下內容
10 3 * * * rsync -vrlptD --progress --password-file=/root/rsyncd.secrets /home/www/data rsyncd@192.168.45.2::www
25 3 * * * rsync -vrlptD --progress --password-file=/root/rsyncd.secrets /home/mysql/data rsyncd@192.168.45.2::mysql
40 3 * * * rsync -vrlptD --progress --password-file=/root/rsyncd.secrets /home/svn rsyncd@192.168.45.2::svn

 
附錄:
附錄1.在linux端運行# rsync -avrtopg --progress --password-file=/root/rsyncd.secrets /home/www/data rsyncd@192.168.45.2::rsyncd會出現password file must not be other-accessible
continuing without password file
password:
問題password file must not be other-accessible已經回答了,儲存密碼的檔案/root/rsyncd.secrets不應該被其它使用者可讀。
# chmod 600 /root/rsyncd.secrets //修改許可權為600即可

聯繫我們

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