0
votes

I'm trying to backup multiple directories with rsync, using --exclude option.

I know that --exclude paths need to be relative to the source path, but what happens when there are multiple sources?

Let's say I want to backup /home/user/source_a and /home/user/source_b, but want to exclude /home/user/source_a/something.

When I write --exclude=/something will both /home/user/source_a/something and /home/user/source_b/something be excluded (if there's /home/user/source_b/something)?

1

1 Answers

0
votes

I obviously misunderstand your question - so my first version of my answer was expecting you want to exclude the 'something' directory in both sources. I that case the trailling slash on the sources was needed.

To exclude only /home/user/source_a/something (not /home/user/source_b/something) as refined in your comment, you have to go a level higher, so that rsync is aware of the different sources. Then your rsync command would look like this:

rsync -a --exclude=/source_a/something /home/user/source_a /home/user/source_b /target

Just by removing the trailing slash at the sources will transfer the source_a and source_b directories itself, too. Therefor it is now possible to exclude a path from a specific source.