rsync --exclude 參數

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

 同步 除.svn  和temp  以外的文件php

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

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

/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

 可見都是相對路徑api

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 不會被同步
相關文章
相關標籤/搜索