Skip to content
Snippets Groups Projects
Commit 5e52dbbe authored by Hahn Axel (hahn)'s avatar Hahn Axel (hahn)
Browse files

update restore.sh and restic plugin

parent bc12652d
No related branches found
No related tags found
1 merge request!1Version 2
......@@ -218,19 +218,17 @@
color cmd
t_cmdShowVolumes
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
test -z "$_selid" && _selid=$RESTORE_ITEM
RESTORE_ITEM=$_selid
echo using \"$RESTORE_ITEM\"
RESTORE_ITEMINFO=$( t_cmdShowVolumes | grep "^$RESTORE_ITEM" | awk '{ print $2 " " $3} ' )
echo
}
# set a filter to reduce count of files to restore
function t_restoreFilter(){
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 " - a single directory name anywhere in the folderstructure"
echo " - a filename without path"
......
......@@ -163,42 +163,9 @@ function setVars(){
# sTarget=`j_getFullTarget "$sDir2restore"`
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
}
# --------------------------------------------------------------------------------
# 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:
function doRestore(){
restorecmd=$( t_cmdRestore )
if [ -z "$restorecmd" ]; then
color error
......@@ -208,11 +175,6 @@ h1 "RESTORE - GET FILES FROM STORAGE"
exit 1
fi
echo
echo --- Restore:
echo $restorecmd
echo "RETURN to start restore ... or Ctrl + C to abort"
read dummy
mkdir -p "${sRestorepath}"
color cmd
$restorecmd
......@@ -230,6 +192,21 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo find ${sRestorepath}
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
......@@ -244,8 +221,13 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo
echo " D - directory to restore: $sDir2restore"
echo " W - time or snapshot ID : $RESTORE_ITEM"
echo " F - what to restore : $RESTORE_FILTER"
echo -n " W - time or snapshot ID : $RESTORE_ITEM"
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 " C - show file changes"
# echo " S - search file"
......@@ -269,9 +251,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
echo " X - exit"
echo
color input
echo -n "Select (not case sensitive) --> "
color reset
showPrompt "Select (not case sensitive) --> "
read action
echo
......@@ -280,6 +260,7 @@ h1 "RESTORE - GET FILES FROM STORAGE"
enterBackupDir
;;
w|W)
h2 "Set a time / select a snapshot"
t_restoreSelect
;;
c|C)
......@@ -297,9 +278,13 @@ h1 "RESTORE - GET FILES FROM STORAGE"
bash
;;
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
;;
r|R)
h2 "Start restore"
doRestore
;;
x|X)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment