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