/[smeserver]/rpms/e-smith-mysql/sme10/e-smith-mysql-2.6.0-bz7827-dumpfailure.patch
ViewVC logotype

Contents of /rpms/e-smith-mysql/sme10/e-smith-mysql-2.6.0-bz7827-dumpfailure.patch

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.1 - (show annotations) (download)
Wed Jan 27 19:46:06 2021 UTC (3 years, 4 months ago) by jpp
Branch: MAIN
CVS Tags: e-smith-mysql-2_6_0-22_el7_sme, e-smith-mysql-2_6_0-20_el7_sme, e-smith-mysql-2_6_0-18_el7_sme, e-smith-mysql-2_6_0-19_el7_sme, e-smith-mysql-2_6_0-21_el7_sme, HEAD
* Wed Jan 27 2021 Jean-Philipe Pialasse <tests@pialasse.com> 2.6.0-18.sme
- fix backup fails in pre-backup in mysqldump [SME: 7827]

1 diff -Nur e-smith-mysql-2.6.0.old/root/etc/e-smith/events/actions/mysql-dump-tables e-smith-mysql-2.6.0/root/etc/e-smith/events/actions/mysql-dump-tables
2 --- e-smith-mysql-2.6.0.old/root/etc/e-smith/events/actions/mysql-dump-tables 2021-01-27 14:37:21.692000000 -0500
3 +++ e-smith-mysql-2.6.0/root/etc/e-smith/events/actions/mysql-dump-tables 2021-01-27 14:43:58.451000000 -0500
4 @@ -1,6 +1,35 @@
5 #!/bin/sh
6
7 status=$(/sbin/e-smith/config getprop mariadb status)
8 +fixtables=$(/sbin/e-smith/config getprop mariadb autofixtables || echo "disabled")
9 +if [ "$fixtables" = "enabled" ]; then
10 + /sbin/e-smith/config delprop mariadb failsbackup
11 +fi
12 +failsbackup=$(/sbin/e-smith/config getprop mariadb failsbackup || echo "disabled")
13 +
14 +
15 +onfailure () {
16 + db=$1
17 + message=""
18 + if [ "$failsbackup" = "enabled" ]; then
19 + exit 1;
20 + message="There was an error trying to dump database $db, please fix this db. We stop there without backups."
21 + echo $message
22 + echo $message | /usr/bin/mail -s "error on backup of $db MariaDB database" admin
23 + fi
24 + message="$message \nThere was an error trying to dump database $db, please check for table errors in this db. Forcing a backup of the corrupted DB."
25 + mysqldump --force --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db"-failed.dump || message="$message \nFailed to force backup of corrupted db $db as $db-failed.dump" >&2
26 + if [ "$fixtables" = "enabled" ]; then
27 + repair="failure"
28 + message="$message \nTrying to auto-repair the db and do a backup after..."
29 + mysqlcheck -s --auto-repair -c "$db" && \
30 + mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump && repair="success"
31 + message="$message \n => $repair"
32 + fi
33 + echo $message
34 + echo $message | /usr/bin/mail -s "error on backup of $db MariaDB database" admin
35 +}
36 +
37 if [ "$status" = "disabled" ]
38 then
39 echo "mysqld is disabled - no tables dumped" >&2
40 @@ -8,5 +37,5 @@
41 fi
42 for db in $(mysql -BNre "show databases;"|egrep -vi "^information_schema$|^performance_schema$")
43 do
44 - mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump || exit 1
45 + mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump || onfailure $db
46 done

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed