--database does not find database dump when port is specified for database in config #1322

Closed
opened 2026-06-14 20:39:50 +00:00 by cegredev · 5 comments

What I'm trying to do and why

I'm trying to restore selected databases from my archives for the purpose of not having to restore all of them at once. This however results in an error saying the dumps don't exist: $PATH_TO_REPO: Cannot restore data source dump immich missing from archive. This error goes away when I don't specify the port in my borgmatic config (it's postgres default port 5432 but I like to be explicit).

Steps to reproduce

  1. Setup a database using the following docker compose:
  db:
    image: postgres:18.4-alpine
    container_name: nextcloud_postgres
    volumes:
      - "../../storage/nextcloud/db:/var/lib/postgresql"
      - /run/user/1000:/run/user/1000 # I don't think I should need this, but it didn't work with or without it
    environment:
      - POSTGRES_DB=nextcloud
      - POSTGRES_USER=postgres
      - POSTGRES_PASSWORD=1234
  1. Use something like the following borgmatic config. Use it in a test repo of yours, if you have that.
repositories:
    - path: $PATH_TO_REPO

source_directories:
    - ...

postgresql_databases:
    - name: "nextcloud"
    # - port: 5432

      pg_dump_command: docker exec nextcloud_postgres pg_dump -U postgres
      pg_restore_command: docker exec -i nextcloud_postgres pg_restore -U postgres
      psql_command: docker exec -i nextcloud_postgres psql -U postgres
  1. Run borgmatic create --config path/to/this/config.yaml
  2. Run borgmatic restore --archive latest --database nextcloud
  3. Uncomment the port, repeat 3. and 4. and watch it fail

Actual behavior

When the port is specified, the restore fails with the following output:

