Yet another filter question

Christoph Biedl cbiedl at
Tue May 3 20:07:18 UTC 2016


Since the very first day I've been using rsync - some 15 years ago -
the filtering rules caused great grieve. Their behaviour is just not
the way I'd expect it be be and as I read the manpage. Usually I end
up with some hand-written recipes, carefully documented,y including all
the gotchas.

This time however I failed and I see no other way than to ask for

Given the following structure


Now, the following command (rsync 3.1.1)

    rsync -av --del --deleted-excluded -F \
        /path/to/project/ /path/to/backup/project/

should transfer

- sync: project/project.git/.git/
- skip: Everything else in project/project.git/
- sync: Everything else in project/

In other words: Don't transfer the git repo except for .git/ itself.
Yes, this means files not checked in are lost, that's by intention.

Now, how is .rsync-filter supposed to look? The first of many failing
attempts was

    + *.git/.git/*
    - *.git/

This however kills the entire project.git/ directory, in violation of
"the first matching pattern is acted on". Given previous bad
experiences I've tried (using a script) all 128 combination of

- line order
- '+' or '-' at the start of any line
- '*' appended to any line, or not, with without trailing slash

but no avail.

Any clue?


More information about the rsync mailing list