Extracting a directory from a remote repository fails if working_directory defined #1037

Closed
opened 2025-03-20 21:24:26 +00:00 by bb · 2 comments
Contributor

What I'm trying to do and why

I have a config which has a remote ssh repository and a working directory configured. I'm trying to extract a directory which fails because the ssh path is appended to the working directory even though it should be absolute.

Steps to reproduce

Prepare a config containing something like this:

repositories:
    - path: ssh://storagebox/./borg-backups/foo.borg
      label: backup

working_directory: /home/user/apps/foo

Then (after initializing, creating a backup, ...) try:

borgmatic -c .config/borgmatic.d/foo.yaml -v1 extract --archive latest --path /home/user/apps/foo/data/storage --destination /home/user/restore/ --strip-components 5

Actual behavior

Repository /home/user/apps/foo/ssh:/storagebox/borg-backups/foo.borg does not exist.
backup: Error running actions for repository
backup: Command 'borg extract --info --strip-components 5 /home/user/apps/foo/ssh://storagebox/./borg-backups/foo.borg::host-2025-03-20T21:40:24.258741 /home/user/apps/foo/data/storage' returned non-zero exit status 2.
/home/user/.config/borgmatic.d/foo.yaml: An error occurred

Expected behavior

The subfolder is extracted to the ~/restore directory.

Other notes / implementation ideas

In projects.torsion.org/borgmatic-collective/borgmatic/blame@c2409d9968/borgmatic/borg/extract.py (L138) do the same check like in

if ':' not in repository:

E.g. add an optional parameter to normalize_repository_path which could be the base repository and ONLY join the base path in the first 2 branches.

borgmatic version

1.9.14

borgmatic installation method

pipx install borgmatic

Borg version

borg 1.2.8

Python version

Python 3.10.12

Database version (if applicable)

No response

Operating system and version

Ubuntu 22.04.5 LTS

### What I'm trying to do and why I have a config which has a remote ssh repository and a working directory configured. I'm trying to extract a directory which fails because the ssh path is appended to the working directory even though it should be absolute. ### Steps to reproduce Prepare a config containing something like this: ```yaml repositories: - path: ssh://storagebox/./borg-backups/foo.borg label: backup working_directory: /home/user/apps/foo ``` Then (after initializing, creating a backup, ...) try: ``` borgmatic -c .config/borgmatic.d/foo.yaml -v1 extract --archive latest --path /home/user/apps/foo/data/storage --destination /home/user/restore/ --strip-components 5 ``` ### Actual behavior Repository /home/user/apps/foo/ssh:/storagebox/borg-backups/foo.borg does not exist. backup: Error running actions for repository backup: Command 'borg extract --info --strip-components 5 /home/user/apps/foo/ssh://storagebox/./borg-backups/foo.borg::host-2025-03-20T21:40:24.258741 /home/user/apps/foo/data/storage' returned non-zero exit status 2. /home/user/.config/borgmatic.d/foo.yaml: An error occurred ### Expected behavior The subfolder is extracted to the ~/restore directory. ### Other notes / implementation ideas In https://projects.torsion.org/borgmatic-collective/borgmatic/blame/commit/c2409d99684bb632be73a3a3cce5bc06dfe8630a/borgmatic/borg/extract.py#L138 do the same check like in https://projects.torsion.org/borgmatic-collective/borgmatic/src/commit/c2409d99684bb632be73a3a3cce5bc06dfe8630a/borgmatic/config/validate.py#L147 E.g. add an optional parameter to `normalize_repository_path` which could be the base repository and ONLY join the base path in the first 2 branches. ### borgmatic version 1.9.14 ### borgmatic installation method pipx install borgmatic ### Borg version borg 1.2.8 ### Python version Python 3.10.12 ### Database version (if applicable) _No response_ ### Operating system and version Ubuntu 22.04.5 LTS
bb changed title from Extraction a directory from a remote repository fails if working_directory defined to Extracting a directory from a remote repository fails if working_directory defined 2025-03-20 21:27:13 +00:00
Owner

Thanks so much for filing this and submitting a PR as well! It definitely looks like an oversight in the existing code.

Thanks so much for filing this and submitting a PR as well! It definitely looks like an oversight in the existing code.
witten 2025-03-21 22:40:19 +00:00
  • closed this issue
  • added the
    bug
    label
Owner

Released in borgmatic 2.0.0!

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