如何排除rsync中的多个目录?

Var*_*K M 6 backup scripts rsync

有人可以建议如何排除多个目录。下面提到的代码在这里我试图排除日志,但代码不起作用。我必须单独排除日志目录以及位于 /home/ec2-user/source/IntegrationServer/instances/packages 内的另一个名为 packages 的文件夹

#!/bin/bash

source=/home/ec2-user/source
dest=/home/ec2-user/destination

rsync -arv --exclude '/home/ec2-user/source/IntegrationServer/instances/default/logs/' $source/ $dest 
Run Code Online (Sandbox Code Playgroud)

小智 9

只需添加(--排除)多次

rsync -av --exclude some/subdir/linuxconfig --exclude some/other/dir --exclude exampledir /path/to/src/ /path/to/dest/
Run Code Online (Sandbox Code Playgroud)

  • 您还可以使用“--exclude-from”并列出要在文件中排除的目录名称。 (4认同)