Rsync:一個很實用的檔案同步命令,rsync很實用

來源:互聯網
上載者:User

Rsync:一個很實用的檔案同步命令,rsync很實用

sync是Linux系統下的檔案同步和資料轉送工具,可用於同步檔案、代碼發布

1.安裝.

yum install -y xinetd 
yum insatll -y rsync

2.配置 
開啟rsync功能vim /etc/xinetd.d/rsync

 

service rsync{        disable = no    #把yes改成no        flags           = IPv6        socket_type     = stream        wait            = no        user            = root        server          = /usr/bin/rsync        server_args     = --daemon        log_on_failure  += USERID}
編輯主設定檔
vim /etc/rsyncd.conf服務端

uid = nobody       #目錄或檔案的屬主屬組為nobody,同步的時候報錯許可權不足檢查目錄檔案的所屬使用者組
gid = nobody
use chroot = yes
max connections = 30
pid file=/var/run/rsyncd.pid
log file=/var/log/rsyncd.log
list = no

[data]    #同步項 模組     【同步項不需要再服務端添加】
path = /usr/local/hero_all_backup/           
hosts allow = 192.168.50.146  
read only = yes

啟動即可。rsync –daemon

3.使用.

 rsync -avz aaa.txt 192.168.0.162::data

####

-v, –verbose 詳細模式輸出

-a, –archive 歸檔模式,表示以遞迴方式傳輸檔案,並保持所有檔案屬性

-z, 對備份的檔案在傳輸時進行壓縮處理 

–-delete 刪除那些DST中SRC沒有的檔案 

–-exclude= 指定排除不需要傳輸的檔案模式 

4.其他.

 

rsync -avz --delete /tmp/2/ /var/spool/clientmqueue/ 

同步/tmp/2空目錄到/var/spool/clientmqueue/   即刪除/var/spool/clientmqueue/目錄下的無用檔案。

rsync -avz --delete --exclude=".svn" --exclude="*.swp"

同步的時候排除.svn和.swp的隱藏檔案

 

聯繫我們

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