A few months ago I wrote a post about escaping filename or directory spaces for rsync. Well that wasn’t the end of rsync giving me problems with spaces.
When I used the --exclude-from rsync option to specify a list of exclusions, I figured using single or double-quotes around files/directories that contain spaces would be enough to escape them. However, after swashing through hundreds and hundreds of lines from rsync’s output, I discovered the excluded directories were still being synced!
When using --exclude-from, files and directories should not contain any single or double quotes, only a backslash:
/afs/*
/automount/*
/Users/raam/Documents/Virtual\ Machines/*


Thanks. This is good information to know. I suspected that this was the case, but this will save me a decent amount of experimentation.
Cheers!
You’re welcome, Reagan!
my rsync cmd is as:
rsync -[options] —-exclude-from=exclude.file /mnt/xyz/ /home
so in the exclude.file do I include the path as:
- /mnt/xyz/abc/some.file or
- /abc/some.file or
- abc/some.file
Hi Dalal,
The syntax for rsync is
rsync [OPTION]... SRC [SRC]... DEST, so your example command will copy things FROM /mnt/xyz/ TO /home. I just want to make sure that’s what you’re trying to do!Regarding excluding: I believe the exclude pattern is in relation to the path you’re copying from. So, I think “abc/some.file” is the correct way to exclude in your example.
To make sure, you can do a “dry run” of the command to see what will happen by using the “-n” option. This causes rsync to show you what it would do, but it doesn’t actually transfer any files.
I hope this helps!