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
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
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide 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 @@
#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!
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...
.
patches/utils/patch_header.sh
...
...
@@ -36,12 +37,12 @@ PRINT_HELP="--backupdir=BACKUPDIR\n\tThe directory which the dump is to be store
function
backup
{
# parameters:
login-path
, database, outfile
# parameters:
connection
, database, outfile
if
[
-e
"
$3
"
]
;
then
failure
"dumpfile already exists."
fi
echo
-n
"Dumping database
$
3
to
$
4
... "
$CMD_MYSQL_DUMP
--opt
--default-character-set
=
utf8
--routines
--login-path
=
$1
$2
>
${
3
}
echo
"Dumping database
$
2
to
$
3
... "
$CMD_MYSQL_DUMP
$1
--opt
--default-character-set
=
utf8
--routines
$2
>
${
3
}
success
}
...
...
@@ -56,7 +57,7 @@ function backup {
DATE
=
$(
date
-u
--rfc-3339
=
ns |
sed
's/ /T/g'
)
BACKUPFILE
=
${
BACKUPDIR
}
/
${
DATABASE
}
.
${
DATE
}
.dump.sql
backup
$
LOGIN_PATH
$DATABASE
$BACKUPFILE
BACKUPFILE
=
${
BACKUPDIR
}
/
${
DATABASE
_NAME
}
.
${
DATE
}
.dump.sql
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-
set
-e
function
_print_help
()
{
printf
$USAGE
printf
$CMD_OPTIONS
printf
"
$USAGE
"
printf
"
$CMD_OPTIONS
"
if
[
-n
"
$PRINT_HELP
"
]
;
then
printf
$PRINT_HELP
printf
--
"
$PRINT_HELP
"
fi
if
[
-n
"
$1
"
]
;
then
printf
$1
printf
"
$1
"
fi
}
while
test
$#
-gt
0
;
do
...
...
@@ -60,7 +60,7 @@ while test $# -gt 0; do
-u
)
shift
if
test
$#
-gt
0
;
then
D
B
USER
=
$1
D
ATABASE_
USER
=
$1
else
echo
"no database specified"
exit
1
...
...
@@ -68,7 +68,7 @@ while test $# -gt 0; do
shift
;;
--user
*
)
D
B
USER
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
D
ATABASE_
USER
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
shift
;;
-l
)
...
...
@@ -88,7 +88,7 @@ while test $# -gt 0; do
-d
)
shift
if
test
$#
-gt
0
;
then
DATABASE
=
$1
DATABASE
_NAME
=
$1
else
echo
"no database specified"
exit
1
...
...
@@ -96,7 +96,7 @@ while test $# -gt 0; do
shift
;;
--database
*
)
DATABASE
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
DATABASE
_NAME
=
`
echo
$1
|
sed
-e
's/^[^=]*=//g'
`
shift
;;
--patch
*
)
...
...
@@ -113,9 +113,9 @@ while test $# -gt 0; do
esac
done
if
[
-z
"
$DATABASE
"
]
if
[
-z
"
$DATABASE
_NAME
"
]
then
print_help
"Please specify the database."
_
print_help
"Please specify the database."
exit
1
fi
...
...
@@ -124,7 +124,7 @@ then
MYSQL_CONNECTION
=
"--login-path=
$LOGIN_PATH
"
else
MYSQL_CONNECTION
=
""
if
[
"
$D
B
USER
"
]
if
[
"
$D
ATABASE_
USER
"
]
then
MYSQL_CONNECTION
=
"--user=
$DBUSER
"
fi
...
...
@@ -135,7 +135,7 @@ else
fi
if
[
-n
"
$PATCH
"
]
;
then
echo
-ne
"applying patch
$PATCH
to
$DATABASE
... "
echo
-ne
"applying patch
$PATCH
to
$DATABASE
_NAME
... "
fi
function
success
{
...
...
@@ -155,7 +155,7 @@ function uptodate {
# @param $1: db version string, e.g. v2.0.0
# @return: 0 on success, 1 on failure
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
return
0
fi
...
...
@@ -168,13 +168,13 @@ function update_version {
}
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
{
set
+e
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
-e
"
$1
"
$CMD_MYSQL
$MYSQL_CONNECTION
-D
$DATABASE
_NAME
-e
"
$1
"
ret
=
${
PIPESTATUS
[0]
}
if
[
"
$ret
"
-ne
0
]
;
then
failure
"MYSQL ERROR"
...
...
@@ -183,5 +183,5 @@ function mysql_execute {
}
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