rsync参数的具体解释如下:
--exclude=PATTERN 指定排除不需要传输的文件模式
列子:
目前有目录test下有a,b,c三个目录
[]#ls test
a b c
复制目录test,但不复制a目录,复制到test-2021。
[]# rsync -av --exclude=test/a test test-2021
sending incremental file list
created directory test-2021
test/
test/b/
test/c/
sent 110 bytes received 84 bytes 129.33 bytes/sec
total size is 0 speedup is 0.00
如果我不想在 test-2021-2下创建test,但此时参数exclude参数发现失效了,复制了全部目录,此时需要把参数exclude放到test-2021-2后(复制后处理),此时目录为a
[]# rsync -av --exclude=test/a test/* test-2021-2
created directory test-2021-2
a/
b/
c/
sent 100 bytes received 83 bytes 366.00 bytes/sec
此时需要把参数exclude放到test-2021-2后(复制后处理),此时目录为a
注意:参数位置和目录都有改变
[]# rsync -av test/* test-2021-3 --exclude=a
created directory test-2021-3