这个问题的变体随处可见,我尝试过许多建议的解决方案。但我不明白以下命令中缺少什么rsync
:
这将发送源目录中的所有内容,而这是我所不想要的:
echo "$HP3000_SRC" "$HP0000_DST_HOST":"$HP3000_DST_DIR"
/tmp/hp3000 192.168.216.107:/usr/local/www/apache24/data/hll_DaV/upload/Other_Scans
rsync --dry-run -avz -ogt --include="./" --include="*pdf-Q*" --rsh='ssh -p22' "$HP3000_SRC" "$HP0000_DST_HOST":"$HP3000_DST_DIR"
!!Warning!! - Any deliberate attempt to access this resource without
legitimate authorization is a criminal offence
(R.S.C. 1985, c. C-46 - Section 342.1).
sending incremental file list
hp3000/
hp3000/HP3000-2021-04-23T23:27:16-04:00.pdf
hp3000/HP3000-2021-04-23T23:27:18-04:00.pdf
hp3000/HP3000-2021-04-23T23:27:18-04:00.pdf-QZARDBD
hp3000/HP3000-2021-04-23T23:27:19-04:00.pdf
hp3000/HP3000-2021-04-23T23:27:21-04:00.pdf
hp3000/HP3000-2021-04-23T23:27:21-04:00.pdf-QZCCB3R
hp3000/HP3000-2021-04-23T23:27:24-04:00.pdf
hp3000/HP3000-2021-04-23T23:27:24-04:00.pdf-QZCCMWR
hp3000/HP3000-2021-04-24T05:52:33-04:00.pdf
hp3000/HP3000-2021-04-24T05:52:33-04:00.pdf-QZARBDW
hp3000/HP3000-2021-04-24T05:52:34-04:00.pdf
hp3000/HP3000-2021-04-24T05:52:34-04:00.pdf-QZARDBJ
hp3000/HP3000-2021-04-24T05:52:35-04:00.pdf
hp3000/HP3000-2021-04-24T05:52:35-04:00.pdf-QZCCUBT
hp3000/HP3000-2021-04-24T05:52:36-04:00.pdf
hp3000/HP3000-2021-04-24T05:52:36-04:00.pdf-QZGLRQB
hp3000/HP3000-2021-04-25T00:39:49-04:00.pdf
hp3000/HP3000-2021-04-25T00:39:49-04:00.pdf-QZAPATB
hp3000/HP3000-REPORTS.txt
sent 811 bytes received 77 bytes 592.00 bytes/sec
total size is 701,038 speedup is 789.46 (DRY RUN)
虽然这什么也没有发送:
rsync --dry-run -avz -ogt --include="./" --include="*pdf-Q*" --exclude="*" --rsh='ssh -p22' "$HP3000_SRC" "$HP0000_DST_HOST":"$HP3000_DST_DIR" !!Warning!! - Any deliberate attempt to access this resource without
legitimate authorization is a criminal offence
(R.S.C. 1985, c. C-46 - Section 342.1).
sending incremental file list
sent 18 bytes received 12 bytes 20.00 bytes/sec
total size is 0 speedup is 0.00 (DRY RUN)
我想要传输的只是包含“ ”的文件pdf-Q
。 调用 的哪个部分rsync
可以完成此操作;为什么 会--exclude
覆盖--include
?
答案1
包含和排除选项从左到右应用:对于任何给定的文件或目录,第一个匹配的选项即被应用。
查看你的命令
rsync --dry-run -avz -ogt --include="./" --include="*pdf-Q*" --rsh='ssh -p22' "$HP3000_SRC" "$HP0000_DST_HOST":"$HP3000_DST_DIR"
您将匹配最顶层的目录(这已经发生,因此这是无操作),然后包含pdf-Q
文件名中包含的任何内容。没有排除,因此没有排除任何内容。
尝试这个(你不需要,-ogt
因为这些选项已经暗示了-a
)。
rsync --dry-run -avz --include='**/' --include='*pdf-Q*' --exclude '*' --prune-empty-dirs --rsh='ssh -q' "$HP3000_SRC" "$HP0000_DST_HOST":"$HP3000_DST_DIR"