Sqlite backup fails #1290

Open
opened 2026-03-31 08:00:21 +00:00 by zjean · 3 comments

What I'm trying to do and why

I have the same issue as is mentioned in the comments of #1276, but since that issue seems to originate from something else, I decided to write my own.
I try to backup sqlite databases on my docker host, by mounting a root folder into my borgmatic container.
This has worked for a long time, but got broken in a recent version

Steps to reproduce

regular sqlite database backup config in the configuration yaml

Actual behavior

external-disk: Command 'sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump > /tmp/borgmatic-ovsfb6j3/./borgmatic/sqlite_databases/localhost/mosquitto' returned non-zero exit status 1.

external-disk: Creating archive at "/mnt/borg-repository::borgmatic-backup-2026-03-31T09:44:31.checkpoint"
external-disk: Verified integrity of /root/.cache/borg/a65edc89381d46f49b666735612e29c96a1a0ba9d554a9e8c42dde40e05722d6/chunks
external-disk: Reading files cache ...
external-disk: Verified integrity of /root/.cache/borg/a65edc89381d46f49b666735612e29c96a1a0ba9d554a9e8c42dde40e05722d6/files
external-disk: security: read previous location '/mnt/borg-repository'
external-disk: security: read manifest timestamp '2026-03-24T00:35:46.140715'
external-disk: security: determined newest manifest timestamp as 2026-03-24T00:35:46.140715
external-disk: security: repository checks ok, allowing access
external-disk: Processing files ...
external-disk: Cleaned up 1 uncommitted segment files (== everything after segment 20932).
external-disk: Verified integrity of /mnt/borg-repository/hints.20932
external-disk: Calling bootstrap hook function remove_data_source_dumps
external-disk: Looking for bootstrap manifest files to remove in /tmp/borgmatic-*/borgmatic/bootstrap
external-disk: Removing bootstrap manifest at /tmp/borgmatic-2hn4yjf5/borgmatic/bootstrap/manifest.json
external-disk: Calling btrfs hook function remove_data_source_dumps
external-disk: Calling lvm hook function remove_data_source_dumps
external-disk: Calling mariadb hook function remove_data_source_dumps
external-disk: Removing MariaDB data source dumps
external-disk: Calling mongodb hook function remove_data_source_dumps
external-disk: Removing MongoDB data source dumps
external-disk: Calling mysql hook function remove_data_source_dumps
external-disk: Removing MySQL data source dumps
external-disk: Calling postgresql hook function remove_data_source_dumps
external-disk: Removing PostgreSQL data source dumps
external-disk: Calling sqlite hook function remove_data_source_dumps
external-disk: Removing SQLite data source dumps
external-disk: Calling zfs hook function remove_data_source_dumps
external-disk: Running 2 commands for after create action hook
external-disk: BORG_PASSPHRASE=*** echo "Backup created."
Backup created.
external-disk: BORG_PASSPHRASE=*** echo "Calling Uptime Kuma after backup"
Calling Uptime Kuma after backup
external-disk: Error running actions for repository
external-disk: Command 'sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump > /tmp/borgmatic-2hn4yjf5/./borgmatic/sqlite_databases/localhost/mosquitto' returned non-zero exit status 1.
/etc/borgmatic.d/config.yaml: Calling ntfy hook function ping_monitor
/etc/borgmatic.d/config.yaml: Calling ntfy hook function ping_monitor
/etc/borgmatic.d/config.yaml: Pinging ntfy topic janwiebe-borgmatic-1d264961-4148-4f42-8fb8-9be925cf206a
/etc/borgmatic.d/config.yaml: Using ntfy ping URL https://ntfy.sh
/etc/borgmatic.d/config.yaml: Calling ntfy hook function destroy_monitor
/etc/borgmatic.d/config.yaml: Error running configuration
/etc/borgmatic.d/config.yaml: Running after create/prune/compact/check error command hook
/etc/borgmatic.d/config.yaml: BORG_PASSPHRASE=*** echo "Error while creating a backup."
Error while creating a backup.
/etc/borgmatic.d/config.yaml: An error occurred

summary:
/etc/borgmatic.d/config.yaml: Loading configuration file
An error occurred
Error running actions for repository
Command 'sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump > /tmp/borgmatic-2hn4yjf5/./borgmatic/sqlite_databases/localhost/mosquitto' returned non-zero exit status 1.
Error running configuration

Expected behavior

Finish without errors

Other notes / implementation ideas

No response

borgmatic version

2.1.3

borgmatic installation method

docker

Borg version

borg 1.4.4

Python version

Python 3.14.3

Database version (if applicable)

3.51.2 2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cb2075 (64-bit)

Operating system and version

No response

### What I'm trying to do and why I have the same issue as is mentioned in the comments of #1276, but since that issue seems to originate from something else, I decided to write my own. I try to backup sqlite databases on my docker host, by mounting a root folder into my borgmatic container. This has worked for a long time, but got broken in a recent version ### Steps to reproduce regular sqlite database backup config in the configuration yaml ### Actual behavior external-disk: Command 'sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump > /tmp/borgmatic-ovsfb6j3/./borgmatic/sqlite_databases/localhost/mosquitto' returned non-zero exit status 1. ``` external-disk: Creating archive at "/mnt/borg-repository::borgmatic-backup-2026-03-31T09:44:31.checkpoint" external-disk: Verified integrity of /root/.cache/borg/a65edc89381d46f49b666735612e29c96a1a0ba9d554a9e8c42dde40e05722d6/chunks external-disk: Reading files cache ... external-disk: Verified integrity of /root/.cache/borg/a65edc89381d46f49b666735612e29c96a1a0ba9d554a9e8c42dde40e05722d6/files external-disk: security: read previous location '/mnt/borg-repository' external-disk: security: read manifest timestamp '2026-03-24T00:35:46.140715' external-disk: security: determined newest manifest timestamp as 2026-03-24T00:35:46.140715 external-disk: security: repository checks ok, allowing access external-disk: Processing files ... external-disk: Cleaned up 1 uncommitted segment files (== everything after segment 20932). external-disk: Verified integrity of /mnt/borg-repository/hints.20932 external-disk: Calling bootstrap hook function remove_data_source_dumps external-disk: Looking for bootstrap manifest files to remove in /tmp/borgmatic-*/borgmatic/bootstrap external-disk: Removing bootstrap manifest at /tmp/borgmatic-2hn4yjf5/borgmatic/bootstrap/manifest.json external-disk: Calling btrfs hook function remove_data_source_dumps external-disk: Calling lvm hook function remove_data_source_dumps external-disk: Calling mariadb hook function remove_data_source_dumps external-disk: Removing MariaDB data source dumps external-disk: Calling mongodb hook function remove_data_source_dumps external-disk: Removing MongoDB data source dumps external-disk: Calling mysql hook function remove_data_source_dumps external-disk: Removing MySQL data source dumps external-disk: Calling postgresql hook function remove_data_source_dumps external-disk: Removing PostgreSQL data source dumps external-disk: Calling sqlite hook function remove_data_source_dumps external-disk: Removing SQLite data source dumps external-disk: Calling zfs hook function remove_data_source_dumps external-disk: Running 2 commands for after create action hook external-disk: BORG_PASSPHRASE=*** echo "Backup created." Backup created. external-disk: BORG_PASSPHRASE=*** echo "Calling Uptime Kuma after backup" Calling Uptime Kuma after backup external-disk: Error running actions for repository external-disk: Command 'sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump > /tmp/borgmatic-2hn4yjf5/./borgmatic/sqlite_databases/localhost/mosquitto' returned non-zero exit status 1. /etc/borgmatic.d/config.yaml: Calling ntfy hook function ping_monitor /etc/borgmatic.d/config.yaml: Calling ntfy hook function ping_monitor /etc/borgmatic.d/config.yaml: Pinging ntfy topic janwiebe-borgmatic-1d264961-4148-4f42-8fb8-9be925cf206a /etc/borgmatic.d/config.yaml: Using ntfy ping URL https://ntfy.sh /etc/borgmatic.d/config.yaml: Calling ntfy hook function destroy_monitor /etc/borgmatic.d/config.yaml: Error running configuration /etc/borgmatic.d/config.yaml: Running after create/prune/compact/check error command hook /etc/borgmatic.d/config.yaml: BORG_PASSPHRASE=*** echo "Error while creating a backup." Error while creating a backup. /etc/borgmatic.d/config.yaml: An error occurred summary: /etc/borgmatic.d/config.yaml: Loading configuration file An error occurred Error running actions for repository Command 'sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump > /tmp/borgmatic-2hn4yjf5/./borgmatic/sqlite_databases/localhost/mosquitto' returned non-zero exit status 1. Error running configuration ``` ### Expected behavior Finish without errors ### Other notes / implementation ideas _No response_ ### borgmatic version 2.1.3 ### borgmatic installation method docker ### Borg version borg 1.4.4 ### Python version Python 3.14.3 ### Database version (if applicable) 3.51.2 2026-01-09 17:27:48 b270f8339eb13b504d0b2ba154ebca966b7dde08e40c3ed7d559749818cb2075 (64-bit) ### Operating system and version _No response_
Owner

