mysql restore does not allow extra options #630

Closed
opened 2023-01-19 18:56:57 +00:00 by LordRalex · 5 comments

What I'm trying to do and why

I have my db passwords stored in Docker secrets, which I use a before hook to write to a config file for mysql to read from.

This is due to the limitations that borgmatic doesn't permit passwords to be stored in files, so this was the workaround I had.

This worked to make backups, and I've confirmed said backups are functional when doing extracts.

However, when I actually needed to restore the databases, I tried to use the built-in restore to perform this, only for it to fail to get to the database with it complaining that the password was not specified.

Steps to reproduce (if a bug)

Config contains following:

hooks:
    before_everything:
        - printf "[client]\npassword=" | tee db.cnf >/dev/null
        - cat /run/secrets/core_db_pw >> db.cnf
        
    mysql_databases:
        - name: database
          hostname: database
          username: user
          list_options: --defaults-extra-file=db.cnf
          options: --defaults-extra-file=db.cnf --skip-comments

borgmatic creates backups of this database as expected.
Attempt to use borgmatic restore to restore the latest version of this database

Actual behavior (if a bug)

borgmatic fails to connect to database on restore. Command output does not show any options being passed in.

Expected behavior (if a bug)

It actually does the restore using the config without manual intervention.

Other notes / implementation ideas

Per the docs, it only indicates there are 2 options supported: List and dump. It does not indicate the actual restore allows for setting properties. In this scenario, it's not possible to use borgmatic to do the full restore. Rather, I have to extract the backup, and then do it via command-line to complete the restoration.

Environment

borgmatic version: 1.7.5

borgmatic installation method: Docker swarm container, based on b3vis/borgmatic

Borg version: 1.2.2

Python version: 3.10.8

Use python3 --version

Database version (if applicable):
(client) mysql Ver 15.1 Distrib 10.6.11-MariaDB, for Linux (aarch64) using readline 5.1
(server) mysql Ver 15.1 Distrib 10.10.2-MariaDB, for debian-linux-gnu (aarch64) using EditLine wrapper

Use psql --version or mysql --version on client and server.

operating system and version: Linux 5.11.0-1028-oracle #31~20.04.1-Ubuntu SMP Wed Jan 26 14:20:52 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux

#### What I'm trying to do and why I have my db passwords stored in Docker secrets, which I use a before hook to write to a config file for mysql to read from. This is due to the limitations that borgmatic doesn't permit passwords to be stored in files, so this was the workaround I had. This worked to make backups, and I've confirmed said backups are functional when doing extracts. However, when I actually needed to restore the databases, I tried to use the built-in restore to perform this, only for it to fail to get to the database with it complaining that the password was not specified. #### Steps to reproduce (if a bug) Config contains following: ``` hooks: before_everything: - printf "[client]\npassword=" | tee db.cnf >/dev/null - cat /run/secrets/core_db_pw >> db.cnf mysql_databases: - name: database hostname: database username: user list_options: --defaults-extra-file=db.cnf options: --defaults-extra-file=db.cnf --skip-comments ``` borgmatic creates backups of this database as expected. Attempt to use borgmatic restore to restore the latest version of this database #### Actual behavior (if a bug) borgmatic fails to connect to database on restore. Command output does not show any options being passed in. #### Expected behavior (if a bug) It actually does the restore using the config without manual intervention. #### Other notes / implementation ideas Per the docs, it only indicates there are 2 options supported: List and dump. It does not indicate the actual restore allows for setting properties. In this scenario, it's not possible to use borgmatic to do the full restore. Rather, I have to extract the backup, and then do it via command-line to complete the restoration. #### Environment **borgmatic version:** 1.7.5 **borgmatic installation method:** Docker swarm container, based on b3vis/borgmatic **Borg version:** 1.2.2 **Python version:** 3.10.8 Use `python3 --version` **Database version (if applicable):** (client) mysql Ver 15.1 Distrib 10.6.11-MariaDB, for Linux (aarch64) using readline 5.1 (server) mysql Ver 15.1 Distrib 10.10.2-MariaDB, for debian-linux-gnu (aarch64) using EditLine wrapper Use `psql --version` or `mysql --version` on client and server. **operating system and version:** Linux 5.11.0-1028-oracle #31~20.04.1-Ubuntu SMP Wed Jan 26 14:20:52 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
Owner

Thanks for taking the time to file this! It sounds like a restore_options option would solve your need here?

Thanks for taking the time to file this! It sounds like a `restore_options` option would solve your need here?
Author

Yep, that indeed does sound like it would solve my needs.

Yep, that indeed does sound like it would solve my needs.
Owner

Awesome! That should hopefully be pretty straight-forward to add.

Awesome! That should hopefully be pretty straight-forward to add.
witten added the
design finalized
label 2023-01-19 19:07:20 +00:00
Owner

This is implemented in master with new configuration options for database command customization: list_options, restore_options, and analyze_options for PostgreSQL, restore_options for MySQL, and restore_options for MongoDB. It should hopefully be released soon! Thanks again for suggesting it.

This is implemented in master with new configuration options for database command customization: `list_options`, `restore_options`, and `analyze_options` for PostgreSQL, `restore_options` for MySQL, and `restore_options` for MongoDB. It should hopefully be released soon! Thanks again for suggesting it.
Owner

Just released in borgmatic 1.7.6!

Just released in borgmatic 1.7.6!
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#630
No description provided.