Trouble with include/exclude patterns

Max Bowsher maxb at
Thu Feb 6 12:17:34 EST 2003

Anand Buddhdev wrote:
> I'm using rsync 2.5.4 on my RedHat 7.3 client laptop and rsync 2.5.5
> on my RedHat 8.0 server. On the client, I have a directory "rpm" with
> 5 subdirectories, out of which I only want to copy the one called
> across. I also have another directory ".mozilla" out of which I want
> to 
> copy across 2 files. I have constructed the following rsync
> invocation: 
> rsync -e ssh -av --delete \
> --exclude='/rpm/BUILD' --exclude='/rpm/SOURCES'
> --exclude='/rpm/SPECS' --exclude='/rpm/RPMS' \ 
> --include='.mozilla/arb/kfgj0v2y.slt/bookmarks.html' \
> --include='.mozilla/arb/kfgj0v2y.slt/prefs.js' \
> --exclude='.mozilla' \
> .mozilla \
> rpm \
> $SERVER:laptop-backup
> Now, this works correct for the "rpm" directory, by only copying
> rpm/SRPMS, and leaving out rpm/BUILD, rpm/SOURCES, /rpm/SPECS and
> rpm/RPMS.
> However, it does not copy my bookmarks.html and prefs.js files. If I
> add one more -v to the rsync command, I see this:
> excluding directory .mozilla because of pattern .mozilla
> So it seems the entire .mozilla directory is skipped, despite my 2
> --include statements.
> I have read the man page over and over, and I can't see what's wrong.

--include .mozilla
--include .mozilla/arb/
--exclude .mozilla/arb/*
--include .mozilla/arb/kfgj0v2y.slt/
--include .mozilla/arb/kfgj0v2y.slt/bookmarks.html
--include .mozilla/arb/kfgj0v2y.slt/prefs.js
--exclude .mozilla/arb/kfgj0v2y.slt/*

Yes, its messy.

I don't think there is a better way.

> Any idea what I'm doing wrong? And any ideas on reducing those 4
> --excludes to one --exclude and one --include for the rpm directory?


--include /rpm/SRPMS
--exclude /rpm/*

do what you want?


More information about the rsync mailing list