nathan lachenmyer
nathan lachenmyer

Reputation: 5550

rsync: how to exclude directories with special character via external exclude file

I'm trying to back up a server with an rsync script automated with cron. Right now I'm using the command:

rsync -avz --progress --exclude-from "/Users/user/Scripts/exclude.txt" -e ssh user@server:$REMOTE_PATH $LOCAL_PATH > /tmp/rsync.log

with $REMOTE_PATH and $LOCAL_PATH defined in the bash script.

I have a directory called #recycle that I'm trying to skip, and am unsure how to exclude it with a file. If I use the option --exclude '#recycle/', then it skips the directory just fine. However, if I include the option above with an --exclude-from tag, with the file only containing the line:

#recycle/

then it doesn't work. I've also tried \#recycle/, but escaping the pound sign doesn't seem to fix the issue. I'm pretty sure that the pound is causing all of the issues, but I don't have any control over the directory names. Any thoughts on how to fix this?

thanks!

Upvotes: 5

Views: 3623

Answers (1)

that other guy
that other guy

Reputation: 123570

Lines starting with # are ignored in exclude files, yes.

You can instead use [#]recycle which matches the same thing, but is not discarded as a comment.

Upvotes: 7

Related Questions