Database "missing from archive" #985

Closed
opened 2025-02-03 03:23:40 +00:00 by enieuwy · 8 comments

What I'm trying to do and why

I'm trying to restore a database to the original containerised postgres).

Steps to reproduce

Config is:

postgresql_databases:
  - name: authentik
    hostname: authentik-postgresql-1
    username: authentik
    password: <redacted>

Actual behavior

# borgmatic restore --repository borgwarehouse --archive latest --database authentik
borgwarehouse: Error running actions for repository
Cannot restore data source dump authentik@localhost missing from archive
/etc/borgmatic.d/config.yaml: An error occurred

summary:
/etc/borgmatic.d/config.yaml: An error occurred
borgwarehouse: Error running actions for repository
Cannot restore data source dump authentik@localhost missing from archive

Need some help? https://torsion.org/borgmatic/#issues

Expected behavior

Database appears successfully backed up to archive:

# borgmatic list --repository borgwarehouse --archive latest --find *borgmatic/*_databases
borgwarehouse: Searching archives
ssh://borgwarehouse@192.168.50.10:2222/./d1916b04: Listing archive backup-2025-02-02T01:01:44
drwxr-xr-x root   root          0 Sun, 2025-02-02 01:01:13 borgmatic/mongodb_databases
drwx------ root   root          0 Sun, 2025-02-02 01:01:13 borgmatic/mongodb_databases/librechat-mongodb:27017
-rw------- root   root    5830906 Sun, 2025-02-02 01:01:13 borgmatic/mongodb_databases/librechat-mongodb:27017/LibreChat
drwxr-xr-x root   root          0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases
drwx------ root   root          0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/authentik-postgresql-1
-rw------- root   root    2333102 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/authentik-postgresql-1/authentik
drwx------ root   root          0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/solidtime-database-1
-rw------- root   root      65648 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/solidtime-database-1/solidtime
drwx------ root   root          0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/librechat-vectordb
-rw------- root   root       3983 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/librechat-vectordb/mydatabase

Other notes / implementation ideas

No response

borgmatic version

# borgmatic --version 1.9.5

borgmatic installation method

Container

Borg version

# borg --version borg 1.4.0

Python version

# python3 --version Python 3.12.8

Database version (if applicable)

# psql --version psql (PostgreSQL) 17.2 (borgmatic container)
# psql --version psql (PostgreSQL) 16.6 (origin db container)

Operating system and version

Debian 12 (host)

### What I'm trying to do and why I'm trying to restore a database to the original containerised postgres). ### Steps to reproduce Config is: ``` postgresql_databases: - name: authentik hostname: authentik-postgresql-1 username: authentik password: <redacted> ``` ### Actual behavior ``` # borgmatic restore --repository borgwarehouse --archive latest --database authentik borgwarehouse: Error running actions for repository Cannot restore data source dump authentik@localhost missing from archive /etc/borgmatic.d/config.yaml: An error occurred summary: /etc/borgmatic.d/config.yaml: An error occurred borgwarehouse: Error running actions for repository Cannot restore data source dump authentik@localhost missing from archive Need some help? https://torsion.org/borgmatic/#issues ``` ### Expected behavior Database appears successfully backed up to archive: ``` # borgmatic list --repository borgwarehouse --archive latest --find *borgmatic/*_databases borgwarehouse: Searching archives ssh://borgwarehouse@192.168.50.10:2222/./d1916b04: Listing archive backup-2025-02-02T01:01:44 drwxr-xr-x root root 0 Sun, 2025-02-02 01:01:13 borgmatic/mongodb_databases drwx------ root root 0 Sun, 2025-02-02 01:01:13 borgmatic/mongodb_databases/librechat-mongodb:27017 -rw------- root root 5830906 Sun, 2025-02-02 01:01:13 borgmatic/mongodb_databases/librechat-mongodb:27017/LibreChat drwxr-xr-x root root 0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases drwx------ root root 0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/authentik-postgresql-1 -rw------- root root 2333102 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/authentik-postgresql-1/authentik drwx------ root root 0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/solidtime-database-1 -rw------- root root 65648 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/solidtime-database-1/solidtime drwx------ root root 0 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/librechat-vectordb -rw------- root root 3983 Sun, 2025-02-02 01:01:13 borgmatic/postgresql_databases/librechat-vectordb/mydatabase ``` ### Other notes / implementation ideas _No response_ ### borgmatic version `# borgmatic --version 1.9.5` ### borgmatic installation method Container ### Borg version `# borg --version borg 1.4.0` ### Python version `# python3 --version Python 3.12.8` ### Database version (if applicable) `# psql --version psql (PostgreSQL) 17.2` (borgmatic container) `# psql --version psql (PostgreSQL) 16.6` (origin db container) ### Operating system and version Debian 12 (host)
Owner

Thanks for filing this again and including all the details! So I think I found the problem for real now. It turns out that you don't need --hostname authentik-postgresql-1.. you need --original-hostname authentik-postgresql-1. The former is for specifying the destination hostname to restore to, while the latter is for disambiguating/specifying which database dump you want to restore. Confusing, I know. It tripped me up too.. and I implemented the damned thing!

Anyway, let me know if --original-hostname works for you.

In regards to the "original" hostname defaulting to localhost, maybe this would be less confusing and more intuitive if instead an unspecified original hostname defaulted to matching dumps of all hostnames. That would align more with your first attempt of just restoring the database by name. I haven't taken the time to think through the implications in terms of how feasible/practical that would be, but I wanted to get your take on such a change since you were directly bitten by this. Thanks!

Thanks for filing this [again](https://github.com/borgmatic-collective/docker-borgmatic/issues/388) and including all the details! So I think I found the problem for real now. It turns out that you don't need `--hostname authentik-postgresql-1`.. you need `--original-hostname authentik-postgresql-1`. The former is for specifying the destination hostname to restore to, while the latter is for disambiguating/specifying which database dump you want to restore. Confusing, I know. It tripped me up too.. and I implemented the damned thing! Anyway, let me know if `--original-hostname` works for you. In regards to the "original" hostname defaulting to `localhost`, maybe this would be less confusing and more intuitive if instead an unspecified original hostname defaulted to matching dumps of *all* hostnames. That would align more with your first attempt of just restoring the database by name. I haven't taken the time to think through the implications in terms of how feasible/practical that would be, but I wanted to get your take on such a change since you were directly bitten by this. Thanks!
Author

Really appreciate your support! A new error (looks like progress):

# borgmatic restore --repository borgwarehouse --archive latest --database authentik --original-hostname authentik-postgresql-1
borgwarehouse: Error running actions for repository
Command 'pg_restore --no-password --if-exists --exit-on-error --clean --dbname authentik --host authentik-postgresql-1 --username authentik' returned non-zero exit status 1.
/etc/borgmatic.d/config.yaml: An error occurred

summary:
/etc/borgmatic.d/config.yaml: An error occurred
borgwarehouse: Error running actions for repository
pg_restore: error: could not execute query: ERROR:  unrecognized configuration parameter "transaction_timeout"
Command was: SET transaction_timeout = 0;
Command 'pg_restore --no-password --if-exists --exit-on-error --clean --dbname authentik --host authentik-postgresql-1 --username authentik' returned non-zero exit status 1.

Need some help? https://torsion.org/borgmatic/#issues
Really appreciate your support! A new error (looks like progress): ``` # borgmatic restore --repository borgwarehouse --archive latest --database authentik --original-hostname authentik-postgresql-1 borgwarehouse: Error running actions for repository Command 'pg_restore --no-password --if-exists --exit-on-error --clean --dbname authentik --host authentik-postgresql-1 --username authentik' returned non-zero exit status 1. /etc/borgmatic.d/config.yaml: An error occurred summary: /etc/borgmatic.d/config.yaml: An error occurred borgwarehouse: Error running actions for repository pg_restore: error: could not execute query: ERROR: unrecognized configuration parameter "transaction_timeout" Command was: SET transaction_timeout = 0; Command 'pg_restore --no-password --if-exists --exit-on-error --clean --dbname authentik --host authentik-postgresql-1 --username authentik' returned non-zero exit status 1. Need some help? https://torsion.org/borgmatic/#issues ```
Owner

Okay, I was afraid of this. It sounds like a PostgreSQL 17 client can't restore to a PostgreSQL 16 database either. From the PostgreSQL docs:

Also, it is not guaranteed that pg_dump's output can be loaded into a server of an older major version — not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server.

So, options here:

  • You could potentially upgrade your Authentik PostgreSQL database to the same major version as the borgmatic container.
  • You could build your own borgmatic container (based on this one you're using) with an older version of the PostgreSQL clients installed to match your Authentik PostgreSQL.
  • You could try adding --quote-all-identifiers to the configured dump command and then creating a new backup. I don't know if that would help, but the PostgreSQL docs seem to indicate it might in certain cross-major-version cases.
Okay, I was afraid of this. It sounds like a PostgreSQL 17 client can't restore to a PostgreSQL 16 database either. From [the PostgreSQL docs](https://www.postgresql.org/docs/current/app-pgdump.html#notes): > Also, it is not guaranteed that pg_dump's output can be loaded into a server of an older major version — not even if the dump was taken from a server of that version. Loading a dump file into an older server may require manual editing of the dump file to remove syntax not understood by the older server. So, options here: * You could potentially upgrade your Authentik PostgreSQL database to the same major version as the borgmatic container. * You could build your own borgmatic container (based on this one you're using) with an older version of the PostgreSQL clients installed to match your Authentik PostgreSQL. * You could try adding `--quote-all-identifiers` to the configured dump command and then creating a new backup. I don't know if that would help, but the PostgreSQL docs seem to indicate it might in certain cross-major-version cases.
Author

I modified Authentik docker compose to use pgsql 17, then recreated the database (docker compose down --volumes and docker compose up -d).

Ran borgmatic restore --repository borgwarehouse --archive latest --database authentik --original-hostname authentik-postgresql-1 again, and IT WORKED! Hallelujah! Thank you very much for your generous support—saved days of work!

I modified Authentik docker compose to use pgsql 17, then recreated the database (`docker compose down --volumes` and `docker compose up -d`). Ran `borgmatic restore --repository borgwarehouse --archive latest --database authentik --original-hostname authentik-postgresql-1` again, and IT WORKED! Hallelujah! Thank you very much for your generous support—saved days of work!
Author

How can I buy you a coffee?

How can I buy you a coffee?
Owner

I'm so glad to hear that worked! I'll leave this ticket open to make that tweak to the --original-hostname default as described above. And I appreciate the offer, but no coffee is needed. Really. All I request is that you spread the word about borgmatic! (And if you've got cash burning a hole in your pocket, donate to the excellent Borg project that makes all of this possible.)

I'm so glad to hear that worked! I'll leave this ticket open to make that tweak to the `--original-hostname` default as described above. And I appreciate the offer, but no coffee is needed. Really. All I request is that you spread the word about borgmatic! (And if you've got cash burning a hole in your pocket, [donate to the excellent Borg project](https://www.borgbackup.org/support/fund.html) that makes all of this possible.)
Owner

Okay, the --original-hostname tweak is in place and will be part of the next release. Now, you don't have specify an original hostname with restore if there's a single archive dump match without the hostname.

Okay, the `--original-hostname` tweak is in place and will be part of the next release. Now, you don't have specify an original hostname with `restore` if there's a single archive dump match without the hostname.
Owner

Released in borgmatic 1.9.9!

Released in borgmatic 1.9.9!
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#985
No description provided.