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

Check if the created dump contains "insert"

parent 3baef77b
No related branches found
No related tags found
1 merge request!56Check if the created dump contains "insert"
......@@ -12,7 +12,8 @@
# 2022-01-20 ah v1.1 fixes with shellcheck
# 2022-02-14 ah v2.0 rewrite with class like functions
# 2022-02-18 ah v2.1 WIP: added counters
# 2022-03-17 v1.2 WIP: add lines with prefix __DB__
# 2022-03-17 v2.2 WIP: add lines with prefix __DB__
# 2022-03-21 v2.3 Check if the created dump contains "insert"
# ================================================================================
if [ -z "$LOCALDUMP_LOADED" ]; then
......@@ -71,7 +72,7 @@ function mysql.db.create(){
echo "CREATE DATABASE IF NOT EXISTS ${_dbname};" | mysql
fetchrc >/dev/null
test $myrc -eq 0 && mysql_COUNT_CREATE+=1
test $rc -eq 0 || mysql_COUNT_ERRORS+=1
test $myrc -eq 0 || mysql_COUNT_ERRORS+=1
}
# dump [database] --> [file]
......@@ -89,11 +90,17 @@ function mysql.db.dump(){
--single-transaction \
--no-autocommit \
--result-file="$_dumpfile" \
"$_dbname"
"$_dbname" 2>&1
fetchrc >/dev/null
test $myrc -eq 0 && mysql_COUNT_DUMPS+=1
test $rc -eq 0 || mysql_COUNT_ERRORS+=1
test $rc -eq 0
zgrep -i "INSERT" "$_dumpfile" >/dev/null
typeset -i local _rc2=$?
test $_rc2 -ne 0 && echo "ERROR: the dump does not contain an insert statement."
typeset -i local _rctotal=$?+$_rc2
test $_rctotal -eq 0 && mysql_COUNT_DUMPS+=1
test $_rctotal -eq 0 || mysql_COUNT_ERRORS+=1
test $_rctotal -eq 0
}
# import [file] --> [database]
......@@ -106,7 +113,7 @@ function mysql.db.import(){
zcat "$_dumpfile" | mysql "${_dbname}"
fetchrc >/dev/null
test $myrc -eq 0 && mysql_COUNT_IMPORT+=1
test $rc -eq 0 || mysql_COUNT_ERRORS+=1
test $myrc -eq 0 || mysql_COUNT_ERRORS+=1
}
# show a list of existing databases
......@@ -116,7 +123,7 @@ function mysql.db.list(){
fetchrc >/dev/null
test $myrc -eq 0 && mysql_COUNT_DB=$( echo "$_result" | grep -c "^Database:" )
test $myrc -eq 0 && echo "$_result" | grep "^Database:" | awk '{ print $2 }'
test $rc -eq 0 || mysql_COUNT_ERRORS+=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.
Please register or to comment