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
5e52dbbe
Commit
5e52dbbe
authored
4 years ago
by
Hahn Axel (hahn)
Browse files
Options
Downloads
Patches
Plain Diff
update restore.sh and restic plugin
parent
bc12652d
No related branches found
No related tags found
1 merge request
!1
Version 2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
plugins/transfer/restic.sh
+2
-4
2 additions, 4 deletions
plugins/transfer/restic.sh
restore.sh
+30
-45
30 additions, 45 deletions
restore.sh
with
32 additions
and
49 deletions
plugins/transfer/restic.sh
+
2
−
4
View file @
5e52dbbe
...
@@ -218,19 +218,17 @@
...
@@ -218,19 +218,17 @@
color cmd
color cmd
t_cmdShowVolumes
t_cmdShowVolumes
color reset
color reset
showPrompt
"ID of the snapshot to restore from [
$RESTORE_ITEM
] >"
showPrompt
"ID of the snapshot
or
\"
latest
\"
to restore from [
$RESTORE_ITEM
] >"
read
_selid
read
_selid
test
-z
"
$_selid
"
&&
_selid
=
$RESTORE_ITEM
test
-z
"
$_selid
"
&&
_selid
=
$RESTORE_ITEM
RESTORE_ITEM
=
$_selid
RESTORE_ITEM
=
$_selid
echo
using
\"
$RESTORE_ITEM
\"
echo
using
\"
$RESTORE_ITEM
\"
RESTORE_ITEMINFO
=
$(
t_cmdShowVolumes |
grep
"^
$RESTORE_ITEM
"
|
awk
'{ print $2 " " $3} '
)
echo
echo
}
}
# set a filter to reduce count of files to restore
# set a filter to reduce count of files to restore
function
t_restoreFilter
(){
function
t_restoreFilter
(){
local
_inc
=
local
_inc
=
echo
"--- Filter:"
echo
"By default all files will be restored."
echo
"You can limit it by setting include rules."
echo
"You can enter ..."
echo
"You can enter ..."
echo
" - a single directory name anywhere in the folderstructure"
echo
" - a single directory name anywhere in the folderstructure"
echo
" - a filename without path"
echo
" - a filename without path"
...
...
This diff is collapsed.
Click to expand it.
restore.sh
+
30
−
45
View file @
5e52dbbe
...
@@ -163,42 +163,9 @@ function setVars(){
...
@@ -163,42 +163,9 @@ function setVars(){
# sTarget=`j_getFullTarget "$sDir2restore"`
# sTarget=`j_getFullTarget "$sDir2restore"`
sRestorepath
=
"
${
RESTORE_BASEDIR
}
/
${
sSafeName
}
"
sRestorepath
=
"
${
RESTORE_BASEDIR
}
/
${
sSafeName
}
"
if
[
!
-z
$sRestoreItem
]
;
then
echo
${
sRestoreItem
}
|
grep
'\*'
>
/dev/null
if
[
$?
-eq
0
]
;
then
sRestoreItem
=
`
dirname
$sRestoreItem
|
sed
's#^\.##'
`
color error
echo
ERROR: using a placeholder is not allowed. Using the directory above.
echo
[
$sRestoreItem
]
color reset
fi
sRestorepath
=
"
${
sRestorepath
}
/
${
sRestoreItem
}
"
fi
}
}
function
doRestore
(){
# --------------------------------------------------------------------------------
# MAIN
# --------------------------------------------------------------------------------
h1
"RESTORE - GET FILES FROM STORAGE"
# ----- set a directory to restore to have a useful initial point
setBackupDir
$1
if
[
-z
$sDir2restore
]
;
then
enterBackupDir
fi
# ----- make inputs
t_restoreSelect
t_restoreFilter
# ----- get restore command:
restorecmd
=
$(
t_cmdRestore
)
restorecmd
=
$(
t_cmdRestore
)
if
[
-z
"
$restorecmd
"
]
;
then
if
[
-z
"
$restorecmd
"
]
;
then
color error
color error
...
@@ -208,11 +175,6 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -208,11 +175,6 @@ h1 "RESTORE - GET FILES FROM STORAGE"
exit
1
exit
1
fi
fi
echo
echo
---
Restore:
echo
$restorecmd
echo
"RETURN to start restore ... or Ctrl + C to abort"
read
dummy
mkdir
-p
"
${
sRestorepath
}
"
mkdir
-p
"
${
sRestorepath
}
"
color cmd
color cmd
$restorecmd
$restorecmd
...
@@ -230,6 +192,21 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -230,6 +192,21 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo
find
${
sRestorepath
}
echo
find
${
sRestorepath
}
exit
exit
}
# --------------------------------------------------------------------------------
# MAIN
# --------------------------------------------------------------------------------
# ----- set a directory to restore to have a useful initial point
t_checkRequirements
setBackupDir
$1
if
[
-z
$sDir2restore
]
;
then
enterBackupDir
fi
# ----- menu and loop
# ----- menu and loop
...
@@ -244,8 +221,13 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -244,8 +221,13 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo
echo
echo
" D - directory to restore:
$sDir2restore
"
echo
" D - directory to restore:
$sDir2restore
"
echo
" W - time or snapshot ID :
$RESTORE_ITEM
"
echo
-n
" W - time or snapshot ID :
$RESTORE_ITEM
"
echo
" F - what to restore :
$RESTORE_FILTER
"
test
-z
"
$RESTORE_ITEM
"
&&
echo
-n
" ... set it"
test
-z
"
$RESTORE_ITEMINFO
"
||
echo
-n
" (
$RESTORE_ITEMINFO
)"
echo
echo
-n
" F - what to restore :
$RESTORE_FILTER
"
test
-z
"
$RESTORE_FILTER
"
&&
echo
-n
"(no filter = restore all files)"
echo
echo
echo
# echo " C - show file changes"
# echo " C - show file changes"
# echo " S - search file"
# echo " S - search file"
...
@@ -256,7 +238,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -256,7 +238,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo
echo
echo
" restore from :
$sTarget
"
echo
" restore from :
$sTarget
"
echo
" restore to :
$sRestorepath
"
echo
" restore to :
$sRestorepath
"
echo
-n
" "
echo
-n
"
"
ls
-d
$sRestorepath
>
/dev/null 2>&1
ls
-d
$sRestorepath
>
/dev/null 2>&1
if
[
$?
-eq
0
]
;
then
if
[
$?
-eq
0
]
;
then
color error
color error
...
@@ -269,9 +251,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -269,9 +251,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo
" X - exit"
echo
" X - exit"
echo
echo
color input
showPrompt
"Select (not case sensitive) --> "
echo
-n
"Select (not case sensitive) --> "
color reset
read
action
read
action
echo
echo
...
@@ -280,6 +260,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -280,6 +260,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
enterBackupDir
enterBackupDir
;;
;;
w|W
)
w|W
)
h2
"Set a time / select a snapshot"
t_restoreSelect
t_restoreSelect
;;
;;
c|C
)
c|C
)
...
@@ -297,9 +278,13 @@ h1 "RESTORE - GET FILES FROM STORAGE"
...
@@ -297,9 +278,13 @@ h1 "RESTORE - GET FILES FROM STORAGE"
bash
bash
;;
;;
f|F
)
f|F
)
h2
"Filter restore items"
echo
"By default all files will be restored."
echo
"You can limit it by setting include rules."
t_restoreFilter
t_restoreFilter
;;
;;
r|R
)
r|R
)
h2
"Start restore"
doRestore
doRestore
;;
;;
x|X
)
x|X
)
...
...
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