我试图只使用口是心非备份特定文件,所以我首先使用了这个命令:
duplicity /source-path --include "**/*/*.txt" --include "**/*/*.xml" /dest-path
但这会产生以下错误:
Last selection expression:
Command-line include glob: **/*/*.txt
only specifies that files be included. Because the default is to
include all files, the expression is redundant. Exiting because this
probably isn't what you meant.
然后我尝试排除所有内容,然后仅包含我需要的内容:
duplicity /source-path --exclude "**/*" --include "**/*/*.txt" --include "**/*/*.xml" /dest-path
但我仍然遇到同样的错误。我将如何做到这一点,基本上只备份源上的 .txt 和 .xml ?
答案1
在如何包含和排除文件的多种变体的长篇描述中,似乎有一个最重要的句子:
当第一个匹配的文件选择条件指定排除给定文件时,文件选择系统准确地排除该文件。
据此,您首先需要为您想要的文件提供一个包含选项,以便它们在那里匹配,并且第一个匹配不能再是排除。有一个排除选项来匹配所有内容。之前匹配的文件不会受到影响,但现在排除其他所有文件:
duplicity ... --include "**/*/*.txt" --exclude "**/*" src dest
对于你的例子来说,那就是
duplicity /source-path --include "**/*/*.txt" --include "**/*/*.xml" --exclude "**/*" /dest-path
要了解哪些文件是匹配的,您可以使用试运行,而不更改任何内容,并通过日志记录来列出匹配的文件:
duplicity --dry-run --no-encryption -v info --include ... --exclude ... src dest
FILE SELECTION
duplicity accepts the same file selection options rdiff-backup does,
including --exclude, --exclude-filelist-stdin, etc.
When duplicity is run, it searches through the given source directory
and backs up all the files specified by the file selection system. The
file selection system comprises a number of file selection conditions,
which are set using one of the following command line options:
--exclude
[ ... ]
--include-regexp
Each file selection condition either matches or doesn't match a given
file. A given file is excluded by the file selection system exactly
when the first matching file selection condition specifies that the
file be excluded; otherwise the file is included.