rsync --exclude 參數


/usr/bin/rsync -vr --exclude=".svn" --exclude="temp" --delete /alidata/www/pro/ecshop/ /alidata/www/crontal/ecshop

 同步 除.svn  和temp  之外的文件

rsync 命令選項 源目錄 目標目錄

假如源目錄寫為 /var/www/就會把該目錄下所有文件同步到目標目錄,如果寫為/var/www/*,那么當前目錄下的隱藏文件(文件夾名或文件名是以”.”號開頭)則不會被同步,不過子目錄中的隱藏文件還是會被同步。

假設需要排除某個文件(或文件夾),可以用–exclude來指定,例如需要排除源目錄下的dir1文件夾,可以寫為:
/usr/bin/rsync -vzrtopg –exclude=dir1 /var/www/src/ /var/www/dest

可以同時排除多條,例如:
/usr/bin/rsync -vzrtopg –exclude=dir1 –exclude=dir2 /var/www/src/ /var/www/dest

除了上述方法,還可以通過–exclude-from來指定,例如:
/usr/bin/rsync -vzrtopg –exclude-from=exclude.list /var/www/src/ /var/www/dest

exclude.list文件中指定需要排除的列表,例如:
dir1
[0-9]*
dir2/.[a-z0-9]*
.svn

 ------------------------------->實例

/usr/bin/rsync -vr --exclude=".svn" --exclude="temp/*" --exclude="data/config.php" --exclude="mobile/data/*" --exclude="mobile/include/base/constant.php"  --delete /alidata/www/pro/ecshop/ /alidata/www/crontal/ecshop

 可見都是相對路徑

root@(none):~/svnclient/ecshop# la -a
.                     api              cert                   diy.php           feed.php          includes     pick_out.php   snatch.php     wap
..                    api.php          certi.php              dl_receiver.php   flash_sale.php    index.php    pm.php         .svn           wholesale.php
activity.php          article_cat.php  chinabank_receive.php  doc               flow.php          js           quotation.php  tag_cloud.php  widget
admin                 article.php      comment.php            ecmoban_qq        gallery.php       languages    receive.php    temai.php      xxzz
affiche.php           auction.php      compare.php            ecs_template.frm  goods.php         message.php  region.php     temp
affiliate.php         brand.php        cycle_image.php        ecs_template.MYD  goods_script.php  mobile       respond.php    themes
alipay.html           captcha.php      data                   ecs_template.MYI  group_buy.php     myship.php   robots.txt     topic.php
allcate.php           catalog.php      delete_cart_goods.php  exchange.php      htaccess.txt      package.php  search.php     user.php
animated_favicon.gif  category.php     denglu.php             favicon.ico       images            phpinfo.php  sitemaps.php   vote.php
root@(none):~/svnclient/ecshop# pwd
/root/svnclient/ecshop

 

root@(none):~/svnclient/ecshop# ecshop 下的 data/config.php temp/* mobile/data/* mobile/include/base/constant.php 不會被同步

 


 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM