2016-07-08 58 views
-1

我想只得到新的或改變的文件列表,結果只有很少的過濾器。 我的所有新的或修改過的文件有:rsync include-from文件遞歸

>f+++++++++ dsadcache.txt 
>f+++++++++ root.svn 
>f+++++++++ txt-file-in-root.txt 
>fcsT...... wp-config.php 
cd+++++++++ cache/ 
>f+++++++++ cache/fileincac.txt 
>f+++++++++ cache/fileincache.txt 
>f+++++++++ wp-content/inside.svn 
>f+++++++++ wp-content/inside.txt 
>f+++++++++ wp-content/object-cache.php 

最終的結果應該是這樣的:

>f+++++++++ txt-file-in-root.txt 
>fcsT...... wp-config.php 
>f+++++++++ wp-content/inside.txt 

當我嘗試包括,從文件與本規則:

- *cache* 
+ *.html 
+ *.txt 
+ *.js 
+ *.php 
+ *.jpg 
+ *.jpeg 
+ *.png 
+ *.bmp 
+ *.gif 
+ *.tif 
+ *.tiff 
+ *.ico 
+ *.json 
+ *.xml 
- * 

過濾器工作但結果不是遞歸的

>f+++++++++ txt-file-in-root.txt 
>fcsT...... wp-config.php 

丟失:

>f+++++++++ wp-content/inside.txt 

我的命令是:

rsync -nrci --include-from="file" source/ destination 

編輯:

讓我解釋一下獲勝的答案:

這裏的路徑rsync的過程的順序:

dsadcache.txt 
txt-file-in-root.txt 
cache/ 
cache/fileincac.txt 
cache/fileincache.txt 
wp-content/ 
wp-content/inside.txt 
wp-config.php 

不包括

filter='+ */' 

目錄

cache/ 
wp-content/ 

被排除在外。

回答

1

在遞歸模式下,rsync自上而下訪問子目錄,因此wp-content首先在您的規則中與您的規則匹配,當rsync檢查您的樹的頂層時。由於沒有與此目錄匹配的包含模式,因此通用排除規則- *將其刪除。

根據rsync聯機幫助頁,實現您的目標的一種方法是在排除規則之前的任意位置放置+ */,以便在遞歸操作過程中包含子目錄。

+0

檢查我的編輯,是否正確的處理方式? :) –

+0

@NovkovskiStevoBato我剛剛在你的解釋中添加了wp-content /作爲一個排除的目錄(同行評審未決)。除此之外,它看起來對我來說是正確的。 – coolparadox