MySQL dump on "all" fails when only system databases are present #319

Closed
opened 2020-05-23 20:53:37 +00:00 by hansmeets · 5 comments

What I'm trying to do and why

I've imported my borgmatic config from another machine and noticed that the config now fails on the "all" database dumps. The machine is still fresh and doesn't have any databases imported yet.

Steps to reproduce (if a bug)

  • Set up borgmatic to dump all MySQL databases
  • Have no user databases present
mysql --skip-column-names --batch --execute "show schemas"
information_schema
mysql
performance_schema
  • The mysqldump command is now invalid, due to the fact that no databases are listed in combination with the --databases command

Actual behavior (if a bug)

/etc/borgmatic/config.yaml: Error running configuration file
<repo>: Error running actions for repository
Usage: mysqldump [OPTIONS] database [tables]
Command 'mysqldump --add-drop-database --databases > /root/.borgmatic/mysql_databases/localhost/all' returned non-zero exit status 1.

Expected behavior (if a bug)

Have borgmatic recognize that only system databases are found, and skip database dump without error.

Environment

borgmatic version: 1.5.4

borgmatic installation method: pip package

Borg version: 1.1.11

Python version: 3.8.3

Database version (if applicable): 10.3.22-MariaDB

operating system and version: Debian testing (bullseye)

#### What I'm trying to do and why I've imported my borgmatic config from another machine and noticed that the config now fails on the "all" database dumps. The machine is still fresh and doesn't have any databases imported yet. #### Steps to reproduce (if a bug) - Set up borgmatic to dump all MySQL databases - Have no user databases present ``` mysql --skip-column-names --batch --execute "show schemas" information_schema mysql performance_schema ``` - The mysqldump command is now invalid, due to the fact that no databases are listed in combination with the --databases command #### Actual behavior (if a bug) ``` /etc/borgmatic/config.yaml: Error running configuration file <repo>: Error running actions for repository Usage: mysqldump [OPTIONS] database [tables] Command 'mysqldump --add-drop-database --databases > /root/.borgmatic/mysql_databases/localhost/all' returned non-zero exit status 1. ``` #### Expected behavior (if a bug) Have borgmatic recognize that only system databases are found, and skip database dump without error. #### Environment **borgmatic version:** 1.5.4 **borgmatic installation method:** pip package **Borg version:** 1.1.11 **Python version:** 3.8.3 **Database version (if applicable):** 10.3.22-MariaDB **operating system and version:** Debian testing (bullseye)
Owner

Thanks so much for reporting this one. It definitely seems like the current behavior of issuing a mysqldump command with invalid parameters is not the right thing to do!

The one problem I can envision if borgmatic doesn't error when there are no "all" databases to backup: A user may see backups succeeding and assume that everything is working, when in fact nothing is being backed up.. because there are no user databases on the system. Thoughts on that?

In your particular case, I'm curious.. Why do you have the MySQL database hook enabled if no user databases are present? Are you planning to add databases later on?

Thanks so much for reporting this one. It definitely seems like the current behavior of issuing a `mysqldump` command with invalid parameters is not the right thing to do! The one problem I can envision if borgmatic doesn't error when there are no "all" databases to backup: A user may see backups succeeding and assume that everything is working, when in fact nothing is being backed up.. because there are no user databases on the system. Thoughts on that? In your particular case, I'm curious.. Why do you have the MySQL database hook enabled if no user databases are present? Are you planning to add databases later on?
witten added the
bug
label 2020-05-23 21:23:14 +00:00
Author

I am migrating to a new machine and am indeed planning to adding/importing databases later on. I was preparing borgmatic beforehand and stumbled across the error.

You're right about the cases where a user might assume that everything is working, when it isn't. And that user should probably have the mysql hook disabled. Maybe a descriptive error would be enough, without calling the invalid mysqldump command?

I am migrating to a new machine and am indeed planning to adding/importing databases later on. I was preparing borgmatic beforehand and stumbled across the error. You're right about the cases where a user might assume that everything is working, when it isn't. And that user should probably have the mysql hook disabled. Maybe a descriptive error would be enough, without calling the invalid mysqldump command?
Owner

A descriptive error makes sense to me!

A descriptive error makes sense to me!
Owner

Released in borgmatic 1.5.5!

Released in borgmatic 1.5.5!
Author

I've tested the update, works great!

Thanks Dan.

<>: Querying for "all" MySQL databases to dump
mysql --skip-column-names --batch --execute show schemas
<>: Error running actions for repository
Cannot find any MySQL databases to dump.

I've tested the update, works great! Thanks Dan. ``` <>: Querying for "all" MySQL databases to dump mysql --skip-column-names --batch --execute show schemas <>: Error running actions for repository Cannot find any MySQL databases to dump. ```
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#319
No description provided.