Jean-Philippe Pialasse de0996e198 * Fri Mar 07 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-9.sme
- upgrade to support mariadb 11.4 [SME: 12930]
  move mariadb-upgrade to mysql.init unit
  remove duplicate in 00_restore_dumped_dbs and 10mysql_upgrade,
  add a tmp.d for pid file, add post action dnf script
  update mariadb.service.d/ content, set default to utfmb4
- mysql.user table filtering [SME: 12592]

* Sun Jan 26 2025 Jean-Philippe Pialasse <jpp@koozali.org> 11.0.0-8.sme
- prestart script requires daemontools bins [SME: 12566]
2025-03-08 23:59:18 -05:00

54 lines
2.4 KiB
Bash

#!/bin/sh
status=$(/sbin/e-smith/config getprop mariadb status)
fixtables=$(/sbin/e-smith/config getprop mariadb autofixtables || echo "disabled")
if [ "$fixtables" = "enabled" ]; then
/sbin/e-smith/config delprop mariadb failsbackup
fi
failsbackup=$(/sbin/e-smith/config getprop mariadb failsbackup || echo "disabled")
onfailure () {
db=$1
message=""
if [ "$failsbackup" = "enabled" ]; then
exit 1;
message="There was an error trying to dump database $db, please fix this db. We stop there without backups."
echo $message
echo $message | /usr/bin/mail -s "error on backup of $db MariaDB database" admin
fi
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."
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
if [ "$fixtables" = "enabled" ]; then
repair="failure"
message="$message \nTrying to auto-repair the db and do a backup after..."
mysqlcheck -s --auto-repair -c "$db" && \
mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump && repair="success"
message="$message \n => $repair"
fi
echo $message
echo $message | /usr/bin/mail -s "error on backup of $db MariaDB database" admin
}
if [ "$status" = "disabled" ]
then
echo "mysqld is disabled - no tables dumped" >&2
exit 0
fi
for db in $(mysql -BNre "show databases;"|egrep -vi "^information_schema$|^performance_schema$")
do
mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table -QB "$db" -r /home/e-smith/db/mysql/"$db".dump || onfailure $db
done
# dump user privileges
mysqldump --system=users --insert-ignore > /home/e-smith/db/mysql/mysql.privileges.dump
# dump plugins
mysqldump --system=plugins --insert-ignore > /home/e-smith/db/mysql/mysql.plugins.dump
# dump udfs
mysqldump --system=udfs --insert-ignore > /home/e-smith/db/mysql/mysql.udfs.dump
# dump servers
mysqldump --system=servers --insert-ignore > /home/e-smith/db/mysql/mysql.servers.dump
# dump stats
mysqldump --system=stats --insert-ignore > /home/e-smith/db/mysql/mysql.stats.dump
# dump timezones
mysqldump --system=timezones --insert-ignore > /home/e-smith/db/mysql/mysql.timezones.dump