borgmatic restore does not pass options from mongodb hook #533

Closed
opened 2022-05-13 23:28:01 +00:00 by errnesto · 5 comments

What I'm trying to do and why

I want to backup and restore my mongodb database via borgmatic hooks

Steps to reproduce (if a bug)

The database needs the --ssl option set for the connection to work

Actual behavior (if a bug)

This works fine by setting the options via the config for creating the backup
But for borgmatic restore --archive latest I get:

Error running actions for repository
Command 'mongorestore --archive --drop --db mydb --host xxx --username xxx --password xxx --authenticationDatabase admin' returned non-zero exit status 1.
xxx.yaml: Error running configuration file

With error connecting to host: could not connect to server: server selection error in the description

Expected behavior (if a bug)

I think the reason for this is that the --ssl flag is missing on the mongorestore command and therefore it fails.

So the options should be added to the restore command as well

Environment

borgmatic version: [version here]

1.6.0

borgmatic installation method: [e.g., Debian package, Docker container, etc.]

pip

Borg version: [version here]

borg 1.1.16

Python version: [version here]

Python 3.10.4

Database version (if applicable): [version here]

mongodb 4.2

operating system and version: [OS here]

Debian bullseye

#### What I'm trying to do and why I want to backup and restore my mongodb database via borgmatic hooks #### Steps to reproduce (if a bug) The database needs the `--ssl` option set for the connection to work #### Actual behavior (if a bug) This works fine by setting the options via the config for creating the backup But for `borgmatic restore --archive latest` I get: ``` Error running actions for repository Command 'mongorestore --archive --drop --db mydb --host xxx --username xxx --password xxx --authenticationDatabase admin' returned non-zero exit status 1. xxx.yaml: Error running configuration file ``` With `error connecting to host: could not connect to server: server selection error` in the description #### Expected behavior (if a bug) I think the reason for this is that the --ssl flag is missing on the `mongorestore` command and therefore it fails. So the options should be added to the restore command as well #### Environment **borgmatic version:** [version here] 1.6.0 **borgmatic installation method:** [e.g., Debian package, Docker container, etc.] pip **Borg version:** [version here] borg 1.1.16 **Python version:** [version here] Python 3.10.4 **Database version (if applicable):** [version here] mongodb 4.2 **operating system and version:** [OS here] Debian bullseye
Owner

Thank you for reporting this! It looks like this behavior is intentional—all the database hooks only pass the database options value to the dump and not the restore commands. I think the idea is that users often want to provide dump-only options.

Given that you're interested in passing the --ssl flag, which seems like a pretty common need, what do you think of borgmatic supporting a new ssl option (true or false) along with your other MongoDB database options? When true, that could plumb the --ssl flag to both dump and restore commands.

Thank you for reporting this! It looks like this behavior is intentional—all the database hooks only pass the database `options` value to the dump and not the restore commands. I think the idea is that users often want to provide dump-only options. Given that you're interested in passing the `--ssl` flag, which seems like a pretty common need, what do you think of borgmatic supporting a new `ssl` option (true or false) along with your other MongoDB database options? When true, that could plumb the `--ssl` flag to both dump and restore commands.
Author

Hey thank you for the quick response.
Yes adding an ssl option would sound good to me.

Maybe this could also be solved with a mongodb connection string. But if so I could not figure this out yet…

Hey thank you for the quick response. Yes adding an ssl option would sound good to me. Maybe this could also be solved with a mongodb connection string. But if so I could not figure this out yet…
Author

Maybe another idea would be to have restore_options that work the same as options but for the restore command? This way more complex (connection) setups would also be supported.

Maybe another idea would be to have `restore_options` that work the same as `options` but for the restore command? This way more complex (connection) setups would also be supported.
Owner

Both of those approaches (ssl and restore_options) sound good to me! There is already precedent in some of the other database hooks for things like list_options.

Both of those approaches (`ssl` and `restore_options`) sound good to me! There is already precedent in some of the other database hooks for things like `list_options`.
witten added the
design finalized
label 2022-05-14 02:36:55 +00:00
Owner

The MongoDB hook now has a restore_options configuration option in borgmatic 1.7.6. Enjoy!

The MongoDB hook now has a `restore_options` configuration option in borgmatic 1.7.6. Enjoy!
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#533
No description provided.