【问题标题】:rsync is nesting the source directory in the destination as if it had no trailing slash when --files-from option is used当使用 --files-from 选项时,rsync 将源目录嵌套在目标中,就好像它没有尾部斜杠一样
【发布时间】:2017-04-26 07:37:27
【问题描述】:

在这里拉我的头发试图让它发挥作用。下面是详细信息和命令的示例。

我有一个名为 list.txt 的目录列表文件,其内容如下所示:

HYTTCCCXX HYTVNCCXX HYV5TCCXX

我的 rsync 命令如下所示: rsync -av --recursive --files-from='/tmp/list.txt' /test/apple/ /destination/files/

问题是当我运行命令时,它包括 /test/(这是一个 autofs 顶层,因此实际上不包含任何内容)和 /test/apple/ 在要传输的文件中。导致文件被写入目标两次,就好像我在源代码中留下了斜杠一样。

因此,目标最终会包含列表中的两个目录,以及源的另一个副本,例如: /destination/files/HYW22CCXX /destination/files/HYTVNCCXX /destination/files/HYV5TCCXX /destination/files/test/apple/HYW22CCXX /destination/files/test/apple/HYW22CCXX /destination/files/test/apple/HYTVNCCXX

所以我最终得到了所有内容的 2 个副本。

我尝试了各种排除组合,例如 --exclude='/test/apple/'--exclude='/test/*--exclude='apple/* 以试图阻止它被包含在内。但没有任何效果。

有什么想法吗?我很想弄清楚这一点。

谢谢!

【问题讨论】:

    标签: linux bash rsync nfs


    【解决方案1】:

    这是因为--files-from 选项暗含--relative

    引用自 rsync 手册页,--files-from 部分:

    --relative (-R) 选项是隐含的,它保留了为文件中每个项目指定的路径信息(如果要关闭它,请使用--no-relative 或--no-R) .

    尝试以下选项,看看是否有帮助: rsync -av --recursive --no-relative --files-from='/tmp/list.txt' /test/apple/ /destination/files/

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-07
      • 2014-03-29
      • 1970-01-01
      相关资源
      最近更新 更多