2

我正在使用rdiff-backup。非常棒的简单强大的备份工具。但是,我正在与通配符 glob 模式作斗争。我有这个目录结构:

/data/aaa/cache
/data/bbb/cache
/data/ccc/cache
etc....

在每个缓存目录中都有原始文件和缓存文件。原始文件简单地命名为1.jpg2.png3.gif等。缓存文件在原始文件名上附加了一些字符串。

所以我想备份所有 /data/*/cache 目录,但只包括原始文件,而不是缓存文件。

我正在使用这个命令:
rdiff-backup --exclude **/cache --include **/cache/+([0-9]).+([a-z]) /data /backup

但是 rdiff-backup 返回这个,我迷路了:

Found interrupted initial backup. Removing...
Fatal Error: Last selection expression:
    Command-line include glob: **/cache/+([0-9]).+([a-z])
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.
4

2 回答 2

3

您可能需要执行两步过程:

  1. 创建要排除的所有文件的列表,例如使用 find 。-name "**/cache" > excludes.lst
  2. 将列表与 --exclude-filelist excludes.lst 一起使用

这样您就可以避免使用 glob 选项,并且您可以完全控制您的排除项

于 2014-10-18T15:42:20.967 回答
2

来自http://rdiff-backup.nongnu.org/rdiff-backup.1.html

   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.

...

   For instance,

          rdiff-backup --include /usr --exclude /usr /usr /backup

   is exactly the same as

          rdiff-backup /usr /backup

   because  the  include  and  exclude  directives  match exactly the same
   files, and the --include comes first, giving it precedence.

因此,在您的情况下,它在抱怨 final--include因为如果文件到达那里(即它与前一个不匹配--exclude),无论它是否与--include. 这就是错误消息想要表达的意思。

至于如何实现你的目标...

假设您确实只想排除表单的路径:只需/data/*/cache/[0-9]*.[a-z][a-z][a-z]?*指定:

rdiff-backup --exclude '/data/*/cache/[0-9]*.[a-z][a-z][a-z]?*' --exclude '*' /data /backup

这应该有效(我没有测试过)。

于 2014-10-15T19:36:54.337 回答