close

最近想打包線上在跑的網站(在Ubuntu上)。本來想說用cp就好,但是cp沒辦法去exclude一些檔案列表,偏偏網站上面有些是暫存檔和使用者上傳的東西,另外還有一些雜七雜八不該包的code。

後來查到可以用rsync來作 因為有支援exclude的參數,以下是範例,a參數包含了一堆其他參數的功能,v參數就是將詳細資訊印出來

rsync -av --exclude 'dir' source destination

想要exclude多一點的話可以這樣下

rsync -av --exclude 'dir1' --exclude 'dir2' source destination

 

要注意的一點是:

如果想要避掉 某幾個目錄下的子目錄 像是每個目錄下的.svn資料夾,

可以直接用 --exclude '.svn/', 他會自動避掉所有符合名稱的子目錄

而如果是每個子目錄底下的檔案的話,

templates_c/底下的檔案,可以用 --exclude 'templates_c/*'

 

參考網址:

http://unix.stackexchange.com/questions/5774/rsync-excluding-a-particular-subdirectory-and-its-children-where-the-subdirecto#_

http://www.thegeekstuff.com/2011/01/rsync-exclude-files-and-folders/

http://blog.xuite.net/jyoutw/xtech/20025390

 

arrow
arrow
    文章標籤
    Linux rsync exclude
    全站熱搜

    卡卡 發表在 痞客邦 留言(0) 人氣()