Thanks for filing this as a separate ticket. A few thoughts:

  • Can you pinpoint the version upgrade where this first broke? Was it borgmatic 2.1.2 to 2.1.3, for instance? Knowing that would help track down the change that caused this (assuming there is one).
  • I'm not seeing any useful SQLite error showing up in the borgmatic logs. So you could try running the SQLite dump directly outside of borgmatic to see if there's more of a useful error message. For instance, exec into the borgmatic container and then run: sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump and look for errors.
Thanks for filing this as a separate ticket. A few thoughts: * Can you pinpoint the version upgrade where this first broke? Was it borgmatic 2.1.2 to 2.1.3, for instance? Knowing that would help track down the change that caused this (assuming there is one). * I'm not seeing any useful SQLite error showing up in the borgmatic logs. So you could try running the SQLite dump directly outside of borgmatic to see if there's more of a useful error message. For instance, `exec` into the borgmatic container and then run: `sqlite3 -bail /mnt/source/apps/mosquitto/data/mosquitto.db .dump` and look for errors.
Author

I get for example this error from when running sqlite3 from within the container.
When downloading the .db file, I can open and query with e.g. DBeave

4069fabeace8:/# sqlite3 -bail /mnt/source/apps/wanderer/data/pb_data/data.db .dump
sql error: unable to open database file (14)
PRAGMA foreign_keys=OFF;
BEGIN TRANSACTION;
/**** ERROR: (14) unable to open database file *****/
ROLLBACK; -- due to errors
4069fabeace8:/#

At the following versions, I too have this error:
borgmatic --version
2.1.2

borg --version
borg 1.4.3

I get for example this error from when running sqlite3 from within the container. When downloading the .db file, I can open and query with e.g. DBeave ``` 4069fabeace8:/# sqlite3 -bail /mnt/source/apps/wanderer/data/pb_data/data.db .dump sql error: unable to open database file (14) PRAGMA foreign_keys=OFF; BEGIN TRANSACTION; /**** ERROR: (14) unable to open database file *****/ ROLLBACK; -- due to errors 4069fabeace8:/# ``` At the following versions, I too have this error: borgmatic --version 2.1.2 borg --version borg 1.4.3
Owner

Thanks for those additional details. If sqlite3 is unable to open/dump the database file even without borgmatic, then it sounds like the database file is missing, has permissions issues, or is corrupt at least from the perspective of the container. Some thoughts on things to try:

  • exec into the container and use ls -l to check that the database file exists at the path you expect and that you have permissions to read it.
  • If you have sqlite3 available on your host, try running the dump command on the database file (probably at a different path on the host) to see if it works there.
  • Without overwriting your original, try restoring the database file from backups to see if you can find a copy that can actually be dumped. This might not be necessary though if you determine above that the database path is missing or otherwise not accessible from the container.
Thanks for those additional details. If `sqlite3` is unable to open/dump the database file even without borgmatic, then it sounds like the database file is missing, has permissions issues, or is corrupt at least from the perspective of the container. Some thoughts on things to try: * `exec` into the container and use `ls -l` to check that the database file exists at the path you expect and that you have permissions to read it. * If you have `sqlite3` available on your host, try running the dump command on the database file (probably at a different path on the host) to see if it works there. * Without overwriting your original, try restoring the database file from backups to see if you can find a copy that can actually be dumped. This might not be necessary though if you determine above that the database path is missing or otherwise not accessible from the container.
Sign in to join this conversation.
No milestone
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
borgmatic-collective/borgmatic#1290
No description provided.