Bug #2906
MySQL backup doesn't fail if root password is not set
Status: | CLOSED | Start date: | ||
---|---|---|---|---|
Priority: | Normal | Due date: | ||
Assignee: | - | % Done: | 100% | |
Category: | nethserver-mysql | |||
Target version: | v6.5 | |||
Security class: | Resolution: | |||
Affected version: | v6.5-final | NEEDINFO: | No |
Description
MySQL dumps are done during pre-backup-data
event.
If any dump can't be saved, the action should exit 1 and the event must fail.
Actual behavior
The /etc/e-smith/events/actions/mysql-dump-tables
actions doesn't fail if root has no access to MySQL.
Expected behavior
The action must exit 1 and the pre-backup-data
event must fail.
Steps to reproduce
mv /root/.my.cnf /root/my.cnf /etc/e-smith/events/actions/mysql-dump-tables [root@localhost ~]# /etc/e-smith/events/actions/mysql-dump-tables ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@localhost ~]# echo $? 0
The actions should exit with status 1.
Associated revisions
Backup: better error handling. Refs #2906
History
#1 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from NEW to TRIAGED
- Target version set to v6.5
- % Done changed from 0 to 20
Proposed solution:
--- /etc/e-smith/events/actions/mysql-dump-tables 2014-08-20 09:17:29.000000000 +0000 +++ mysql-dump-tables 2014-10-13 16:59:26.912658088 +0000 @@ -11,7 +11,10 @@ echo "mysqld is disabled - no tables dumped" >&2 exit 0 fi -for db in $(mysql -BNre "show databases" | grep -v information_schema) +dbs=`mysql -BNre "show databases"` || exit 1 +for db in $(echo $dbs) do - mysqldump --single-transaction --quick --add-drop-table -QB "$db" -r $backup_dir/"$db".dump || exit 1 + if [ "$db" != "information_schema" ]; then + mysqldump --skip-dump-date --ignore-table=mysql.event --single-transaction --quick --add-drop-table -QB "$db" -r $backup_dir/"$db".dump || exit 1 + fi doneThis solution also :
- avoid the warning:
-- Warning: Skipping the data of table mysql.event. Specify the --events option explicitly.
- doesn't print the date inside the dump
#2 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from TRIAGED to ON_DEV
- % Done changed from 20 to 30
#3 Updated by Giacomo Sanchietti almost 7 years ago
- Assignee set to Giacomo Sanchietti
#4 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from ON_DEV to MODIFIED
- % Done changed from 30 to 60
#5 Updated by Giacomo Sanchietti almost 7 years ago
- Status changed from MODIFIED to ON_QA
- Assignee deleted (
Giacomo Sanchietti) - % Done changed from 60 to 70
Package in nethserver-testing:
- nethserver-mysql-1.0.6-1.0git0bc5ee84.ns6.noarch.rpm
- Check the bug is not reproducible
#6 Updated by Davide Principi almost 7 years ago
- Assignee set to Davide Principi
#7 Updated by Davide Principi almost 7 years ago
- Status changed from ON_QA to VERIFIED
- Assignee deleted (
Davide Principi) - % Done changed from 70 to 90
VERIFIED
[root@davidep2 ~]# mv .my.cnf my.cnf [root@davidep2 ~]# mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@davidep2 ~]# /etc/e-smith/events/actions/mysql-dump-tables ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) [root@davidep2 ~]# echo $? 1
#8 Updated by Davide Principi almost 7 years ago
- Status changed from VERIFIED to CLOSED
- % Done changed from 90 to 100
In nethserver-updates:
nethserver-mysql-1.0.7-1.ns6.noarch.rpm