Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backup manager non compatible with latest versions of mariadb #144

Open
fbruffaert opened this issue Oct 6, 2024 · 3 comments
Open

Backup manager non compatible with latest versions of mariadb #144

fbruffaert opened this issue Oct 6, 2024 · 3 comments

Comments

@fbruffaert
Copy link

fbruffaert commented Oct 6, 2024

Hello,

After upgrading from mariadb 10 to 11.5, my backups are not working anymore because of mysql backups.

The logs read:
Using method "mysql". The "mysql" method is chosen, but is not found.

After some digging in source code, the problem is with those lines of code:
mysql=$(which mysql 2> /dev/null) || true
and
mysqldump=$(which mysqldump) || true

New versions of mariadb have renamed those commands.
Is backup-manager still maintened?

In the meantime, a temp fix for those who have the same issue is to create symlinks:

ln -s /usr/bin/mariadb /usr/bin/mysql
ln -s /usr/bin/mariadb-dump /usr/bin/mysqldump
@fabmars
Copy link

fabmars commented Oct 29, 2024

Depends on your distrib. For instance with MariaDB 11.4/11.5 on my Ubuntu 24, you get fed with mariadb-client-compat which symlinks /usr/bin/mysql to the mariadb executable (and same for mysqldump to mariadb-dump) exactly like you're suggesting.

@fabmars
Copy link

fabmars commented Oct 29, 2024

But there is something else that makes your ticket very relevant: so far, if your "root" user used unix_socket auth (only), the mysql client used to go for the socket protocol even if you specified a port in your command line. That's the assumption backup-manager takes here for instance.
However the mariadb client works quite differently: once you specify a port, it goes for the password auth no matter what.
Assuming you have the mariadb-client-compat package, backup-manager will actually call the mariadb executable and you're stuck!

This isn't obvious from what' I'm reading on the mariadb auth changes from version 10.4 here and here but that's what I'm observing (see the test below).

Worse, on ubuntu you cannot just uninstall the mariadb-client package and install the mysql-client one instead because the former is marked as 'auto' in apt and you cannot easily uninstall it without removing the mariadb-server itself...duh

Fortunately there is a simple solution for that: specify --protocol=socket within BM_MYSQL_EXTRA_OPTIONS and you can force the mysql mariadb client to do the right thing.

BUT then you are likely to stumble upon the same issue a few lines down the road if your config requires a ALL backup and you're backing up databases separately: the mysql client is used to list the server's databases, and (again, assuming you have the mariadb-client-compat package or a symlink), the fact a port is specified leads you to a password auth and it becomes complicated as there is nothing similar to $BM_MYSQL_EXTRA_OPTIONS passed to the command line this time.

=====

One can see this behavior by himself using a docker mariadb server instance (where fortunately the mysql-client package isn't bound to the server one for some reason):

docker run --rm -d --name some-mariadb --env MARIADB_ROOT_PASSWORD=whatever -p 3307:3306  mariadb:11.4
docker  exec -ti some-mariadb bash

then from the docker instance:
mariadb -u root -p'whatever' -h localhost
from the mariadb client, ensure the root user uses socket protocol:

ALTER USER root@localhost IDENTIFIED VIA unix_socket;
flush privileges;
exit

back to the docker instance:
mariadb -u root -h localhost -P 3306 => yields ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: NO)
swap clients:
apt remove mariadb-client => mariadb server should still be running after that
apt update && apt install mysql-client
mysql -u root -h localhost -P 3306 => You're in. Different behavior!

=====

So now what to do ?

  • Make a mariadb specific method ? => hmm maybe, or at least keep most of the code common
  • Add specific command line options for the separate db backup case ?
  • Add more tests to check the mariadb executables presence on top of the mysql ones plus more tweaks to add the port or not depending on...? => seems complicated
  • Add the port optjon on the 2 lines of code above only if the BM_MYSQL_PORT variable is specified ? => I like it too
  • wait for mariadb to fix something ?

Now @fbruffaert seems @kissifrot is now the maintainer, so this project is still active but I'm willing to make a pull request anyway.

fabmars added a commit to fabmars/Backup-Manager that referenced this issue Oct 29, 2024
@fabmars
Copy link

fabmars commented Oct 29, 2024

MR #145

fabmars added a commit to fabmars/Backup-Manager that referenced this issue Nov 12, 2024
fabmars added a commit to fabmars/Backup-Manager that referenced this issue Nov 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants