Specify path for database dump/restore commands #311

Closed
opened 2020-05-15 17:52:51 +00:00 by witten · 4 comments
Owner

What I'm trying to do and why

As a user doing database dumps and restores, I want to be able to specify the path to the various dump/restore binaries (pg_dump, pg_restore, mysql, etc.) in the borgmatic configuration file. The idea is that these binaries may not be on the default path, or I may want to select different ones than those on the default path.

Work-around: Manipulate the shell PATH before invoking borgmatic.

Other notes / implementation ideas

This could work similarly to the existing Borg local_path / remote_path options. One challenge is that there are multiple different binaries, not just one. So maybe specifying the folder containing all of them (per database hook) would be better.

#### What I'm trying to do and why As a user doing database dumps and restores, I want to be able to specify the path to the various dump/restore binaries (`pg_dump`, `pg_restore`, `mysql`, etc.) in the borgmatic configuration file. The idea is that these binaries may not be on the default path, or I may want to select different ones than those on the default path. Work-around: Manipulate the shell `PATH` before invoking borgmatic. #### Other notes / implementation ideas This could work similarly to the existing Borg `local_path` / `remote_path` options. One challenge is that there are multiple different binaries, not just one. So maybe specifying the folder containing all of them (per database hook) would be better.

@witten this feature would be very helpful for our use case, where we have different mariadb (versions 5 and 10) and firebirdsql (versions 2.5 and 3) instances running in docker containers which are not reachable from the host but only within their isolated docker network.

In our home brew backup scripts we define these commands for database dumping:

CMD_MYSQLDUMP="/usr/bin/docker exec -t stack-somestack_mariadb_1 /usr/bin/mysqldump"

This dumps the database by executing the appropriate mysqldump within the running database container, dumping it to stdout.

The restore command works similarly by piping the dump via stdin to the mysql command within the container.

And it would be great to allow for indidvidual database configurations like

    other_databases:
        - name: someotherdatabase
          before_dump: <here my individual action to prepare for dumping>
          dump: <here my individual dump command to stdout>
          after_dump: <here my individual action to cleanup dumping>
          before_restore: <here my individual action to prepare for restoration>
          restore: <here my individual restore command to stdin>
          after_restore: <here my individual action to cleanup restoration>

This would allow for very individual configurations, not only tied to postgresql or mysql, as long as there are command line tools available which could be used to dump and restore from/to stdin/stdout. Or, if filenames have to be involved, some filename expansion like ${filename} or similar where borgmatic could create some temporary usable filename.

@witten this feature would be very helpful for our use case, where we have different mariadb (versions 5 and 10) and firebirdsql (versions 2.5 and 3) instances running in docker containers which are not reachable from the host but only within their isolated docker network. In our home brew backup scripts we define these commands for database dumping: CMD_MYSQLDUMP="/usr/bin/docker exec -t stack-somestack_mariadb_1 /usr/bin/mysqldump" This dumps the database by executing the appropriate mysqldump within the running database container, dumping it to stdout. The restore command works similarly by piping the dump via stdin to the mysql command within the container. And it would be great to allow for indidvidual database configurations like ``` other_databases: - name: someotherdatabase before_dump: <here my individual action to prepare for dumping> dump: <here my individual dump command to stdout> after_dump: <here my individual action to cleanup dumping> before_restore: <here my individual action to prepare for restoration> restore: <here my individual restore command to stdin> after_restore: <here my individual action to cleanup restoration> ``` This would allow for very individual configurations, not only tied to postgresql or mysql, as long as there are command line tools available which could be used to dump and restore from/to stdin/stdout. Or, if filenames have to be involved, some filename expansion like ${filename} or similar where borgmatic could create some temporary usable filename.
Author
Owner

Just released for PostgreSQL in borgmatic 1.7.5! I'll leave this ticket open to cover the other database hooks.

Just released for PostgreSQL in borgmatic 1.7.5! I'll leave this ticket open to cover the other database hooks.
witten added the
good first issue
label 2023-03-29 18:49:09 +00:00
Author
Owner

shivansh02 added custom command options for MariaDB and MySQL. So now all that remains is adding custom command support for the SQLite and MongoDB hooks. Rather than leave this ticket open even longer, I'll file separate tickets for that work.

[shivansh02](https://github.com/shivansh02) added [custom command options for MariaDB and MySQL](https://github.com/borgmatic-collective/borgmatic/pull/81). So now all that remains is adding custom command support for the SQLite and MongoDB hooks. Rather than leave this ticket open even longer, I'll file separate tickets for that work.
Author
Owner

Released in borgmatic 1.8.9!

Released in borgmatic 1.8.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#311
No description provided.