Differentiating between files and directories when excluding files?

If I am backing up a directory and wish to include all directories named foo but not files named foo, is there a way to specify that? With rsync and git, a trailing slash on a name makes it match only directories…

rsync -a --exclude=foo/ . /dest/

…but that doesn’t appear to work with restic (0.17.3); running restic backup --exclude foo/ excludes both files and directories named foo.

I guess one could dynamically generate an exclude file with --exclude-file <(find srcdir -name foo -type d -print) or something like that.

The excludes do not differentiate between files and directories. See Allow excluding/negative-excluding directories only – give meaning to trailing slashes · Issue #4399 · restic/restic · GitHub for the corresponding feature request.

1 Like

Thanks for the issue pointer!