Bacula-users

Re: [Bacula-users] mysqldump not working due to missing password

2017-01-05 07:34:23
Subject: Re: [Bacula-users] mysqldump not working due to missing password
From: Martin Simmons <martin AT lispworks DOT com>
To: bacula-users AT lists.sourceforge DOT net
Date: Thu, 5 Jan 2017 12:33:10 GMT
>>>>> On Thu, 5 Jan 2017 08:47:08 +0100, Stefan Kiehne said:
> 
> Hi guys,
> 
> I have a ClientRunBeforeJob directive that makes a dump of each database
> (using mysqldump) before the backup.
> 
> ClientRunBeforeJob = "sh -c 'databases=`mysql -u root -e \"SHOW DATABASES;\" 
> | grep -Ev \"(Database|information_schema|performance_schema)\"`; rm -f 
> /var/spool/bacula/*.sql && for db in $databases; do mysqldump 
> --defaults-extra-file=/var/spool/bacula/.my.cnf --opt --events --databases 
> $db > /var/spool/bacula/$db.sql; done && unset databases'"
> 
> I added the option --defaults-extra-file=/root/.my.cnf because it neede a
> password but since the bacula user couldn't read the file in that directory
> it failed. So I moved the file to /var/spool/bacula/.my.cnf and changed the
> ClientRunBeforeJob accordingly. Just checked and it still didn't work
> (ClientRunBeforeJob: ERROR 1045 (28000): Access denied for user 'x'@'y'
> (using password: NO). I can log in to mysql as bacula with no problem
> (using 'sudo -u bacula mysql') So what am I missing here?

Is the "ERROR 1045" coming from `mysql ...` or from mysqldump?

I suspect confusion about users and defaults from your description.

1. The ClientRunBeforeJob runs in the bacula-fd.  Are you really running
that as the bacula user?  Normally it runs as root.

2. You are passing '-u root' to mysql so this is not connecting as the
bacula user and might be different from your tests with 'sudo -u bacula
mysql'.

3. You are not passing --defaults-extra-file to mysql (only to mysqldump).

4. You are not passing '-u root' to mysqldump, so the user will either be
specified in /var/spool/bacula/.my.cnf or defaulted to the user running the
command (probably root in the ClientRunBeforeJob).

__Martin

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Bacula-users mailing list
Bacula-users AT lists.sourceforge DOT net
https://lists.sourceforge.net/lists/listinfo/bacula-users

<Prev in Thread] Current Thread [Next in Thread>