LVM and runtime dir exclusion #1203
Labels
No labels
blocked
breaking
bug
data loss
design finalized
good first issue
new feature area
question / support
security
waiting for response
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
borgmatic-collective/borgmatic#1203
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
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
In the aftermath of #1122, I now am finding that LVM snap based backups "silently"ish soft fail when runtime dir is inadvertently excluded.
Steps to reproduce
This config:
cron/tmpfor runtime:Using runtime directory /tmp/borgmatic-4ams1w6c/borgmatic/tmpis obviously excluded as aboveActual behavior
Snaps etc are created, but the resulting archive only has:
This obviously happens because the LVM snap is mounted under
/tmp/borgs_runtime_dir.Expected behavior
I had kinda expected #1122 to error out; the context of that bug of course was manifest, but ... yeah.
Other notes / implementation ideas
Though I get why a sane fallback to
/tmpfor runtime, I also don't want to backup/tmp, so this'll make for a fascinating series of pattern includes/excludes 😉borgmatic version
2.0.12
borgmatic installation method
pipx
Borg version
borg 1.4.3
Python version
Python 3.13.5
Database version (if applicable)
No response
Operating system and version
PRETTY_NAME="Debian GNU/Linux 13 (trixie)" NAME="Debian GNU/Linux" VERSION_ID="13" VERSION="13 (trixie)" VERSION_CODENAME=trixie DEBIAN_VERSION_FULL=13.2 ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"A few thoughts:
Are you sure that the reason the archive is missing LVM snapshots is because
/tmpis excluded? I see that you have'! tmp'in the excludes, but I would not expect that to match anything unless: 1. borgmatic was run from the/directory or 2. theworking_directorywas set to/.I know that you have
R /as a root pattern, but my understanding is that that subsequent exclude patterns aren't automatically relative to the root. You'd have to specify an absolute path like! /tmp(or usingworking_directoryor whatever).So if these excludes are invalid, then why doesn't all of
/end up in the archive? That I don't know. Can I see the portion of the verbose borgmatic output that prints out the processed patterns that borgmatic is sending to Borg?I'm sure. I actually saw borg output the exclusion using the progress/list option. I've lost it in my scrollback, but there was definitely a:
... that covered the whole snap mount.
Re the leading slashes -- I tried both, and was using leading up until this issue (which was all brought about/broken by me upgrading to Debian 13, and I still don't know why this broke my backups overall).
I ended up with removing the leaders because of this example in the borg doco:
Yeah, see above. It worked with them just fine before upgrading. The same behaviour is exhibited either way. I also tried:
borgandborgmaticto the versions I was using before the trixie upgradeSure, but it wasn't helpful to me:
Debugging was further confused due to me fault-finding using a shell, vs it normally running via
cron, which of course changed the runtime dir from/run/user/0to/tmprespectively. The paste above was from an interactive.The only thing that revealed exclusion was using
-v2 -n create -c /etc/borgmatic.d/myconfig.yaml --list. Whilst interactive, commenting out the/runline fixed it.And now, commenting out the
/tmpline and scheduling a cron run fixed it too, confirming my suspicions.Something weird with the dot slash hack? I dunno.
Thanks for details and the explanation about the leading slashes. I guess because Borg doesn't store leading slashes as part of archive paths, it may not need them in patterns either.
Fun fact: Debian 13 changed
/tmpto usetmpfs, which earlier Debian versions didn't. (/runis alsotmpfs, but that may have already been the case.) But I'm assuming you don't haveone_file_systemset in your config file, so the Debian change should hopefully not impact anything here. Maybe though the Debian upgrade changed some of the inputs to the runtime directory path determination.In any case, there are four checks gating the error you were expecting about the runtime directory. All have to evaluate as true in order to produce that error:
Looking at your computed patterns, check number 1 looks to be satisfied. And I'm guessing checks 3 and 4 are true as well. So that leaves check 2. Given that the bootstrap directory is getting included in the archive, that leads me to believe that at least some portion of the runtime directory was in the paths that Borg planned to backup. And that's consistent with the computed patterns, in which the bootstrap directory gets inserted before any user excludes.
So, code-wise, that explains why you're not receiving the error you expect. The borgmatic runtime directory is only getting partially excluded from the Borg archive, and therefore the error doesn't trigger.
I'll need to think about what if anything I can do about this.
Okay, this is fixed in main and will be part of the next release. Previously, you only got the runtime directory error if all patterns inside the runtime directory got excluded. Now, you'll get the error if any patterns inside the runtime directory get excluded.
One other note though on the topic of leading slash paths in your patterns. I do recommend using leading slashes there, because otherwise borgmatic can't tell if a pattern is intended to represent an absolute or relative path. And due to that, borgmatic won't rewrite any exclude patterns such that they apply to rewritten LVM snapshots paths—meaning that some of your excludes won't get applied.
Anyway, thanks for bringing this to my attention!
Noted re leading slashes!
Dan, always a pleasure to work with you. I really appreciate your politeness, the time you take with issues, and the responsiveness. As silly as this sounds, I enjoy logging issues with you 😉.
borgmaticis awesome, and you are a great example to the open source community.Thank you so much for the kind words. I really appreciate it! 😊 Keep on filing your extensively detailed tickets whenever you come across problems.
Released in borgmatic 2.0.13!
FYI the approach here caused an issue with a different use case, so the precise check needed some updates. I also downgraded the error to a warning. See #1211 for more information.