Is it possible to run two borgmatic instances in parallel, both using LVM snapshots? #957
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 assignees
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
borgmatic-collective/borgmatic#957
Loading…
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
Thanks for all your wonderful work!
I've tested the new
lvmsnapshot feature, and it's awesome!I usually run two borgmatic instances at the same time to parallelize backups to two different repositories, each with its own password (one local storage, the other remote).
Steps to reproduce
Run two borgmatic instances in parallel, both using LVM snapshots.
Actual behavior
I noticed the following error in the second borgmatic instance after the first one is completed:
Expected behavior
No response
Other notes / implementation ideas
Could the first complete borgmatic instance have removed the snapshots/mounted
tree created by the second one before its completion? This line seems to target all snapshots created by borgmatic, not the one specific of the running instance?
borgmatic version
1.9.4
borgmatic installation method
pipx
Borg version
1.4.0
Python version
3.13.1
Database version (if applicable)
No response
Operating system and version
NAME="Arch Linux" PRETTY_NAME="Arch Linux" ID=arch BUILD_ID=rolling ANSI_COLOR="38;2;23;147;209" HOME_URL="https://archlinux.org/" DOCUMENTATION_URL="https://wiki.archlinux.org/" SUPPORT_URL="https://bbs.archlinux.org/" BUG_REPORT_URL="https://gitlab.archlinux.org/groups/archlinux/-/issues" PRIVACY_POLICY_URL="https://terms.archlinux.org/docs/privacy-policy/" LOGO=archlinux-logo
I'm glad to hear that the new LVM hook is (mostly) working for you! In terms of running two borgmatic instances in parallel, it's unfortunately not intentionally designed for that currently—not just in the LVM hook but throughout the rest of the application code as well. So in your particular case, yes, one borgmatic instance is removing snapshots created by the other instance. This is actually somewhat intentional; the idea is that there may be snapshots leftover from a prior borgmatic run that errored out, snapshots that we don't want to leave littering the filesystem forever.
A few ideas I can think of for addressing this:
archive_name_formatoption when removing old snapshots. The idea is that each borgmatic run could use a configuration file with a differentarchive_name_format, putting that value into each snapshot path. And then that instance of borgmatic could be responsible for cleaning up a different subset of named snapshots.In any case, there would probably have to be an audit of the whole borgmatic source code as well to make sure that multiple simultaneous processes are really supported. Off the top of my head, I can imagine that things will break or not break depending on the configured or defaulted user runtime directory. Specifically, if borgmatic is using a path in
/tmpfor the runtime directory, that will conveniently use a differently named path in each borgmatic process. But if using something like/run/user/1234/borgmatic, there could be path collisions between processes.Thanks for your kind reply! 🙏 I'll run borgmatic instances sequentially from now on. 👍
I just lost a couple of hours trouble-shooting weird issues where files were not available anymore from Btrfs-snapshots. I had been running multiple Borgmatic processes in parallel because I wanted to speed up the backing up of multiple separate LXC-containers, each with a config file of its own. The background information by @witten explains the behavior perfectly well.
I only wish I had known this before! Do you see a good point to include this in the (excellent!) docu? Maybe on the page How to make per-application backups?
Sorry to hear you lost a couple hours troubleshooting! Great suggestion.. I've just added a note about this to the per-application backups docs, which should be live shortly.
Thanks a lot for including this and more explanations to the docs!