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
ccd2f6fc
Commit
ccd2f6fc
authored
1 year ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
add selector fore restore
parent
f3c8405d
Branches
Branches containing commit
No related tags found
1 merge request
!129
Db Profiles
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
localdump.sh
+39
-9
39 additions, 9 deletions
localdump.sh
with
39 additions
and
9 deletions
localdump.sh
+
39
−
9
View file @
ccd2f6fc
...
@@ -46,6 +46,7 @@
...
@@ -46,6 +46,7 @@
LOCALDUMP_LOADED
=
1
LOCALDUMP_LOADED
=
1
ARCHIVE_BASEDIR
=
BACKUP_BASEDIR
=
BACKUP_BASEDIR
=
BACKUP_PLUGINDIR
=
BACKUP_PLUGINDIR
=
...
@@ -183,7 +184,10 @@
...
@@ -183,7 +184,10 @@
# restore: show profiles from that exist backups
# restore: show profiles from that exist backups
# global string BACKUP_BASEDIR base directory of all backups
# global string BACKUP_BASEDIR base directory of all backups
function
listBackupedServices
(){
function
listBackupedServices
(){
find
"
${
BACKUP_BASEDIR
}
"
-mindepth
1
-maxdepth
1
-type
d |
sed
"s#^
${
BACKUP_BASEDIR
}
/##g"
|
sort
|
grep
"^[a-z]"
(
find
"
${
BACKUP_BASEDIR
}
"
-mindepth
1
-maxdepth
1
-type
d
-exec
basename
{}
\;
test
-n
"
${
ARCHIVE_BASEDIR
}
"
&&
find
"
${
ARCHIVE_BASEDIR
}
"
-mindepth
1
-maxdepth
1
-type
d
-exec
basename
{}
\;
)
|
sort
-u
}
}
# ------------------------------------------------------------
# ------------------------------------------------------------
...
@@ -341,7 +345,7 @@
...
@@ -341,7 +345,7 @@
fi
fi
# -----
db
init
# ----- init
vars
BACKUP_BASEDIR
=
$(
_j_getvar
"
${
JOBFILE
}
"
"dir-localdumps"
)
BACKUP_BASEDIR
=
$(
_j_getvar
"
${
JOBFILE
}
"
"dir-localdumps"
)
# check
# check
...
@@ -350,6 +354,8 @@
...
@@ -350,6 +354,8 @@
echo
There must be an entry dir-localdumps
in
${
JOBFILE
}
echo
There must be an entry dir-localdumps
in
${
JOBFILE
}
exit
1
exit
1
fi
fi
ARCHIVE_BASEDIR
=
$(
_j_getvar
"
${
JOBFILE
}
"
dir-dbarchive
)
BACKUP_PLUGINDIR
=
$(
dirname
$0
)
/plugins/localdump
BACKUP_PLUGINDIR
=
$(
dirname
$0
)
/plugins/localdump
DBD_BASEDIR
=
$BACKUP_PLUGINDIR
/profiles
DBD_BASEDIR
=
$BACKUP_PLUGINDIR
/profiles
...
@@ -411,7 +417,7 @@
...
@@ -411,7 +417,7 @@
BACKUP_PARAMS
=
$(
dbdetect.getParams
)
BACKUP_PARAMS
=
$(
dbdetect.getParams
)
BACKUP_TARGETDIR
=
${
BACKUP_BASEDIR
}
/
${
PROFILENAME
}
BACKUP_TARGETDIR
=
${
BACKUP_BASEDIR
}
/
${
PROFILENAME
}
ARCHIVE_DIR
=
$
(
_j_getvar
"
${
JOBFILE
}
"
dir-dbarchive
)
/
${
PROFILENAME
}
ARCHIVE_DIR
=
$
{
ARCHIVE_BASEDIR
}
/
${
PROFILENAME
}
BACKUP_SCRIPT
=
$(
get_service_script
${
SERVICENAME
}
)
BACKUP_SCRIPT
=
$(
get_service_script
${
SERVICENAME
}
)
...
@@ -456,10 +462,10 @@
...
@@ -456,10 +462,10 @@
h1
"RESTORE DATABASE"
h1
"RESTORE DATABASE"
if
!
listBackupedServices
;
then
if
!
listBackupedServices
|
grep
-q
.
;
then
color.echo error
"ERROR: No database dump was found in [
${
BACKUP_BASEDIR
}
]."
color.echo error
"ERROR: No database dump was found in [
${
BACKUP_BASEDIR
}
]
nor [
${
ARCHIVE_BASEDIR
}
]
."
exit
1
exit
1
fi
fi
if
[
-z
$1
]
||
[
!
-f
"
$1
"
]
;
then
if
[
-z
$1
]
||
[
!
-f
"
$1
"
]
;
then
...
@@ -468,6 +474,14 @@
...
@@ -468,6 +474,14 @@
# ----- interactive selections
# ----- interactive selections
h2
"Select profile that has a dump"
h2
"Select profile that has a dump"
if
[
-z
"
${
parService
}
"
]
;
then
if
[
"
$(
listBackupedServices |
wc
-l
)
"
-eq
1
]
;
then
parService
=
"
$(
listBackupedServices
)
"
echo
"Selecting the only existing profile:
$parService
"
fi
fi
if
[
-z
"
${
parService
}
"
]
;
then
if
[
-z
"
${
parService
}
"
]
;
then
listBackupedServices
listBackupedServices
color.print input
"Restore for profile name >"
color.print input
"Restore for profile name >"
...
@@ -482,15 +496,30 @@
...
@@ -482,15 +496,30 @@
color.echo error
"ERROR: profile [
${
parService
}
] is not known here (or database service is stopped)."
color.echo error
"ERROR: profile [
${
parService
}
] is not known here (or database service is stopped)."
echo
echo
echo
"Existing database profiles:"
echo
"Existing database profiles:"
get_database_profiles
get_database_profiles |
nl
echo
exit
1
exit
1
fi
fi
# ----- check if dump exists in archive and in backup
if
[
-d
"
${
BACKUP_BASEDIR
}
/
${
parService
}
"
]
&&
[
-d
"
${
ARCHIVE_BASEDIR
}
/
${
parService
}
"
]
;
then
echo
echo
"Backup
${
BACKUP_BASEDIR
}
"
echo
"Archive
${
ARCHIVE_BASEDIR
}
"
color.print input
"Select a source directory >"
read
-r
backupsource
test
-z
"
$backupsource
"
&&
exit
1
BACKUP_BASEDIR
=
"
${
backupsource
}
"
else
# just one test needed because BACKUP_BASEDIR is BACKUP_BASEDIR
test
-d
"
${
ARCHIVE_BASEDIR
}
/
${
parService
}
"
&&
BACKUP_BASEDIR
=
"
${
ARCHIVE_BASEDIR
}
/
${
parService
}
"
fi
if
[
!
-d
"
${
BACKUP_BASEDIR
}
/
${
parService
}
"
]
;
then
if
[
!
-d
"
${
BACKUP_BASEDIR
}
/
${
parService
}
"
]
;
then
color.echo error
"ERROR: profile
${
parService
}
has no backup yet."
color.echo error
"ERROR: profile
${
parService
}
has no backup yet."
exit
1
exit
1
fi
fi
BACKUP_TARGETDIR
=
"
${
BACKUP_BASEDIR
}
/
${
parService
}
"
BACKUP_TARGETDIR
=
"
${
BACKUP_BASEDIR
}
/
${
parService
}
"
h2
"Select database"
h2
"Select database"
...
@@ -541,6 +570,7 @@
...
@@ -541,6 +570,7 @@
BACKUP_PARAMS
=
$(
dbdetect.getParams
)
BACKUP_PARAMS
=
$(
dbdetect.getParams
)
eval
$(
dbdetect.setenv
)
eval
$(
dbdetect.setenv
)
h2
$BACKUP_SCRIPT
$mode
"
${
sDumpfile
}
"
"
${
sTargetDb
}
"
.
$BACKUP_SCRIPT
$mode
"
${
sDumpfile
}
"
"
${
sTargetDb
}
"
.
$BACKUP_SCRIPT
$mode
"
${
sDumpfile
}
"
"
${
sTargetDb
}
"
if
[
$?
-ne
0
-o
$rc
-ne
0
]
;
then
if
[
$?
-ne
0
-o
$rc
-ne
0
]
;
then
...
...
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