borgmatic hangs when location.patterns includes /root/.borgmatic and database hooks are active #582
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What I'm trying to do and why
Trying to use database hooks while
location.patternscontainsR /root.Steps to reproduce (if a bug)
Actual behavior (if a bug)
The last step in the reproduction section will hang forever as follows:
Expected behavior (if a bug)
The backup should complete as usual.
Other notes / implementation ideas
The patterns file generated by borgmatic looks like this:
Apparently this causes borg to attempt to backup the pipes in
/root/.borgmatic/*_databasestwice. One time as a subdirectory ofR /rootand a second time forR /root/.borgmatic.straceing the borg process reveals that the process is indeed stuck on trying to open one of the named pipes:Watching the output of
--progresson a sufficiently large database, it is visible that borg makes a backup of the pipe once and later tries to open the pipe again and gets stuck.Apparently this doesn't happen when using
locations.source_directoriesinstead. My guess is that borg deduplicates directories passed on the command line, but doesn't deduplicate roots passed in patterns.This might be related to #578, but isn't solvable by deleting the pipes manually, since the error state is reproducibly generated by borgmatic at startup.
Environment
borgmatic version: 1.7.1
borgmatic installation method: pip
Borg version: 1.2.2
Python version: 3.10.7
Database version (if applicable): 14.5 (but probably not relevant)
operating system and version: Docker container docker.io/library/python:3-bullseye
Ugh! Thank you for reporting this and providing all the details. Borg actually doesn't deduplicate
source_directoriesat all—but borgmatic does! Unfortunately nothing is deduplicating the contents ofpatterns. So I guess that's a new thing borgmatic will need to do as part of this ticket. Or at least make sure not to add~/.borgmaticif a parent directory is already present inpatterns.~/.borgmaticgetting injected intopatterns(when used) was introduced by #574 to work around a Borg bug.I've just pushed a fix for this to master. The gist is that
patternroot directories are now considered when injecting~/.borgmaticintopatterns—it won't get injected if a parent/grandparent/etc directory is already present as a root directory inpatterns. The caveat is that non-root patterns are not considered; borgmatic isn't trying to parse through+ /thisand- /that, so it is still possible to hang yourself. It's just less likely unless you explicitly try to do so.Thanks again for reporting this! Release forthcoming.
Just released in borgmatic 1.7.2!