linux和windows同步資料 cwrsync client to rsync server

來源:互聯網
上載者:User

標籤:style   http   io   ar   os   使用   sp   for   檔案   

linux和windows同步資料,rsync server  cwrsync client

linux server
一般系統都內建rsync,如果沒有就掛載系統硬碟自己安裝一下,安裝挺簡單的不用我再多說了
vi /etc/rsyncd.conf
uid = daemon                            
//這個使用者是系統使用者,當rsync用戶端串連上伺服器後,會映射成這個使用者上傳或者下載檔案
gid = daemon                            
//組名,效果同上
log file = /var/log/rsyncd.log          
//rsync的記錄檔儲存位置
max connections = 5                     
//最大允許的並發連結是5
hosts allow = 192.168.1.0/24             
//只允許指定網段的地址連結的伺服器
hosts deny = *                          
//拒絕其他所有的連結
list = yes                              
//使用者具有list目錄的許可權
auth users = test                       
//rsync的使用者名稱,這個使用者是用戶端使用的,連結的伺服器成功後會映射成上面的daemon使用者
read only = no                          
//不是唯讀模式,這樣使用者就有上傳的許可權了
write only = yes                        
//不允許使用者下載
secrets file = /etc/rsync.pass          
//rsync使用者的密碼檔案儲存位置
[test]                                  
//服務端的模組,用戶端登入時候需要指定
path = /home/test                       
//test模組的絕對路徑             
vi /etc/rsync.pass
test:test                               
//前面是使用者名稱,後面是密碼中間用冒號分割
chmod 600  /etc/rsync.pass              
//修改密碼檔案的許可權
mkdir /home/test
chown daemon.daemon /home/test

windows client
下載cwrsync的安裝包
可以從這個網站擷取到 http://sourceforge.net/projects/sereds/files/cwRsync
然後建立一個install.bat的指令碼
@echo off 

cd C:\Program Files\WinRAR 
rar.exe e -o+ "%HOMEPATH%"\案頭\test.rar "%HOMEPATH%"\案頭\ 
cd "%HOMEPATH%"\案頭\
echo "C:\Program Files\cwRsync\bin\rsync.exe" -vzrtopg --progress --exclude=Recycled --exclude=RECYCLER --exclude="System Volume Information" --password-file=/cygdrive/C/"Program Files"/cwRsync/bin/rsync.pass /cygdrive/d/ [email protected]::test > C:"\Program Files"\cwRsync\bin\rsync.bat
echo test > C:"\Program Files"\cwRsync\bin\rsync.pass
"C:\Program Files\cwRsync\bin\chmod.exe" 600 "/cygdrive/C/Program Files/cwRsync/bin/rsync.pass"
at 12:00 /interactive /every:m,t,w,th,f "C:\Program Files\cwRsync\bin\rsync.bat"

下面是詳細的介紹: 
cd C:\Program Files\WinRAR 
rar.exe e -o+ "%HOMEPATH%"\案頭\test.rar "%HOMEPATH%"\案頭\ 
cd "%HOMEPATH%"\案頭\
#以上三行主要是解壓test.rar的壓縮包 
cwrsync.exe                          
#調用cwrsync的安裝主程式,根據提示一路下一步就可以,沒有需要注意的地方 
echo "C:\Program Files\cwRsync\bin\rsync.exe" -vzrtopg --progress --exclude=Recycled --exclude=RECYCLER --exclude="System Volume Information" --password-file=/cygdrive/C/"Program Files"/cwRsync/bin/rsync.pass /cygdrive/d/ [email protected]::test > C:"\Program Files"\cwRsync\bin\rsync.bat
#上面這句話會產生一個上傳檔案的指令碼,具體內容如下:
#echo 是列印內容
#C:\Program Files\cwRsync\bin\rsync.exe    cwrsync的主程式路徑
#-vzrtopg
#-v, --verbose   詳細模式輸出
#-z, --compress  對備份的檔案在傳輸時進行壓縮處理
#-r, --recursive 對子目錄以遞迴模式處理
#-t, --times     保持檔案時間資訊
#-o, --owner     保持檔案屬主資訊
#-p, --perms     保持檔案許可權
#-g, --group     保持檔案屬組資訊
#--progress      顯示備份過程
#--exclude       是排除的意識,我的範例中排除了三個目錄
#--passwrod-file 密碼檔案的存放路徑
#/cygdrive/d/ 本地的路徑,我這裡是D盤,前面cygdrive必須要跟上,要不cwrsync無法識別你的路徑
#[email protected]::test   目標地址,第一個test是使用者名稱@後面是server的地址::後面是servier端的模組名,在rsyncd.conf檔案中定義過
#> 重新導向和linux系統一樣的用法 
#C:"\Program Files"\cwRsync\bin\rsync.bat 將以上的內容重新導向到rsync.bat這個檔案中
#更多的資訊可以查看rsync的協助 
echo test > C:"\Program Files"\cwRsync\bin\rsync.pass
#這句話是產生密碼檔案,密碼的存放路徑,密碼是test,密碼檔案不需要使用者名稱,只有密碼就可以了 
"C:\Program Files\cwRsync\bin\chmod.exe" 600 "/cygdrive/C/Program Files/cwRsync/bin/rsync.pass"
#使用cwrsync內建的chmod給密碼檔案賦予600的許可權,一定要注意格式,這裡是類比了linux的用法,不要搞錯了,注意兩點一個是cygdrive和反斜線 
at 12:00 /interactive /every:m,t,w,th,f "C:\Program Files\cwRsync\bin\rsync.bat"
#win內建的一個服務,將添加我們建立的指令碼到任務計劃,注意這個任務計劃的作者是system使用者
#at是命令,必須保證task scheduler服務是啟動的 12:00任務計劃在12點執行,/interactive任務計劃和案頭有互動,使用者能看見彈出的cmd視窗
#/every:m,t,w,th,f 周一至周五執行任務計劃 "C:\Program Files\cwRsync\bin\rsync.bat"命令具體路徑
#關於at的更多用法大家還是多看看協助檔案吧
將下載回來的cwrsync.exe和我們的install.bat壓縮到一起,壓縮名是text.rar,用戶端就製作完成了,發行就緒給客戶使用,其中的細節根據自己的情況作修改吧 

linux和windows同步資料 cwrsync client to rsync server

相關文章

聯繫我們

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