Excluding file without pathname does not work
Have you checked borgbackup docs, FAQ, and open Github issues?
Yes
Is this a BUG / ISSUE report or a QUESTION?
BUG
System information. For client/server mode post info for both machines.
Your borg version (borg -V).
1.1.5
Operating system (distribution) and version.
Ubuntu 18.04.1 LTS
Hardware / network configuration, and filesystems used.
Irrelevant.
How much data is handled by borg?
Irrelevant.
Full borg commandline that lead to the problem (leave away excludes and passwords)
borg create \
--verbose \
--filter AME \
--list \
--stats \
--compression lz4 \
--exclude '.viminfo' \
/tmp/borgtest/::'{now}' \
/home/
Describe the problem you're observing.
I'd expect that any file named .viminfo is excluded from the backup.
Can you reproduce the problem? If so, describe how. If not, describe troubleshooting steps you took before opening the issue.
It always happens when you don't specify a path but only a filename.
Include any warning/errors/backtraces from the system logs
No warnings, but i see .viminfo included in the list of archived files:
A /home/mike/.bash_logout
A /home/mike/.profile
A /home/mike/.bashrc
A /home/mike/.bash_history
A /home/mike/.viminfo
Did you see the man page borg-patterns, which explains the different types of exclusion specifiers?
Yes, of course. I've studied it several times - but obviously I'm missing something. In my understanding as *.o excludes any file with extension .o I'd expect that I can also use a full filename (any string without slashes).
I'm not an expert on the selection patterns but I think you should try --exclude '*.viminfo'
... the issue being that, from Borg's point of view, .viminfo and /home/mike/.viminfo are different paths.
borg help patterns says:
For a path to match a pattern, the full path must match, or it must match
from the start of the full path to just before a path separator.
So */.viminfo would probably be the best for your use case.
Oh, I see now. So *.o basically matches all .o files because it matches /bla.o, /x/bla.o, /x/y/bla.o, etc.
Maybe it's worth adding this to the example section?
TODO: check if we have examples for this.
Current 1.4-maint docs have this example:
# Backup home directories excluding image thumbnails (i.e. only
# /home/<one directory>/.thumbnails is excluded, not /home/*/*/.thumbnails etc.)
$ borg create /path/to/repo::my-files /home \
--exclude 'sh:home/*/.thumbnails'
Also the fnmatch docs say:
`Fnmatch <https://docs.python.org/3/library/fnmatch.html>`_, selector `fm:`
This is the default style for ``--exclude`` and ``--exclude-from``.
These patterns use a variant of shell pattern syntax, with '\\*' matching
any number of characters, '?' matching any single character, '[...]'
matching any single character specified, including ranges, and '[!...]'
matching any character not specified. For the purpose of these patterns,
the path separator (backslash for Windows and '/' on other systems) is not
treated specially. Wrap meta-characters in brackets for a literal
match (i.e. `[?]` to match the literal character `?`). For a path
to match a pattern, the full path must match, or it must match
from the start of the full path to just before a path separator. Except
for the root path, paths will never end in the path separator when
matching is attempted. Thus, if a given pattern ends in a path
separator, a '\\*' is appended before matching is attempted. A leading
path separator is always removed.
So:
*matches any number of chars, including slashes- the full path must match