Skip to content
Snippets Groups Projects

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

Merged Hahn Axel (hahn) requested to merge 7599-detect-new-mariadb-dumps into master
1 file
+ 12
1
Compare changes
  • Side-by-side
  • Inline
+ 12
1
@@ -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
Loading