Database backup runtime directory error #999

Closed
opened 2025-02-17 19:35:14 +00:00 by sean-wallace · 8 comments

What I'm trying to do and why

I can't seem to get any combination of runtime_directory and database backups to work since this change that went out in 1.9.5.

It always triggers the ValueError below pretty much whatever I do.

raise ValueError(
    f'The runtime directory {os.path.normpath(borgmatic_runtime_directory)} overlaps with the configured excludes. Please remove it from excludes or change the runtime directory.'
)

Any ideas?

Steps to reproduce

No response

Actual behavior

No response

Expected behavior

No response

Other notes / implementation ideas

No response

borgmatic version

1.9.5-1.9.10

borgmatic installation method

pip install, homebrew

Borg version

1.4.0

Python version

3.12.9

Database version (if applicable)

No response

Operating system and version

No response

### What I'm trying to do and why I can't seem to get any combination of runtime_directory and database backups to work since [this change](https://projects.torsion.org/borgmatic-collective/borgmatic/commit/267af5b372cd28025d2db286ca4cd8cb9bf51b71) that went out in 1.9.5. It always triggers the ValueError below pretty much whatever I do. ``` raise ValueError( f'The runtime directory {os.path.normpath(borgmatic_runtime_directory)} overlaps with the configured excludes. Please remove it from excludes or change the runtime directory.' ) ``` Any ideas? ### Steps to reproduce _No response_ ### Actual behavior _No response_ ### Expected behavior _No response_ ### Other notes / implementation ideas _No response_ ### borgmatic version 1.9.5-1.9.10 ### borgmatic installation method pip install, homebrew ### Borg version 1.4.0 ### Python version 3.12.9 ### Database version (if applicable) _No response_ ### Operating system and version _No response_
Owner

Can I get a look at your configuration and excludes to help diagnose this? Also, when you run borgmatic with --verbosity 2, what is the runtime directory displayed? It should show up on line that says: "Using runtime directory ..."

Thanks!

Can I get a look at your configuration and excludes to help diagnose this? Also, when you run borgmatic with `--verbosity 2`, what is the runtime directory displayed? It should show up on line that says: "Using runtime directory ..." Thanks!
Author

Sure, slightly truncated config:

source_directories:
    - ~/Desktop
    - ~/Documents
    - ~/Downloads
    - ~/projects

repositories:
    - path: /Volumes/SW Backup/borg
      label: swbackup

exclude_patterns:
    - '*.pyc'

exclude_if_present:
    - .nobackup

keep_exclude_tags: true

extra_borg_options:
    create: --list --filter=AME --stats

    prune: --list --stats

postgresql_databases:
    - name: all

And the runtime directory line is showing as Using runtime directory /var/folders/h3/hh7xwqyj3bxdjdlkpnqlyl940000gp/T/borgmatic-499_rck4/borgmatic

Sure, slightly truncated config: ``` source_directories: - ~/Desktop - ~/Documents - ~/Downloads - ~/projects repositories: - path: /Volumes/SW Backup/borg label: swbackup exclude_patterns: - '*.pyc' exclude_if_present: - .nobackup keep_exclude_tags: true extra_borg_options: create: --list --filter=AME --stats prune: --list --stats postgresql_databases: - name: all ``` And the runtime directory line is showing as `Using runtime directory /var/folders/h3/hh7xwqyj3bxdjdlkpnqlyl940000gp/T/borgmatic-499_rck4/borgmatic`
Author

@witten Is there a chance that the if not skip_paths condition should be if skip_paths? I will admit I don't fully understand the point of what it's doing, but it seems like it might be backwards to me.

@witten Is there a chance that the `if not skip_paths` condition should be `if skip_paths`? I will admit I don't fully understand the point of what it's doing, but it seems like it might be backwards to me.
Owner

And the runtime directory line is showing as Using runtime directory /var/folders/h3/hh7xwqyj3bxdjdlkpnqlyl940000gp/T/borgmatic-499_rck4/borgmatic

Interesting, yeah, I don't see anything in your config that would obviously overlap the runtime directory. One thing you can do is look at the output of a borgmatic create run with --files (which you might not actually need since you've already got --list --filter=AME in your extra_borg_options). That should display exactly what's being excluded (via the x prefix). To temporarily get past the error so you can see that, you can add --dry-run which should suppress the ValueError. (See below!)

@witten Is there a chance that the if not skip_paths condition should be if skip_paths? I will admit I don't fully understand the point of what it's doing, but it seems like it might be backwards to me.

That code is pretty tricky, and maybe needs better commenting and/or variable naming. What's going on is that paths is the list of all file paths to backup as determined by a Borg create dry run—file paths that have not been otherwise excluded. Then skip_paths is the subset of those files paths contained by the borgmatic runtime directory. If there are none (if not skip_paths:), that means somewhere along the way, the borgmatic runtime directory (which gets auto-included by borgmatic) got excluded by the user (e.g. via exclude_patterns or similar), and therefore we should error.

Phew.

So. Seeing your excludes would help determine what if anything is causing the runtime directory to get excluded. It's also possible, of course, that something is going wrong in the logic described above.

...

Hold up! I just tried your extra_borg_options: locally, specifically the create, and even more explicitly the --filter=AME and got a repro of your error! I think what's going on is that the --filter=AME is getting passed to the internal borgmatic borg create --dry-run in that function (collect_special_file_paths()) and causing the dry-run output to list zero file paths—which triggers the error above because it thinks the borgmatic runtime directory has been excluded.

Temporarily, I think you can remove --filter AME and that should let you bypass the error. But in terms of fixing this for real, I think I need to make this function ignore or override any user --filter options so as not to inadvertently trigger the error.

> And the runtime directory line is showing as Using runtime directory /var/folders/h3/hh7xwqyj3bxdjdlkpnqlyl940000gp/T/borgmatic-499_rck4/borgmatic ~~Interesting, yeah, I don't see anything in your config that would obviously overlap the runtime directory. One thing you can do is look at the output of a `borgmatic create` run with `--files` (which you might not actually need since you've already got `--list --filter=AME` in your `extra_borg_options`). That should display exactly what's being excluded (via the `x ` prefix). To temporarily get past the error so you can see that, you can add `--dry-run` which should suppress the ValueError.~~ (See below!) > @witten Is there a chance that the if not skip_paths condition should be if skip_paths? I will admit I don't fully understand the point of what it's doing, but it seems like it might be backwards to me. That code is pretty tricky, and maybe needs better commenting and/or variable naming. What's going on is that `paths` is the list of all file paths to backup as determined by a Borg `create` dry run—file paths that have not been otherwise excluded. Then `skip_paths` is the subset of those files paths contained by the borgmatic runtime directory. If there are none (`if not skip_paths:`), that means somewhere along the way, the borgmatic runtime directory (which gets auto-included by borgmatic) got excluded by the user (e.g. via `exclude_patterns` or similar), and therefore we should error. Phew. ~~So. Seeing your excludes would help determine what if anything is causing the runtime directory to get excluded. It's also possible, of course, that something is going wrong in the logic described above.~~ ... Hold up! I just tried your `extra_borg_options:` locally, specifically the `create`, and even more explicitly the `--filter=AME` and got a repro of your error! I think what's going on is that the `--filter=AME` is getting passed to the internal borgmatic `borg create --dry-run` in that function (`collect_special_file_paths()`) and causing the dry-run output to list zero file paths—which triggers the error above because it thinks the borgmatic runtime directory has been excluded. Temporarily, I think you can remove `--filter AME` and that should let you bypass the error. But in terms of fixing this for real, I think I need to make this function ignore or override any user `--filter` options so as not to inadvertently trigger the error.
witten added the
bug
label 2025-02-17 21:57:31 +00:00
Author

Yep, removing the --filter=AME works! I also removed --list so it didn't take forever to run. Thanks very much for figuring it out!

Yep, removing the `--filter=AME` works! I also removed `--list` so it didn't take forever to run. Thanks very much for figuring it out!
Owner

Thanks for your detailed repro info! That definitely helped. Okay, I'll work on coming up with a fix so you can add back --filter=AME if you want.

Thanks for your detailed repro info! That definitely helped. Okay, I'll work on coming up with a fix so you can add back `--filter=AME` if you want.
Owner

I went ahead and implemented a fix for this. It turned out that argparse was probably overkill, and instead I managed to iterate through the arguments such that I could filter out both --filter and its value. Thanks again for your help here!

The fix will be part of the next release.

I went ahead and implemented a fix for this. It turned out that `argparse` was probably overkill, and instead I managed to iterate through the arguments such that I could filter out both `--filter` and its value. Thanks again for your help here! The fix will be part of the next release.
witten referenced this issue from a commit 2025-02-22 22:32:59 +00:00
Owner

Released in borgmatic 1.9.11!

Released in borgmatic 1.9.11!
Sign in to join this conversation.
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

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