相关疑难解决方法(0)

rsync - 排除除少数目录之外的所有目录

似乎有很多关于此的 SF 和 SO 问题,但似乎没有一个符合我的要求。

source_dir/
  some_dir/
  another_dir/
  some_file.php
  some_other_file.txt
  include_this_dir/
  include_that_dir/
  yet_another_dir/
Run Code Online (Sandbox Code Playgroud)

所以我想 rsync 其中两个目录,同时排除其余的。排除这两个目录以外的所有目录很重要,因为可能有其他文件在以后添加到 source_dir 中,需要在未明确列出的情况下将其排除。

我试过:

rsync -av --dry-run --delete --exclude="source_dir/*" (or just "*") --include-from="include.txt" source_dir dest_dir
Run Code Online (Sandbox Code Playgroud)

我的 include.txt 有

  include_this_dir/
  include_that_dir/
Run Code Online (Sandbox Code Playgroud)

我也尝试添加

  source_dir/
Run Code Online (Sandbox Code Playgroud)

没有喜悦。什么都不包括在内。

rsync

10
推荐指数
1
解决办法
1万
查看次数

标签 统计

rsync ×1