Skip to content
Snippets Groups Projects
Commit e1e22df9 authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

Merge branch '7599-detect-new-mariadb-dumps' into 'master'

OP#7599 mysql restore: Error in first line  https://projects.iml.unibe.ch/work_packages/7599

See merge request !146
parents ec2ef8fa cef730ab
No related branches found
No related tags found
1 merge request!146OP#7599 mysql restore: Error in first line https://projects.iml.unibe.ch/work_packages/7599
......@@ -18,6 +18,8 @@
# 2022-03-24 v2.4 On empty dumps: detect if source db is empty too
# 2023-10-06 v2.5 mysqldump params can be customized in jobs/env
# 2023-10-02 v2.6 Detect a connect error before backup; remove unneeded code
# 2024-10-02 v2.6 Detect a connect error before backup; remove unneeded code
# 2024-11-18 v2.7 Detect mariadb sandbox mode
# ================================================================================
if [ -z "$LOCALDUMP_LOADED" ]; then
......@@ -95,7 +97,16 @@ function mysql.db.dump(){
function mysql.db.import(){
local _dumpfile=$1
local _dbname=$2
zcat "$_dumpfile" | mysql $BACKUP_PARAMS "${_dbname}"
# https://mariadb.org/mariadb-dump-file-compatibility-change/
# if sandbox mode is detected then skip the first line
if zcat "$_dumpfile" | head -1 | grep -Fq '!999999\- enable the sandbox mode'
then
zcat "$_dumpfile" | tail +2 | mysql $BACKUP_PARAMS "${_dbname}"
else
zcat "$_dumpfile" | mysql $BACKUP_PARAMS "${_dbname}"
fi
fetchrc >/dev/null
test $myrc -eq 0 && mysql_COUNT_IMPORT+=1
test $myrc -eq 0 || mysql_COUNT_ERRORS+=1
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment