乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      rsync詳解之exclude排除文件

       huhuwoo 2015-10-12

      rsync詳解之exclude排除文件

      問(wèn)題:如何避開(kāi)同步指定的文件夾?  --exclude
      rsync  --exclude files and folders

      http://articles./2007/10/10/rsync-exclude-files-and-folders

      很常見(jiàn)的情況:我想同步/下的 /usr   /boot/ ,  但是不想復(fù)制/proc  /tmp 這些文件夾

      如果想避開(kāi)某個(gè)路徑  直接添加--exclude 即可

      比如--exclude “proc”

      --exclude ‘sources’

      Note: the directory path is relative to the folder you are backing up.

      注意:這個(gè)路徑必須是一個(gè)相對(duì)路徑,不能是絕對(duì)路徑


      例子:源服務(wù)器/home/yjwan/bashshell有一個(gè)checkout文件夾

      [root@CentOS5-4 bashshell]# ls -dl checkout

      drwxr-xr-x 2 root root 4096 Aug 21 09:14 checkou

      現(xiàn)在想要完全避開(kāi)復(fù)制這個(gè)文件夾內(nèi)容怎么辦?

      目標(biāo)服務(wù)器執(zhí)行

      rsync -av --exclude “checkout” yjwan@172.16.251.241:/home/yjwan/bashshell /tmp

      將不會(huì)復(fù)制這個(gè)文件夾

      [root@free /tmp/bashshell]# ls -d /tmp/bashshell/checkout

      ls: /tmp/bashshell/checkout: No such file or directory


      注意:


      1事實(shí)上,系統(tǒng)會(huì)把文件和文件夾一視同仁,如果checkout是一個(gè)文件,一樣不會(huì)復(fù)制


      2 如果想避開(kāi)復(fù)制checkout里面的內(nèi)容,可以這么寫--exclude “checkout/123”


      3 切記不可寫為 --exclude “/checkout”這樣絕對(duì)路徑

      這樣寫 將不會(huì)避免checkout被復(fù)制

      比如

      [root@free /tmp/bashshell]# rsync -av --exclude “/checkout” yjwan@172.16.251.241:/home/yjwan/bashshell /tmp

      receiving file list … done

      bashshell/checkout/


      4可以使用通配符 避開(kāi)不想復(fù)制的內(nèi)容

      比如--exclude “fire*”

      那么fire打頭的文件或者文件夾全部不會(huì)被復(fù)制

      5如果想要避開(kāi)復(fù)制的文件過(guò)多,可以這么寫

      --exclude-from=/exclude.list


      exclude.list 是一個(gè)文件,放置的位置是絕對(duì)路徑的/exclude.list ,為了避免出問(wèn)題,最好設(shè)置為絕對(duì)路徑。


      里面的內(nèi)容一定要寫為相對(duì)路徑


      比如 我想避開(kāi)checkout文件夾和fire打頭的文件


      那么/exclude.list 寫為

      checkout

      fire*

      然后執(zhí)行以下命令,注意寫為--exclude-from或者--exclude-from=都可以

      但是不能為--exclude

      rsync -av --exclude-from=”/exclude.list” yjwan@172.16.251.241:/home/yjwan/bashshell /tmp

      檢查結(jié)果:確實(shí)避開(kāi)了checkout文件夾和fire打頭的文件

      問(wèn)題:如何計(jì)算對(duì)比復(fù)制以后的文件數(shù)量是否正確呢?
      1 查看錯(cuò)誤日志,看是否復(fù)制時(shí)候出問(wèn)題了

      2在源服務(wù)器執(zhí)行可知道具體文件和文件夾的總個(gè)數(shù)

      ls –AlR|grep “^[-d]”|wc

      然后目標(biāo)服務(wù)器在計(jì)算一遍個(gè)數(shù)

      看看數(shù)字是不是能對(duì)的上就ok了

      對(duì)不上再研究怎么回事

      3現(xiàn)在的問(wèn)題是:如果我使用了--exclude參數(shù)就麻煩了

      我怎么知道要復(fù)制幾個(gè)文件?
      首先,前面命令時(shí)候提到過(guò)一種寫法,就是只有源地址,沒(méi)有目標(biāo)地址的寫法,這種寫法可以用來(lái)列出所有應(yīng)該被復(fù)制的文件
      那么用這個(gè)命令,可以計(jì)算出這個(gè)/root/bashshell下面文件和文件夾數(shù)量

      在服務(wù)器端執(zhí)行

      [root@CentOS5-4 bashshell]# rsync -av /root/bashshell/ |grep “^[-d]” | wc

      62     310    4249

      和ls 得到的結(jié)果一致的

      [root@CentOS5-4 bashshell]# ls -AlR |grep “^[-d]“|wc

      62     558    3731

      因此,比如說(shuō)我不要fire 打頭的文件,可以在服務(wù)器端先這樣計(jì)算要復(fù)制的文件
      [root@CentOS5-4 bashshell]# rsync -av --exclude “fire*” /root/bashshell/ |grep “^[-d]” | wc

      44     220    2695

      然后復(fù)制過(guò)去

      看目標(biāo)機(jī)器的文件和文件夾數(shù)量為

      [root@free /tmp]# ls -AlR /tmp/bashshell/  |grep “^[-d]“|wc

      44     396    2554

      可以知道2者是同步的

      問(wèn)題:Rsync的其他幾個(gè)常見(jiàn)參數(shù)
      1

      -z        –compress              compress file data during the transfer

      --compress-level=NUM    explicitly set compression level

      --skip-compress=LIST    skip compressing files with suffix in LIST

      壓縮傳輸,如果網(wǎng)絡(luò)帶寬不夠,那么應(yīng)該壓縮以后傳輸,消耗的當(dāng)然是機(jī)器資源,但是如果內(nèi)網(wǎng)傳輸?shù)脑?,文件?shù)量不是很多的話,這個(gè)參數(shù)不必要的。

      2

      --password-file=FILE

      前面說(shuō)過(guò)了,只有遠(yuǎn)端機(jī)器是rsync服務(wù)器,才能用這個(gè)參數(shù)

      如果你以為個(gè)FILE寫的是ssh 登陸的密碼,那就大錯(cuò)特錯(cuò)了,不少人犯了這個(gè)錯(cuò)誤。

      3

      –stats: Adds a little more output regarding the file transfer status.

      4

      –progress: shows the progress of each file transfer. Can be useful to know if you have large files being backup up.

      關(guān)于這個(gè)參數(shù):

      I frequently find myself adding the -P option for large transfers. It preserves partial transfers in case of interuption, and gives a progress report on each file as it’s being uploaded.

      I move large media files back and forth on my servers, so knowing how long the transfer has remaining is very useful.

      ·Previous Entry: nginx 每天定時(shí)切割Nginx日志的腳本
      ·Next Entry: 如何開(kāi)啟MySQL的遠(yuǎn)程賬號(hào)

      本文出自 “娜一片天空” 博客,請(qǐng)務(wù)必保留此出處http://wanwentao.blog.51cto.com/2406488/582432

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多