Rsync 从列表中包含和排除

Rsync include from and exclude from a list

我正在尝试使用 rsync include-from 和 exclude-from 命令来忽略或仅从源中复制列出的 files/directories。该列表位于文本文件中。由于某种原因,该命令未执行。为什么会这样?

代码:

rsync -ar —exclude-from 'exclude-list.txt' source/* destination/

rsync -ar —include-from 'exclude-list.txt' source2/* destination/

排除-list.txt:

file1
file2
/dir1
/dir2

您使用了错误的语法。你的命令宁愿是

rsync -ar --exclude-from='exclude-list.txt' source/ destination/

排除部分完全错误,而且来源也没有正确指定。首先你不需要 * 然后小心使用关闭 / 或不。 - 这意味着不同的东西!

我强烈建议您阅读 man-page(至少是您需要的部分),然后首先 运行 使用 -n--dry-run 命令查看内容会发生,但没有真正改变任何东西。对于这种情况,-v--stats--progress(甚至 --info=FLAGS)可能会很有趣。