Need help with exclude_patterns #453

Closed
opened 2021-09-15 09:26:39 +00:00 by auanasgheps · 4 comments

What I'm trying to do and why

I want to set up a filter to exclude some files, like WhatsApp DBs that have dates in the filename, like
msgstore-2021-09-15.1.db.crypt14.

The filter I've come up with is msgstore-20*.* which works if I search for files in WinSCP, but does not work in borgmatic/borg because these files are still included in my backups.

I don't want to exclude all crypt14 files because I want to backup another WhatsApp DB which has the same extension but different file name.

I'm sure I am making a very dumb mistake because a simple filter works, like if I exclude a full path (e.g. a temp folder).

I think this issue also applies to the other files I'm trying to exclude when using asterisks.

borgmatic

Steps to reproduce (if a bug)

Here's the relevant configuration. The first two folder patterns work, the others not really.

exclude_patterns:
    - /srv/dev-disk-by-label-nvme/docker-install
    - /srv/dev-disk-by-label-nvme/docker-apps
    - '*/lost+found'
    - 'thumbs.db'
    - 'Thumbs.db'
    - '$RECYCLE.BIN'
    - 'System Volume Information'
    - 'msgstore-20*.*'
    - 'Folder.jpg'
    - 'AlbumArt*.jpg'

Actual behavior (if a bug)

Expected behavior (if a bug)

Other notes / implementation ideas

I'm not sure what I'm doing wrong, but there are no very good examples to do this kind of exclusions, neither in Borgbackup docs.

Environment

borgmatic version: 1.5.12

borgmatic installation method: Debian Package

Borg version: 1.1.15

Python version: Python 3.7.3

Database version (if applicable): N/A

operating system and version: Debian 10 (OpenMediaVault 5.x)

#### What I'm trying to do and why I want to set up a filter to exclude some files, like WhatsApp DBs that have dates in the filename, like msgstore-2021-09-15.1.db.crypt14. The filter I've come up with is `msgstore-20*.*` which works if I search for files in WinSCP, but does not work in borgmatic/borg because these files are still included in my backups. I don't want to exclude all crypt14 files because I want to backup another WhatsApp DB which has the same extension but different file name. I'm sure I am making a very dumb mistake because a simple filter works, like if I exclude a full path (e.g. a temp folder). I think this issue also applies to the other files I'm trying to exclude when using asterisks. ![borgmatic](/attachments/c21d85fd-4acc-42e0-a1ea-3da52caf0c4d) #### Steps to reproduce (if a bug) Here's the relevant configuration. The first two folder patterns work, the others not really. ``` exclude_patterns: - /srv/dev-disk-by-label-nvme/docker-install - /srv/dev-disk-by-label-nvme/docker-apps - '*/lost+found' - 'thumbs.db' - 'Thumbs.db' - '$RECYCLE.BIN' - 'System Volume Information' - 'msgstore-20*.*' - 'Folder.jpg' - 'AlbumArt*.jpg' ``` #### Actual behavior (if a bug) #### Expected behavior (if a bug) #### Other notes / implementation ideas I'm not sure what I'm doing wrong, but there are no very good examples to do this kind of exclusions, neither in Borgbackup docs. #### Environment **borgmatic version:** 1.5.12 **borgmatic installation method:** Debian Package **Borg version:** 1.1.15 **Python version:** Python 3.7.3 **Database version (if applicable):** N/A **operating system and version:** Debian 10 (OpenMediaVault 5.x)
Owner

Thanks for taking the time to file this! (Sorry nobody got to your question on IRC.) Looking at the Borg docs on exclude patterns, there's one sentence in particular that stands out to me as potentially relevant: "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." I think what this means is that if your pattern is an absolute path or starts with a glob, then it'll match a full path properly. On the other hand, if your pattern does not begin with an absolute path and does not start with a glob, then it can't match a full path. If that's the case, then, msgstore-20*.* wouldn't match anything.

So how to fix this? Couple of options:

  • */msgstore-20*.*
  • sh:**/msgstore-20*.* (untested)
  • re:^.*/msgstore-20.*\..*$ (untested)

Give something along those lines a shot and let me know how they work for you!

Thanks for taking the time to file this! (Sorry nobody got to your question on IRC.) Looking at the [Borg docs on exclude patterns](https://borgbackup.readthedocs.io/en/stable/usage/help.html), there's one sentence in particular that stands out to me as potentially relevant: "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." I think what this means is that if your pattern is an absolute path or starts with a glob, then it'll match a full path properly. On the other hand, if your pattern does not begin with an absolute path and does not start with a glob, then it can't match a full path. If that's the case, then, `msgstore-20*.*` wouldn't match anything. So how to fix this? Couple of options: * `*/msgstore-20*.*` * `sh:**/msgstore-20*.*` (untested) * `re:^.*/msgstore-20.*\..*$` (untested) Give something along those lines a shot and let me know how they work for you!
witten added the
question / support
label 2021-09-15 16:22:06 +00:00
Author

Sorry nobody got to your question on IRC.

Thanks for letting me know but I would have never seen a reply: I signed in as guest and when I refreshed the page my m messages were cleared...

Thanks for the patterns! I will try the first one. On saturday my backup will run and I'll be able to report back. I will also change all the others accordingly.

> Sorry nobody got to your question on IRC. Thanks for letting me know but I would have never seen a reply: I signed in as guest and when I refreshed the page my m messages were cleared... Thanks for the patterns! I will try the first one. On saturday my backup will run and I'll be able to report back. I will also change all the others accordingly.
Author

I'm happy to confirm that */msgstore-20*.* made the trick! Thank a lot!

I'm happy to confirm that `*/msgstore-20*.*` made the trick! Thank a lot!
Owner

Awesome, so glad to hear it! I've updated the examples in the configuration file to include a pattern like this one.

Awesome, so glad to hear it! I've updated the examples in the configuration file to include a pattern like this one.
Sign in to join this conversation.
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: borgmatic-collective/borgmatic#453
No description provided.