我只想获取新的或更改的文件列表,结果上几乎没有过滤器。 我所有新的或更改的文件是:
>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/
被排除在外。
最佳答案
在递归模式下,rsync 从上到下访问子目录,因此当 rsync 检查树的顶层时,wp-content
首先与您的规则进行匹配。由于没有与此目录匹配的包含模式,通用排除规则 - *
将删除它。
根据 rsync 手册页,实现目标的一种方法是在排除规则之前的任何位置放置 + */
,以便在递归操作期间包含子目录。
关于linux - rsync 包含文件递归,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38276884/