Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
iml-backup
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IML Open Source
iml-backup
Commits
dedc6dc0
Commit
dedc6dc0
authored
3 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
mysql fixes with shellcheck
parent
77509b75
Branches
Branches containing commit
No related tags found
1 merge request
!26
Eliminate scheduler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
plugins/localdump/mysql.sh
+19
-18
19 additions, 18 deletions
plugins/localdump/mysql.sh
with
19 additions
and
18 deletions
plugins/localdump/mysql.sh
+
19
−
18
View file @
dedc6dc0
...
@@ -10,10 +10,11 @@
...
@@ -10,10 +10,11 @@
#
#
# 2016-11-10 ah,ds v0.8 needs to be testet
# 2016-11-10 ah,ds v0.8 needs to be testet
# 2017-03-28 ..... v1.0 added restore
# 2017-03-28 ..... v1.0 added restore
# 2022-01-20 v1.1 fixes with shellcheck
# ================================================================================
# ================================================================================
if
[
-z
$BACKUP_TARGETDIR
]
;
then
if
[
-z
"
$BACKUP_TARGETDIR
"
]
;
then
echo
ERROR: you cannot start
`
basename
$0
`
directly
echo
"
ERROR: you cannot start
$(
basename
$0
)
directly
"
rc
=
$rc
+1
rc
=
$rc
+1
exit
1
exit
1
fi
fi
...
@@ -33,33 +34,33 @@ function doMysqlBackup(){
...
@@ -33,33 +34,33 @@ function doMysqlBackup(){
create_targetdir
create_targetdir
for
DATABASE_DIR
in
`
find
$SOURCE_DIR
/
*
-type
d
-prune
`
;
for
DATABASE_DIR
in
$(
find
$SOURCE_DIR
/
*
-type
d
-prune
)
;
do
do
# DATABASE=`basename $DATABASE_DIR`
# DATABASE=`basename $DATABASE_DIR`
DATABASE
=
`
basename
$DATABASE_DIR
|
sed
"s#
\@
002d#-#g"
`
DATABASE
=
$(
basename
"
$DATABASE_DIR
"
|
sed
"s#
\@
002d#-#g"
)
TABLECOUNT
=
`
find
$DATABASE_DIR
/.
-type
f
-name
*
frm |
wc
-l
`
TABLECOUNT
=
$(
find
"
$DATABASE_DIR
"
/.
-type
f
-name
"
*frm
"
|
wc
-l
)
echo
---
database
$DATABASE
-
$TABLECOUNT
tables
echo
"
--- database
$DATABASE
-
$TABLECOUNT
tables
"
if
[
$TABLECOUNT
-gt
0
]
;
then
if
[
$TABLECOUNT
-gt
0
]
;
then
echo
-n
"backup ... "
echo
-n
"backup ... "
OUTFILE
=
${
BACKUP_TARGETDIR
}
/
`
get_outfile
${
DATABASE
}
`
.sql
OUTFILE
=
"
${
BACKUP_TARGETDIR
}
/
$(
get_outfile
${
DATABASE
}
)
.sql
"
# task 1251 - "--master-data=2" was removed
# task 1251 - "--master-data=2" was removed
$MYSQLDUMP
--opt
\
$MYSQLDUMP
--opt
\
--default-character-set
=
utf8
\
--default-character-set
=
utf8
\
--flush-logs
\
--flush-logs
\
--single-transaction
\
--single-transaction
\
--no-autocommit
\
--no-autocommit
\
--result-file
=
$OUTFILE
\
--result-file
=
"
$OUTFILE
"
\
$DATABASE
"
$DATABASE
"
fetchrc
fetchrc
# $myrc is last returncode - set in fetchrc
# $myrc is last returncode - set in fetchrc
if
[
$myrc
-eq
0
]
;
then
if
[
$myrc
-eq
0
]
;
then
echo
-n
"gzip ... "
echo
-n
"gzip ... "
compress_file
$OUTFILE
compress_file
"
$OUTFILE
"
else
else
echo
"ERROR occured - no gzip"
echo
"ERROR occured - no gzip"
fi
fi
ls
-l
$OUTFILE
*
ls
-l
"
$OUTFILE
"
*
fi
fi
echo
echo
done
done
...
@@ -73,9 +74,9 @@ function restoreByFile(){
...
@@ -73,9 +74,9 @@ function restoreByFile(){
sMyfile
=
$1
sMyfile
=
$1
sMyDb
=
$2
sMyDb
=
$2
if
[
-z
$sMyDb
]
;
then
if
[
-z
"
$sMyDb
"
]
;
then
h2
"analyze dump
$sMyfile
"
h2
"analyze dump
$sMyfile
"
sMyDb
=
`
guessDB
$sMyfile
`
sMyDb
=
$(
guessDB
$sMyfile
)
echo
"detected db schema from file: [
${
sMyDb
}
]"
echo
"detected db schema from file: [
${
sMyDb
}
]"
else
else
echo
"db schema from param 2: [
${
sMyDb
}
]"
echo
"db schema from param 2: [
${
sMyDb
}
]"
...
@@ -83,7 +84,7 @@ function restoreByFile(){
...
@@ -83,7 +84,7 @@ function restoreByFile(){
echo
echo
echo
import to
$sMyDb
...
echo
import to
"
$sMyDb
"
...
h2 ensure that database exists ...
h2 ensure that database exists ...
color cmd
color cmd
...
@@ -91,10 +92,10 @@ function restoreByFile(){
...
@@ -91,10 +92,10 @@ function restoreByFile(){
color reset
color reset
h2 import ...
h2 import ...
ls
-l
$sMyfile
ls
-l
"
$sMyfile
"
echo
import to database
[
${
sMyDb
}
]
echo
"
import to database [
${
sMyDb
}
]
"
color cmd
color cmd
zcat
$sMyfile
| mysql
"
${
sMyDb
}
"
zcat
"
$sMyfile
"
| mysql
"
${
sMyDb
}
"
fetchrc
fetchrc
color reset
color reset
...
@@ -130,6 +131,6 @@ else
...
@@ -130,6 +131,6 @@ else
fi
fi
fi
fi
echo
$0
$*
[
mysql] final returncode
rc
=
$rc
echo
"
$0
$*
[mysql] final returncode rc=
$rc
"
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment