Creating backup of sqlite database when running Borgmatic as systemd service fails #1276
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
3 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
borgmatic-collective/borgmatic#1276
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
I have a VPS with a SQLite database. I want to create a back up of it every night using Borgmatic. The backup works correctly when running
borgmaticmanually, but fails, when Borgmatic is triggered as a systemd service.When running
borgmaticmanually and listing the files of the newest archive, the filerun/borgmatic/sqlite_databases/localhost/gotosocialhas a reasonable size of several GB, but when triggered the from systemd, the db file content is:Steps to reproduce
The SQLite database is
/gotosocial/sqlite.dband belongs to the usergotosocial. The systemd service is run as root.Attaching my borgmatic config file located at
/etc/borgmatic/(I had to change the file extensions to txt to be able to upload them). As described above, the systemd service is being run every night, triggered by the systemd timer.Actual behavior
This is the output of
sudo journalctl -u borgmatic:Expected behavior
I would like to have a reliable way to back up my sqlite database.
Other notes / implementation ideas
No response
borgmatic version
2.0.5
borgmatic installation method
pipx
Borg version
1.2.8
Python version
3.12.3
Database version (if applicable)
3.45.1 2024-01-30 16:01:20 e876e51a0ed5c5b3126f52e532044363a014bc594cfefa87ffb5b82257ccalt1 (64-bit)
Operating system and version
Ubuntu 24.04.3 LTS
Thanks for the detailed ticket. A few thoughts:
--verbosity 2and looking for a log line like:Using runtime directory .... The path listed there is likely the path that borgmatic under systemd can't write to. You're running as root though, so the problem shouldn't be a file permission issue.LockPersonalitythroughCapabilityBoundingSet. Don't forget to reload your systemd daemon..yamlfiles directly without a rename.Thank you for your reply. So far I have turned off all of the security measures in the systemd file and that still did not fix the issue. I will continue to investigate the issue when I have a bit more time. I think I'll also try changing the runtime directory? I'll update the ticket once I find anything interesting. Thanks again for your help :)
Yeah, you could try changing the runtime directory in case it's at a path where you don't have write permission when run under systemd. And I assume after making the service changes, you did a
systemctl daemon-reload?I'm running into this problem as well. I'm getting some weird filesystem paths:
I have the following in my config:
That
/./borgmaticlooks out of place to me. That command however does work, as long as Imkdir -p /data/borgmatic/runtime/./borgmatic/sqlite_databases/localhostfirst.However, watching the
/data/borgmatic/runtimedirectory, I never see aborgmatic/sqlite_databases/localhostdirectory getting created. That would then also cause the dump to fail, since it's redirecting the output to a location that doesn't exist.Borgmatic: 2.1.3
SQLite: 3.52.0 2026-03-06 16:01:44 557aeb43869d3585137b17690cb3b64f7de6921774daae9e56403c3717dcalt1 (64-bit)
That destination path actually appears correct to me. The
/./portion is borgmatic leveraging a Borg 1.4+ feature (often called the "slashdot hack") that means anything before and including the/./gets stripped off before the path gets stored in the archive. It's handy for backing up a file at a particular path but storing it as something else. In this case, the file would get stored in the Borg archive as justborgmatic/sqlite_databases/localhost/gotosocial.You shouldn't have to manually
mkdirany directories though.It's possible that the directory gets created and deleted too quick to see it. borgmatic creates the directory before dumping and cleans it up after the Borg backup.
Some questions: