add restore operation

This commit is contained in:
Asif Bacchus 2020-03-26 04:33:16 -06:00
parent 07fdd04754
commit f80a66439c
2 changed files with 17 additions and 4 deletions

View File

@ -4,7 +4,7 @@
"fsPath": "$ROOTPATH$/borghelper.sh", "fsPath": "$ROOTPATH$/borghelper.sh",
"bookmarks": [ "bookmarks": [
-1, -1,
222, 231,
-1, -1,
-1, -1,
-1, -1,

View File

@ -49,9 +49,9 @@ fi
### pre-requisites ### pre-requisites
# is user root? # is user root?
if [ ! "$( id -u )" -eq 0 ]; then #if [ ! "$( id -u )" -eq 0 ]; then
consoleError 1 'You must be root to run this script.' # consoleError 1 'You must be root to run this script.'
fi #fi
# has a parameter been passed to this script? # has a parameter been passed to this script?
if [ -z "$1" ]; then if [ -z "$1" ]; then
@ -229,6 +229,19 @@ elif [ "$operation" = 'viewarchive' ]; then
borg list ::"${archiveName}" borg list ::"${archiveName}"
fi fi
# restore operations
if [ "$operation" = 'restore' ]; then
if [ -z "$fileName" ]; then
# restore entire archive
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc extract --list ::"${archiveName}"
elif [ "$fileName" ]; then
# restore single file
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc extract --list ::"${archiveName}" "${fileName}"
fi
fi
### exit gracefully ### exit gracefully
cleanup cleanup