borg icon indicating copy to clipboard operation
borg copied to clipboard

read patterns for current directory from --patterns-if-present

Open VolkerGoetz opened this issue 7 years ago • 0 comments

The problem with --exclude-if-present is that there is no fine grained control over what is included or excluded from the directory where the file/dir is present, it's just all or nothing (with the exception of the tag file itself).

Suppose you have a coding project where you want to exclude the output directories/files from the backup (e.g. the .o files from C/C++ or the .class files from Java). Or you have some directory structure with data that is located beneath a directory maindir and you occasionally create some ZIP archives in maindir too that you do not want to have backed up. Excluding all ZIP files from the backup may not be what one wants and adding everything to a host-global exclude list is cumbersome.

If there was a local .borgbackup.patterns, one could define the excludes relative for the current directory, e.g. a file javaproject/.borgbackup.patterns with the following contents:

P sh
- out/*.class
- *.zip

would exclude these files from the backup:

javaproject/out/DontBackup.class
javaproject/snapshot.zip

The locally defined includes/excludes would be prefixed by the currently processed dir. That means out/*.class would effectively be /path/to/javaproject/out/*.class

VolkerGoetz avatar Jul 29 '18 16:07 VolkerGoetz