Rsync: How do I include/exclude a directory whose name contains a hyphen

I'm working on a script to selectively synchronize certain users' directories with those on a server using rsync (version 3.0.5 protocol version 30).  I am using the --exclude-from command option, and everything works, except when a directory I am specifying contains a hyphen.  Then I can't get a patten match and the directory (and all its children) will not sync.  I have tried to escape the hyphen with a backslash, and replace it with an ampersand or a dot or an asterisk to wild card it.  The command I am using is:

rsync -avze ssh --dry-run --exclude-from='/home/user/excl.tmp' server01:/usr2/ /home/user/usr2/

Examples of excl.tmp file.  This works:
+ /gale
+ /gale/tools
+ /gale/tools/**
- *

This doesn't work (it only syncs the directory named gale):
+ /gale
+ /gale/solver-alpha
+ /gale/solver-alpha/**
- *

Note that rsync will happily sync other files with a hyphen in the name, it just fails to pattern match them when they are specified in the exclude file.

Other details:  The local machine is running ubuntu 9.04, while the remote server is running RedHat Enterprise Linux 5.4
LVL 1
jwolterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

woolmilkporcCommented:
How about
+ "/gale"
+ "/gale/solver-alpha"
+ "/gale/solver-alpha/**"
- *
wmp
0
jwolterAuthor Commented:
@woolmilkporc: enclosing in quotes seems to guarantee that nothing will match.
0
bman21Commented:
what about using escapes?  such as:

+ /gale
+ /gale/solver\-alpha
+ /gale/solver\-alpha/**

--OR--

going with woolmilkporc suggestion try using a single quote instead of a double quotes
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

jwolterAuthor Commented:
@bman21: nope, escapes don't work, nor do single quotes.

I tried the same commands on a system running rsync version 2.6.8 and it worked, so I'm thinking this is a bug in 3.0.5.  I think there are newer versions out, so I'm going to try that.
0
jwolterAuthor Commented:
Update: the latest version, 3.0.7, doesn't fix the problem.  I think it's time to submit a bug report.
0
jwolterAuthor Commented:
Update: just when I thought I was zeroing in on a bug in the code,  I suddenly realized why this wasn't working and it's embarrasingly simple.  It is because one time, early in my testing, I ran the command without the --dry-run argument.  So the directory in question, and its contents were already on the local machine.  rsync (correctly) determined that nothing needed to be transferred so it listed nothing in that directory to transfer.

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bman21Commented:
Makes sense.  Glad you figured it out!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Storage Software

From novice to tech pro — start learning today.