Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-mysqlbackend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
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
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-mysqlbackend
Commits
c0542b35
Unverified
Commit
c0542b35
authored
6 years ago
by
Timm Fitschen
Browse files
Options
Downloads
Patches
Plain Diff
FIX backup script
parent
5cbd671b
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
backup.sh
+7
-6
7 additions, 6 deletions
backup.sh
patches/utils/patch_header.sh
+16
-16
16 additions, 16 deletions
patches/utils/patch_header.sh
with
23 additions
and
22 deletions
backup.sh
+
7
−
6
View file @
c0542b35
...
@@ -25,8 +25,9 @@
...
@@ -25,8 +25,9 @@
#dump a database with all procedures, permissions, structure and data
#dump a database with all procedures, permissions, structure and data
BACKUPDIR
=
./backup
#The directory which the dump is to be stored to. Do not change it here. Use the --backupdir=./my/dir/ option!
BACKUPDIR
=
./backup
#The directory which the dump is to be stored to. Do not change it here. Use the --backupdir=./my/dir/ option!
PRINT_HELP
=
"--backupdir=BACKUPDIR
\n\t
The directory which the dump is to be stored to. (Defaults to ./backup)"
PRINT_HELP
=
"--backupdir=BACKUPDIR
\n\t
The directory which the dump is to be stored to. (Defaults to ./backup)
\n
"
.
.config
# load useful stuff - scans the parameters and so on...
# load useful stuff - scans the parameters and so on...
.
patches/utils/patch_header.sh
.
patches/utils/patch_header.sh
...
@@ -36,12 +37,12 @@ PRINT_HELP="--backupdir=BACKUPDIR\n\tThe directory which the dump is to be store
...
@@ -36,12 +37,12 @@ PRINT_HELP="--backupdir=BACKUPDIR\n\tThe directory which the dump is to be store
function
backup
{
function
backup
{
# parameters:
login-path
, database, outfile
# parameters:
connection
, database, outfile
if
[
-e
"
$3
"
]
;
then
if
[
-e
"
$3
"
]
;
then
failure
"dumpfile already exists."
failure
"dumpfile already exists."
fi
fi
echo
-n
"Dumping database
$
3
to
$
4
... "
echo
"Dumping database
$
2
to
$
3
... "
$CMD_MYSQL_DUMP
--opt
--default-character-set
=
utf8
--routines
--login-path
=
$1
$2
>
${
3
}
$CMD_MYSQL_DUMP
$1
--opt
--default-character-set
=
utf8
--routines
$2
>
${
3
}
success
success
}
}
...
@@ -56,7 +57,7 @@ function backup {
...
@@ -56,7 +57,7 @@ function backup {
DATE
=
$(
date
-u
--rfc-3339
=
ns |
sed
's/ /T/g'
)
DATE
=
$(
date
-u
--rfc-3339
=
ns |
sed
's/ /T/g'
)
BACKUPFILE
=
${
BACKUPDIR
}
/
${
DATABASE
}
.
${
DATE
}
.dump.sql
BACKUPFILE
=
${
BACKUPDIR
}
/
${
DATABASE
_NAME
}
.
${
DATE
}
.dump.sql
backup
$
LOGIN_PATH
$DATABASE
$BACKUPFILE
backup
$
MYSQL_CONNECTION
$DATABASE
_NAME
$BACKUPFILE
This diff is collapsed.
Click to expand it.
patches/utils/patch_header.sh
+
16
−
16
View file @
c0542b35
...
@@ -28,13 +28,13 @@ CMD_OPTIONS="options:\n\n-h, --help\n\tShow brief help.\n-l LOGIN_PATH, --login-
...
@@ -28,13 +28,13 @@ CMD_OPTIONS="options:\n\n-h, --help\n\tShow brief help.\n-l LOGIN_PATH, --login-
set
-e
set
-e
function
_print_help
()
{
function
_print_help
()
{
printf
$USAGE
printf
"
$USAGE
"
printf
$CMD_OPTIONS
printf
"
$CMD_OPTIONS
"
if
[
-n
"
$PRINT_HELP
"
]
;
then
if
[
-n
"
$PRINT_HELP
"
]
;
then
printf
$PRINT_HELP
printf
--
"
$PRINT_HELP
"
fi
fi
if
[
-n
"
$1
"
]
;
then
if
[
-n
"
$1
"
]
;
then
printf
$1
printf
"
$1
"
fi
fi
}
}
while
test
$#
-gt
0
;
do
while
test
$#
-gt
0
;
do
...
@@ -60,7 +60,7 @@ while test $# -gt 0; do
...
@@ -60,7 +60,7 @@ while test $# -gt 0; do
-u
)
-u
)
shift
shift
if
test
$#
-gt
0
;
then
if
test
$#
-gt
0
;
then
D
B
USER
=
$1
D
ATABASE_
USER
=
$1
else
else
echo
"no database specified"
echo
"no database specified"
exit
1
exit
1
...
@@ -68,7 +68,7 @@ while test $# -gt 0; do
...
@@ -68,7 +68,7 @@ while test $# -gt 0; do
shift
shift
;;
;;
--user
*
)
--user
*
)
D
B
USER
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
D
ATABASE_
USER
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
shift
shift
;;
;;
-l
)
-l
)
...
@@ -88,7 +88,7 @@ while test $# -gt 0; do
...
@@ -88,7 +88,7 @@ while test $# -gt 0; do
-d
)
-d
)
shift
shift
if
test
$#
-gt
0
;
then
if
test
$#
-gt
0
;
then
DATABASE
=
$1
DATABASE
_NAME
=
$1
else
else
echo
"no database specified"
echo
"no database specified"
exit
1
exit
1
...
@@ -96,7 +96,7 @@ while test $# -gt 0; do
...
@@ -96,7 +96,7 @@ while test $# -gt 0; do
shift
shift
;;
;;
--database
*
)
--database
*
)
DATABASE
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
DATABASE
_NAME
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
shift
shift
;;
;;
--patch
*
)
--patch
*
)
...
@@ -113,9 +113,9 @@ while test $# -gt 0; do
...
@@ -113,9 +113,9 @@ while test $# -gt 0; do
esac
esac
done
done
if
[
-z
"
$DATABASE
"
]
if
[
-z
"
$DATABASE
_NAME
"
]
then
then
print_help
"Please specify the database."
_
print_help
"Please specify the database."
exit
1
exit
1
fi
fi
...
@@ -124,7 +124,7 @@ then
...
@@ -124,7 +124,7 @@ then
MYSQL_CONNECTION
=
"--login-path=
$LOGIN_PATH
"
MYSQL_CONNECTION
=
"--login-path=
$LOGIN_PATH
"
else
else
MYSQL_CONNECTION
=
""
MYSQL_CONNECTION
=
""
if
[
"
$D
B
USER
"
]
if
[
"
$D
ATABASE_
USER
"
]
then
then
MYSQL_CONNECTION
=
"--user=
$DBUSER
"
MYSQL_CONNECTION
=
"--user=
$DBUSER
"
fi
fi
...
@@ -135,7 +135,7 @@ else
...
@@ -135,7 +135,7 @@ else
fi
fi
if
[
-n
"
$PATCH
"
]
;
then
if
[
-n
"
$PATCH
"
]
;
then
echo
-ne
"applying patch
$PATCH
to
$DATABASE
... "
echo
-ne
"applying patch
$PATCH
to
$DATABASE
_NAME
... "
fi
fi
function
success
{
function
success
{
...
@@ -155,7 +155,7 @@ function uptodate {
...
@@ -155,7 +155,7 @@ function uptodate {
# @param $1: db version string, e.g. v2.0.0
# @param $1: db version string, e.g. v2.0.0
# @return: 0 on success, 1 on failure
# @return: 0 on success, 1 on failure
function
check_version
{
function
check_version
{
local
version
=
$(
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
-B
-e
"Select CaosDBVersion();"
)
local
version
=
$(
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
_NAME
-B
-e
"Select CaosDBVersion();"
)
if
[[
"
$(
echo
$version
|
sed
's/^CaosDBVersion()\s//'
)
"
=
"
$1
"
]]
;
then
if
[[
"
$(
echo
$version
|
sed
's/^CaosDBVersion()\s//'
)
"
=
"
$1
"
]]
;
then
return
0
return
0
fi
fi
...
@@ -168,13 +168,13 @@ function update_version {
...
@@ -168,13 +168,13 @@ function update_version {
}
}
function
dump_table
{
function
dump_table
{
$CMD_MYSQL_DUMP
$MYSQL_CONNECTION
$DATABASE
$1
>
${
DATABASE
}
.
${
1
}
.
${
OLD_VERSION
}
.dump.sql
$CMD_MYSQL_DUMP
$MYSQL_CONNECTION
$DATABASE
_NAME
$1
>
${
DATABASE
_NAME
}
.
${
1
}
.
${
OLD_VERSION
}
.dump.sql
}
}
function
mysql_execute
{
function
mysql_execute
{
set
+e
set
+e
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
-e
"
$1
"
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
_NAME
-e
"
$1
"
ret
=
${
PIPESTATUS
[0]
}
ret
=
${
PIPESTATUS
[0]
}
if
[
"
$ret
"
-ne
0
]
;
then
if
[
"
$ret
"
-ne
0
]
;
then
failure
"MYSQL ERROR"
failure
"MYSQL ERROR"
...
@@ -183,5 +183,5 @@ function mysql_execute {
...
@@ -183,5 +183,5 @@ function mysql_execute {
}
}
function
redo_table
{
function
redo_table
{
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
<
${
DATABASE
}
.
${
1
}
.
${
OLD_VERSION
}
.dump.sql
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
_NAME
<
${
DATABASE
_NAME
}
.
${
1
}
.
${
OLD_VERSION
}
.dump.sql
}
}
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