Reputation: 22225
I would like to do a
rsync master slave
with the following restriction: The directory master/foo/xxx
should be excluded from being copied, but the directory master/bar/xxx
should be copied.
I can not write
rsync --exclude xxx master slave
because this would also exclude master/bar/xxx
. To my surprise, I can also not use
rsync --exclude master/foo/xxx master slave
because it copies BOTH xxx directories (why?).
Of course I can revert to writing two rsync's:
rsync --exclude xxx master slave
rsync master/bar/xxx slave/bar/xxx
but I wonder whether this can't be done any simpler.
Upvotes: 0
Views: 69
Reputation: 25559
The correct command is this:
rsync --exclude /foo/xxx master slave
Include/exclude rules beginning with /
are relative to the root of the transfer (not the root of the filesystem).
Rules starting with other characters are matched to the end of each filename, so foo/xxx
would work also, but might match directories you weren't expecting if there is a foo
somewhere else in the directory tree.
Your command did not work because "master" is outside the root of the transfer.
Upvotes: 1