I'm trying to exclude a directory tree as part of an rsync
command embedded in a bash
script approximately like this:
$OPTIONS="-rl --exclude 'Some Parent Directory/Another Directory'"
rsync $OPTIONS $SOURCEDIR a@b.com:/SomeTargetDir
My aim is to sync all of $SOURCEDIR
into /SomeTargetDir
on the target machine, with the exception of everything under Some Parent Directory/Another Directory
. However, I keep seeing errors of this form:
rsync: link_stat "/Users/myusername/Parent\" failed: No such file or directory (2)
I assume this is related to escaping the exclude path, but I just can't seem to get it right: every combination of \\
, \
and so on that I try doesn't seem right. How can I write the exclude rule correctly?
I don't want to use --exclude-from
unless I absolutely have to.
I am using rsync version 3.0.9 on OS X 10.8, syncing to Ubuntu 12.04 over SSH.