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 @@
#
# 2016-11-10 ah,ds v0.8 needs to be testet
# 2017-03-28 ..... v1.0 added restore
# 2022-01-20 v1.1 fixes with shellcheck
# ================================================================================
if
[
-z
$BACKUP_TARGETDIR
]
;
then
echo
ERROR: you cannot start
`
basename
$0
`
directly
if
[
-z
"
$BACKUP_TARGETDIR
"
]
;
then
echo
"
ERROR: you cannot start
$(
basename
$0
)
directly
"
rc
=
$rc
+1
exit
1
fi
...
...
@@ -33,33 +34,33 @@ function doMysqlBackup(){
create_targetdir
for
DATABASE_DIR
in
`
find
$SOURCE_DIR
/
*
-type
d
-prune
`
;
for
DATABASE_DIR
in
$(
find
$SOURCE_DIR
/
*
-type
d
-prune
)
;
do
# DATABASE=`basename $DATABASE_DIR`
DATABASE
=
`
basename
$DATABASE_DIR
|
sed
"s#
\@
002d#-#g"
`
TABLECOUNT
=
`
find
$DATABASE_DIR
/.
-type
f
-name
*
frm |
wc
-l
`
echo
---
database
$DATABASE
-
$TABLECOUNT
tables
DATABASE
=
$(
basename
"
$DATABASE_DIR
"
|
sed
"s#
\@
002d#-#g"
)
TABLECOUNT
=
$(
find
"
$DATABASE_DIR
"
/.
-type
f
-name
"
*frm
"
|
wc
-l
)
echo
"
--- database
$DATABASE
-
$TABLECOUNT
tables
"
if
[
$TABLECOUNT
-gt
0
]
;
then
echo
-n
"backup ... "
OUTFILE
=
${
BACKUP_TARGETDIR
}
/
`
get_outfile
${
DATABASE
}
`
.sql
OUTFILE
=
"
${
BACKUP_TARGETDIR
}
/
$(
get_outfile
${
DATABASE
}
)
.sql
"
# task 1251 - "--master-data=2" was removed
$MYSQLDUMP
--opt
\
--default-character-set
=
utf8
\
--flush-logs
\
--single-transaction
\
--no-autocommit
\
--result-file
=
$OUTFILE
\
$DATABASE
--result-file
=
"
$OUTFILE
"
\
"
$DATABASE
"
fetchrc
# $myrc is last returncode - set in fetchrc
if
[
$myrc
-eq
0
]
;
then
echo
-n
"gzip ... "
compress_file
$OUTFILE
compress_file
"
$OUTFILE
"
else
echo
"ERROR occured - no gzip"
fi
ls
-l
$OUTFILE
*
ls
-l
"
$OUTFILE
"
*
fi
echo
done
...
...
@@ -73,9 +74,9 @@ function restoreByFile(){
sMyfile
=
$1
sMyDb
=
$2
if
[
-z
$sMyDb
]
;
then
if
[
-z
"
$sMyDb
"
]
;
then
h2
"analyze dump
$sMyfile
"
sMyDb
=
`
guessDB
$sMyfile
`
sMyDb
=
$(
guessDB
$sMyfile
)
echo
"detected db schema from file: [
${
sMyDb
}
]"
else
echo
"db schema from param 2: [
${
sMyDb
}
]"
...
...
@@ -83,7 +84,7 @@ function restoreByFile(){
echo
echo
import to
$sMyDb
...
echo
import to
"
$sMyDb
"
...
h2 ensure that database exists ...
color cmd
...
...
@@ -91,10 +92,10 @@ function restoreByFile(){
color reset
h2 import ...
ls
-l
$sMyfile
echo
import to database
[
${
sMyDb
}
]
ls
-l
"
$sMyfile
"
echo
"
import to database [
${
sMyDb
}
]
"
color cmd
zcat
$sMyfile
| mysql
"
${
sMyDb
}
"
zcat
"
$sMyfile
"
| mysql
"
${
sMyDb
}
"
fetchrc
color reset
...
...
@@ -130,6 +131,6 @@ else
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