rsync 子目录上的包含/排除过滤器

rsync 子目录上的包含/排除过滤器

我已经阅读了几十个其他答案,但没有一个能起到作用。

我有很多这样的目录

Demultiplexing/Run1/analysis/
Demultiplexing/Run1/output/
Demultiplexing/Run2/analysis/
Demultiplexing/Run2/output/
OtherProjects/Run1/analysis/
OtherProjects/Run1/output/
OtherProjects/Run2/analysis/
OtherProjects/Run2/output/

我想要复制以下内容:

  • 仅限Demultiplexing目录

  • 仅限output子目录

  • 排除:名称中包含

我一直在尝试以下命令的变体:

remote_dir="/home/$(whoami)/production"
remote_server="server.org"
production_dir="/data/production"
rsync --dry-run -vrthP -e ssh "${production_dir}/" "$(whoami)"@"${remote_server}":"${remote_dir}/" \
--include="Demultiplexing" \
--include="Demultiplexing/*/output" \
--exclude="*:*" \
--exclude="*" 

但是,这不起作用,它只匹配顶级Demultiplexing目录,没有其他内容。我尝试了很多其他组合,它们要么包含所有内容,要么排除所有内容。

答案1

弄清楚了:

rsync -vrthP -e ssh "${production_dir}/" "$(whoami)"@"${remote_server}":"${remote_dir}/" \
    --include="Demultiplexing" \
    --include="Demultiplexing/*" \
    --include="Demultiplexing/*/output/***" \
    --exclude="*:*" \
    --exclude="*" 

答案2

再试一次:

[root@localhost ~]# rsync -avni --include=output --exclude=OtherProjects --exclude=analysis --exclude='*:*' src/ dst/
sending incremental file list
.d..t...... ./
cd+++++++++ Demultiplexing/
cd+++++++++ Demultiplexing/Run1/
cd+++++++++ Demultiplexing/Run1/output/
>f+++++++++ Demultiplexing/Run1/output/test
cd+++++++++ Demultiplexing/Run2/
cd+++++++++ Demultiplexing/Run2/output/

sent 167 bytes  received 38 bytes  410.00 bytes/sec
total size is 0  speedup is 0.00 (DRY RUN)

相关内容