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",
"bookmarks": [
-1,
222,
231,
-1,
-1,
-1,

View File

@ -49,9 +49,9 @@ fi
### pre-requisites
# is user root?
if [ ! "$( id -u )" -eq 0 ]; then
consoleError 1 'You must be root to run this script.'
fi
#if [ ! "$( id -u )" -eq 0 ]; then
# consoleError 1 'You must be root to run this script.'
#fi
# has a parameter been passed to this script?
if [ -z "$1" ]; then
@ -229,6 +229,19 @@ elif [ "$operation" = 'viewarchive' ]; then
borg list ::"${archiveName}"
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
cleanup