Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support general patterns #1991

Open
TheRealDarklord opened this issue Apr 19, 2024 · 4 comments
Open

support general patterns #1991

TheRealDarklord opened this issue Apr 19, 2024 · 4 comments
Labels
type:feature New functionality

Comments

@TheRealDarklord
Copy link

The problem

Currently i cannot exclude a directory and then include a subdirectory of that excluded one in the backup as Vorta supports exclude patterns only.

Requested Solution

As written in the explanation to borg patterns (https://borgbackup.readthedocs.io/en/stable/usage/help.html#borg-patterns) borg supports include and exclude patterns if it is used with the "right" argument. Vorta uses the exclude-argument which prevents the usage of include patterns.

So the requested solution would be to allow the usage of the more general patterns instead of the exclude-option solely.

Alternatives

The alternative with current capabilities would be to explicitly add all subdirectories and files of my home directory without the games dir. In addition I would then select the specific paths within the games directory. This way I could work around the exclusion of "games" and have its targeted subdirectories included.
The downside is that any new directory in my home directory needs to be added manually in Vorta. So it's not a viable alternative imho.

Additional context

I use Vorta to backup my home directory. In my home directory is a subdirectory for my installed games. I do not want to include those gigabytes of game files within the backup so naturally I exclude that subdirectory. But I DO want to backup specific game related files, e.g. savegames and settings. These reside in various subdirectories of the games directory.

@SAMAD101 SAMAD101 added the type:feature New functionality label Apr 24, 2024
@quercus-carsten
Copy link

I think I am in the same situation. I wanted to backup my linux home directory without the "." files and folders. But there are exceptions like ".ssh", ".profile", ".bashrc" which I'd like to keep.
So I added those into vorta "sources" but didn't get the expected result. Seems like "excluded items" overrule my includes.

If I understand the borg documentation correctly then you could potentially work with "+" and "-" to mark include and exclude rules. By orderly assembling them you could go ahead and e. g. make specific includes in a directory followed by a general exclude - like:

# keep some dot files and dot folders
+ home/foobar/.ssh
+ home/foobar/.bashrc
+ home/foobar/.profile

# get rid of the rest which begins with a dot
- home/foobar/[.][a-zA-Z0-9]*

# backup home
+ home/foobar/[a-zA-Z0-9]*

If that's general patterns , then I would like this feature too.

I think having a separate sources tab and menu for exclusions maybe wouldn't fit in this usecase... Why not have a "raw" rules (general patterns?) tab, which can be filled like the example above to have includes and excludes together in one place. This way you would be able to manage the order of your rules.

@luckyrat
Copy link

Another alternative until the Vorta UI supports this use case is to supply the necessary parameters directly to the borg command.

  1. In the "Schedule" tab and then the "Shell Commands" section...
  2. Enter --pattern parameters into the "Extra parameters for borg create"
  3. List all folders/files you want to include first with the + prefix and then all the higher level folders that you want to exclude using the - prefix.

For example:

--pattern=+/path/to/games/saved-games/ --pattern=+/path/to/games/settings/ --pattern=-/path/to/games/

Although I've only tested the above example, you should be able to use all the patterns listed in the borg documentation and thus create more complex exclusions than this example (such as including any folder called "saved-games" no matter how deep in the folder hierarchy it is found).

Don't forget to remove the exclusion from the main list of exclusions in the "Sources" tab if you've had it there previously.

@goebbe
Copy link
Contributor

goebbe commented Sep 17, 2024

And finally, here is a comment on the use of --patterns-from, which allows providing a list of patterns.
This is convenient if you define many patterns.

  1. In the "Schedule" tab and then the "Shell Commands" section...
  2. Enter --patterns-from /pathto/my_patterns_example.lst into the "Extra parameters for borg create"
  3. Use the advanced features of --patterns-from when defining your pattern list. :-)

Example for my_pattern_example.lst:

## This file defines exclusions and inclusions for --patterns-from
##   + is included,  - is excluded,  ! is definitely excluded (all subdirectories ignored, no include possible) 
##   Order matters! Put the includes at the top of the file

## P defines the pattern style
## "sh:" is the default pattern style when using --patterns-from, so the following line is not required:
#P sh

## R sets the root(s) for the backup. If you opt to set the root(s) here, then the "Sources" in Vorta UI will be ignored! 
#R /home/username

## include Thunderbid user data, but first exclude the Thunderbird cache*
- home/username/.thunderbird/*/calendar-data/cache*
+ home/username/.thunderbird

## include a specific file,  using an efficient "path full" matcher:
+ pf:home/username/.hidden/file.txt

## exclude all hidden files and folders (if not included above):
- home/username/**/.*

## exclude "test folder" with a single space in the name (only works in a pattern-file) 
- home/user/test folder

## exclude "test folder2" with a single space \s in the name, using re:  (regular expression)
- re:home/username/test\sfolder2

## exclude files by file extensions - e.g. if they are redundant :
! home/username/**/*.iso

## exclude .cache files and folders:
! home/username/**/.cache

## exclude the following list of folders and their subdirectories:
! home/username/**/vortamountpoint
! home/username/bin
! home/username/Downloads
! home/username/Syncthing

Using --patterns-from, we can easily include some specific hidden files and folders, even though hidden files are generally excluded,.
It is also possible to add complex regular expressions. But as a general rule: the more explicit you are, the faster is the pattern matching.

@goebbe
Copy link
Contributor

goebbe commented Dec 5, 2024

From the discussions, it seems that the support of "includes" is a feature desired/ required by some users:
discussion #2156, discussion #2089, discussion #1901
"Includes" are supported by borgbackup, but require the use of --pattern or --patterns-from
Currently, Vortas (0.10.1) "Manage excluded items"-feature use --exlude or --exclude-from in the background, which do no support the use of "includes".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:feature New functionality
Projects
None yet
Development

No branches or pull requests

5 participants