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

Merge branch 'update-localdump-to-classlike-functions' into 'master'

Check if the created dump contains "insert"

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