dotmanila / pyxbackup

XtraBackup wrapper/manager in Python
GNU General Public License v2.0
85 stars 41 forks source link

pyxbackup overrides socket if not specified explicitly by mysql_socket #36

Closed guriandoro closed 7 years ago

guriandoro commented 7 years ago

Using the following command:

/usr/bin/python /root/bin/pyxbackup full

with the following cnf file:

# cat /root/bin/pyxbackup.cnf 
[pyxbackup]
mysql_cnf = /root/.my.cnf
stor_dir = /backup/dbbackup/data04/backups
work_dir = /backup/dbbackup/data04/work

Contents of the named mysql cnf file are as follows:

cat /root/.my.cnf 
[client]
user=root
password = 'password'
socket = /var/lib/mysql/mysql.sock

This results in the tool using the following command: xtrabackup --defaults-file=/root/.my.cnf --socket=/tmp/mysql.sock --host=localhost --no-timestamp --backup --parallel=4 --rsync --binlog-info=on --target-dir /backup/dbbackup/data04/backups/full/2017_10_09-19_31_45

As seen there, it is explicitly using --socket=... set to a socket that is not the correct one, making it fail with the following messages:

171009 19:31:46  version_check Connecting to MySQL server with DSN 'dbi:mysql:;mysql_read_default_group=xtrabackup;host=localhost;mysql_socket=/tmp/mysql.sock' as 'root'  (using password: YES).
Failed to connect to MySQL server: DBI connect(';mysql_read_default_group=xtrabackup;host=localhost;mysql_socket=/tmp/mysql.sock','root',...) failed: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) at - line 1314.
171009 19:31:46 Connecting to MySQL server host: localhost, user: root, password: set, port: not set, socket: /tmp/mysql.sock
Failed to connect to MySQL server: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2).

Fix: pyxbackup should not try to explicitly set a socket that is not proven to work, and/or override the one defined in the named my.cnf file.

guriandoro commented 7 years ago

Hi Jervin!

I'll try to propose a fix for this after reviewing the code. I'll keep you updated :)

guriandoro commented 7 years ago

Sent PR over https://github.com/dotmanila/pyxbackup/pull/37.

I think it makes more sense to not use any hardcoded default (like /tmp/mysql.sock), and fall back to using localhost:3306. Let me know what you think about it!

Agustín.

guriandoro commented 7 years ago

PR merged.