Backup failed due to mysql dump

I have latest version of hestiacp installed

When I run

sudo /usr/local/hestia/bin/v-backup-user username

I get error

Error: dump username_db failed

Now after some debug in code I check file /tmp/e.mysql

mysqldump: Got error: 1045: “Access denied for user ‘root’@‘localhost’ (using password: YES)” when trying to connect

So I check my root password in file /usr/local/hestia/conf/mysql.conf and use same password to login which works

mysql -u root -p

Please let me know where it can be wrong.

PS. I have custom root password

Can you create a database with command line?

Thanks for quick reply. As I said I can login to mysql using “mysql -u root -p” and the password specified in file /usr/local/hestia/conf/mysql.conf

Try deleing:

$HESTIA/conf/.mysql.$HOST

I do not have this file

sudo ls -l /usr/local/hestia/conf/
total 16
drwxr-xr-x 2 root root 4096 Jan 9 12:30 defaults
-rw-rw---- 1 root root 151 Jan 10 23:07 dns-cluster.conf
-rw-r–r-- 1 root root 1534 Jan 28 04:44 hestia.conf
-rw-rw---- 1 root root 231 Jan 30 11:16 mysql.conf

Create/drop db works from command line

MariaDB [(none)]> CREATE DATABASE test123;
Query OK, 1 row affected (0.000 sec)

MariaDB [(none)]> DROP DATABASE test123;
Query OK, 0 rows affected (0.003 sec)

Can you create a database from Cli with v-add-database

Sorry I have this file. Deleting and trying again

sudo ls -al /usr/local/hestia/conf/
total 28
drwxr-x— 3 root root 4096 Jan 30 11:37 .
drwxr-xr-x 11 root root 4096 Jan 9 12:23 …
-rw-rw---- 1 root root 75 Jan 9 12:40 .mysql.localhost
drwxr-xr-x 2 root root 4096 Jan 9 12:30 defaults
-rw-rw---- 1 root root 151 Jan 10 23:07 dns-cluster.conf
-rw-r–r-- 1 root root 1534 Jan 28 04:44 hestia.conf
-rw-rw---- 1 root root 231 Jan 30 11:16 mysql.conf

I know we have added:

mysqldump --defaults**-extra**-file=$mycnf --single-transaction --routines -r $1 $2 2> $err

But I’m sure it should not affect the backuping at least on my server(s) I have no issue…

First file $HESTIA/conf/.mysql.$HOST has correct password and I have deleted this file and still get error

Error: dump username_db failed

Further If i change line

mysqldump --defaults**-extra**-file=$mycnf --single-transaction --routines -r $1 $2 2> $err

by adding -u root -pPASSWORdD then it works so it seems that script using password from somewhere else

Even it works with

–defaults-file=$mycnf

i.e. by removing “-extra”

Should load mycnf (that contains the password) and should load normally…

Further I have checked file /usr/local/hestia/func/db.sh everywhere it is “–defaults-file” why we have mysqldump --defaults**-extra**-file in method mysql_dump(). Any special reason ?

Thanks for reference link. I am not sure why it is not working in my case or any other user also have same issue

This is first time I heard the issue. (1.5.7) has been out for under 4 days…

Solution would try:

mysqldump --defaults-file=$mycnf --single-transaction --routines -r $1 $2 2> $err

Detect for error

mysqldump --defaults-extra-file=$mycnf --single-transaction --routines -r $1 $2 2> $err.

Create error and warn user

I think this is issue for all users who are using their custom root password for root DB user.

So now I have to set my custom root db password in two files

sudo nano /root/.my.cnf
sudo nano /usr/local/hestia/conf/mysql.conf

And now below line works

mysqldump --defaults-extra-file=$mycnf --single-transaction --routines -r $1 $2 2> $err.

Ref: mysql handler using defaults-extra-file lets /root/.my.cnf override credentials (#11263) · Issues · liberate / backupninja · GitLab

1 Like

probbaly deleting the file was enough …

Thanks below line also helped

sudo rm /root/.my.cnf

I have a similar issue after the latest update.
Backup cron job [sudo /usr/local/hestia/bin/v-backup-users] can only backup admin user. Other user database backup can’t be created. PLEASE HELP!

Here is the log file:

admin


– SYSTEM –

2022-02-01 14:00:59 admin.conf

2022-02-01 14:00:59 stats.log

2022-02-01 14:00:59 history.log

2022-02-01 14:00:59 pam

– WEB –

2022-02-01 14:00:59 hf.**********.com

2022-02-01 14:00:59 *** 1 domain ***

– DNS –

2022-02-01 14:00:59 *** 0 domains ***

– MAIL –

2022-02-01 14:00:59 *** 0 domains ***

– DB –

2022-02-01 14:00:59 *** 0 databases ***

– CRON –

2022-02-01 14:00:59 *** 12 jobs ***

– User Dir –

2022-02-01 14:01:00 adding .bash_logout

2022-02-01 14:01:00 adding .bashrc

2022-02-01 14:01:00 adding .cache

2022-02-01 14:01:00 adding .composer

2022-02-01 14:01:00 adding .config

2022-02-01 14:01:00 adding .local

2022-02-01 14:01:00 adding .npm

2022-02-01 14:01:00 adding .profile

2022-02-01 14:01:00 adding .ssh

2022-02-01 14:01:00 adding .vscode-server

2022-02-01 14:01:00 *** 10 directories ***

– SUMMARY –

2022-02-01 14:01:00 Rotated: 2022-02-01_13-56-01

2022-02-01 14:01:00 Local: /backup/admin.2022-02-01_14-01-00.tar

2022-02-01 14:01:00 Size: 2 MB

2022-02-01 14:01:00 Runtime: 1 minute


================================

fatih


/usr/local/hestia/bin/v-backup-user: line 178: Error: Connection to localhost failed * 2: syntax error in expression (error token is “: Connection to localhost failed * 2”)

/usr/local/hestia/bin/v-backup-user: line 181: [: : integer expression expected

– SYSTEM –

2022-02-01 14:01:00 fatih.conf

2022-02-01 14:01:00 stats.log

2022-02-01 14:01:00 history.log

2022-02-01 14:01:00 backup-excludes.conf

2022-02-01 14:01:00 pam

– WEB –

2022-02-01 14:01:00 online.**********.com

2022-02-01 14:01:00 files.**********.com

2022-02-01 14:01:00 excluding directory public_html

2022-02-01 14:01:01 news.**********.com

2022-02-01 14:01:01 **********.com

2022-02-01 14:01:03 **********.net

2022-02-01 14:01:03 files.**********.net

2022-02-01 14:01:03 test.**********.com

2022-02-01 14:01:03 *** 7 domains ***

– DNS –

2022-02-01 14:01:03 *** 0 domains ***

– MAIL –

2022-02-01 14:01:03 *** 0 domains ***

– DB –

2022-02-01 14:01:03 fatih_********** (mysql)

Error: Connection to localhost failed