/home/me/borgmatic-test/borgmatic.yaml: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg --version --log-json --debug --show-rc
/home/me/borgmatic-test/borgmatic.yaml: Borg 1.4.2
/home/me/borgmatic-test/repo: Running actions for repository
/home/me/borgmatic-test/repo: Restoring data sources from archive latest
/home/me/borgmatic-test/repo: Using runtime directory /run/user/1000/borgmatic
/home/me/borgmatic-test/repo: Calling bootstrap hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Looking for bootstrap manifest files to remove in /run/user/1000/borgmatic/bootstrap
/home/me/borgmatic-test/repo: Calling btrfs hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Calling lvm hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Calling mariadb hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing MariaDB data source dumps
/home/me/borgmatic-test/repo: Calling mongodb hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing MongoDB data source dumps
/home/me/borgmatic-test/repo: Calling mysql hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing MySQL data source dumps
/home/me/borgmatic-test/repo: Calling postgresql hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing PostgreSQL data source dumps
/home/me/borgmatic-test/repo: Calling sqlite hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing SQLite data source dumps
/home/me/borgmatic-test/repo: Calling zfs hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg list --log-json --glob-archives {hostname}-* --last 1 --json /home/me/borgmatic-test/repo
/home/me/borgmatic-test/repo: Latest archive is hp-envy-fedora-2026-06-14T22:32:02.528301 (9e65d6be08de337547ae7352da6d5a6f5d1ed0d4329b04d5891cf9afd23b9113)
/home/me/borgmatic-test/repo: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg list --log-json --json-lines /home/me/borgmatic-test/repo::hp-envy-fedora-2026-06-14T22:32:02.528301 sh:borgmatic/*_databases/dumps.json sh:run/user/1000/borgmatic/*_databases/dumps.json
/home/me/borgmatic-test/repo: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg extract --log-json --debug --list --show-rc --stdout /home/me/borgmatic-test/repo::hp-envy-fedora-2026-06-14T22:32:02.528301 borgmatic/postgresql_databases/dumps.json > -1
/home/me/borgmatic-test/repo: Collecting database dumps from archive data source dumps metadata files
/home/me/borgmatic-test/repo: Calling bootstrap hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Looking for bootstrap manifest files to remove in /run/user/1000/borgmatic/bootstrap
/home/me/borgmatic-test/repo: Calling btrfs hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Calling lvm hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Calling mariadb hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing MariaDB data source dumps
/home/me/borgmatic-test/repo: Calling mongodb hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing MongoDB data source dumps
/home/me/borgmatic-test/repo: Calling mysql hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing MySQL data source dumps
/home/me/borgmatic-test/repo: Calling postgresql hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing PostgreSQL data source dumps
/home/me/borgmatic-test/repo: Calling sqlite hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Removing SQLite data source dumps
/home/me/borgmatic-test/repo: Calling zfs hook function remove_data_source_dumps
/home/me/borgmatic-test/repo: Error running actions for repository
/home/me/borgmatic-test/repo: Cannot restore data source dump nextcloud missing from archive
/home/me/borgmatic-test/borgmatic.yaml: Error running configuration
/home/me/borgmatic-test/borgmatic.yaml: An error occurred

summary:
/home/me/borgmatic-test/borgmatic.yaml: Loading configuration file
An error occurred
Error running actions for repository
Cannot restore data source dump nextcloud missing from archive
Error running configuration

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

Expected behavior

It works.

Other notes / implementation ideas

No response

borgmatic version

2.1.5

borgmatic installation method

Either pip or package, don't remember and can check later if needed

Borg version

1.4.2

Python version

3.13.7

Database version (if applicable)

18.4

Operating system and version

Fedora 42

### What I'm trying to do and why I'm trying to restore selected databases from my archives for the purpose of not having to restore all of them at once. This however results in an error saying the dumps don't exist: `$PATH_TO_REPO: Cannot restore data source dump immich missing from archive`. This error goes away when I don't specify the port in my borgmatic config (it's postgres default port 5432 but I like to be explicit). ### Steps to reproduce 1. Setup a database using the following docker compose: ```yaml db: image: postgres:18.4-alpine container_name: nextcloud_postgres volumes: - "../../storage/nextcloud/db:/var/lib/postgresql" - /run/user/1000:/run/user/1000 # I don't think I should need this, but it didn't work with or without it environment: - POSTGRES_DB=nextcloud - POSTGRES_USER=postgres - POSTGRES_PASSWORD=1234 ``` 2. Use something like the following borgmatic config. Use it in a test repo of yours, if you have that. ```yaml repositories: - path: $PATH_TO_REPO source_directories: - ... postgresql_databases: - name: "nextcloud" # - port: 5432 pg_dump_command: docker exec nextcloud_postgres pg_dump -U postgres pg_restore_command: docker exec -i nextcloud_postgres pg_restore -U postgres psql_command: docker exec -i nextcloud_postgres psql -U postgres ``` 3. Run `borgmatic create --config path/to/this/config.yaml` 4. Run `borgmatic restore --archive latest --database nextcloud` 5. Uncomment the port, repeat 3. and 4. and watch it fail ### Actual behavior When the port is specified, the `restore` fails with the following output: ``` /home/me/borgmatic-test/borgmatic.yaml: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg --version --log-json --debug --show-rc /home/me/borgmatic-test/borgmatic.yaml: Borg 1.4.2 /home/me/borgmatic-test/repo: Running actions for repository /home/me/borgmatic-test/repo: Restoring data sources from archive latest /home/me/borgmatic-test/repo: Using runtime directory /run/user/1000/borgmatic /home/me/borgmatic-test/repo: Calling bootstrap hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Looking for bootstrap manifest files to remove in /run/user/1000/borgmatic/bootstrap /home/me/borgmatic-test/repo: Calling btrfs hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Calling lvm hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Calling mariadb hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing MariaDB data source dumps /home/me/borgmatic-test/repo: Calling mongodb hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing MongoDB data source dumps /home/me/borgmatic-test/repo: Calling mysql hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing MySQL data source dumps /home/me/borgmatic-test/repo: Calling postgresql hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing PostgreSQL data source dumps /home/me/borgmatic-test/repo: Calling sqlite hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing SQLite data source dumps /home/me/borgmatic-test/repo: Calling zfs hook function remove_data_source_dumps /home/me/borgmatic-test/repo: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg list --log-json --glob-archives {hostname}-* --last 1 --json /home/me/borgmatic-test/repo /home/me/borgmatic-test/repo: Latest archive is hp-envy-fedora-2026-06-14T22:32:02.528301 (9e65d6be08de337547ae7352da6d5a6f5d1ed0d4329b04d5891cf9afd23b9113) /home/me/borgmatic-test/repo: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg list --log-json --json-lines /home/me/borgmatic-test/repo::hp-envy-fedora-2026-06-14T22:32:02.528301 sh:borgmatic/*_databases/dumps.json sh:run/user/1000/borgmatic/*_databases/dumps.json /home/me/borgmatic-test/repo: BORG_PASSPHRASE_FD=*** BORG_EXIT_CODES=*** borg extract --log-json --debug --list --show-rc --stdout /home/me/borgmatic-test/repo::hp-envy-fedora-2026-06-14T22:32:02.528301 borgmatic/postgresql_databases/dumps.json > -1 /home/me/borgmatic-test/repo: Collecting database dumps from archive data source dumps metadata files /home/me/borgmatic-test/repo: Calling bootstrap hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Looking for bootstrap manifest files to remove in /run/user/1000/borgmatic/bootstrap /home/me/borgmatic-test/repo: Calling btrfs hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Calling lvm hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Calling mariadb hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing MariaDB data source dumps /home/me/borgmatic-test/repo: Calling mongodb hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing MongoDB data source dumps /home/me/borgmatic-test/repo: Calling mysql hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing MySQL data source dumps /home/me/borgmatic-test/repo: Calling postgresql hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing PostgreSQL data source dumps /home/me/borgmatic-test/repo: Calling sqlite hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Removing SQLite data source dumps /home/me/borgmatic-test/repo: Calling zfs hook function remove_data_source_dumps /home/me/borgmatic-test/repo: Error running actions for repository /home/me/borgmatic-test/repo: Cannot restore data source dump nextcloud missing from archive /home/me/borgmatic-test/borgmatic.yaml: Error running configuration /home/me/borgmatic-test/borgmatic.yaml: An error occurred summary: /home/me/borgmatic-test/borgmatic.yaml: Loading configuration file An error occurred Error running actions for repository Cannot restore data source dump nextcloud missing from archive Error running configuration Need some help? https://torsion.org/borgmatic/#issues ``` ### Expected behavior It works. ### Other notes / implementation ideas _No response_ ### borgmatic version 2.1.5 ### borgmatic installation method Either pip or package, don't remember and can check later if needed ### Borg version 1.4.2 ### Python version 3.13.7 ### Database version (if applicable) 18.4 ### Operating system and version Fedora 42
Owner

Thanks for filing this! It's fixed in main and will be part of the next release. I also fixed the case of the reverse—starting with an explicit default port in config, dumping, and then removing the port from the config and doing a restore.

Note that I only bothered to fix this when using Borg 1.4+. Should be fine for your case, but I'm calling this out in case anyone else stumbles across the issue. If using Borg 1.2... upgrade!

Thanks for filing this! It's fixed in main and will be part of the next release. I also fixed the case of the reverse—starting with an explicit default port in config, dumping, and then removing the port from the config and doing a restore. Note that I only bothered to fix this when using Borg 1.4+. Should be fine for your case, but I'm calling this out in case anyone else stumbles across the issue. If using Borg 1.2... upgrade!
Owner

Ah, looks like I only fixed this when not using the --database flag. I'm gonna have to fix it a little harder...

Ah, looks like I only fixed this when not using the `--database` flag. I'm gonna have to fix it a little harder...
witten reopened this issue 2026-06-15 19:00:30 +00:00
Owner

Oh I lied; that case actually works as well! I just had a typo on my command-line. Calling this done again.

Oh I lied; that case actually works as well! I just had a typo on my command-line. Calling this done again.
Author

Thank you!

Thank you!
Owner

Released in borgmatic 2.1.7!

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