add progress and file-list options as switches

This commit is contained in:
Asif Bacchus 2020-03-26 04:40:36 -06:00
parent f80a66439c
commit 39f519a67e
2 changed files with 15 additions and 3 deletions

View File

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

View File

@ -99,6 +99,10 @@ while [ $# -gt 0 ]; do
restorePath="${2%/}"
shift
;;
--progress)
# show progress
commonOptions="$commonOptions --progress"
;;
-r|--restore)
# restore archive/file
operation='restore'
@ -114,6 +118,10 @@ while [ $# -gt 0 ]; do
varsFile="$2"
shift
;;
--verbose)
# display each file being processed
restoreOptions="$restoreOptions --list"
;;
*)
# invalid option
printf "%s\nUnknown option: %s\n" "$err" "$1"
@ -155,6 +163,10 @@ if [ "$fileName" ] && [ -z "$archiveName" ]; then
consoleError 1 "Filename specified without an associated archive name."
fi
# clean-up leading spaces in option strings
commonOptions=${commonOptions##[[:space:]]}
restoreOptions=${restoreOptions##[[:space:]]}
### read borg information file
@ -234,11 +246,11 @@ 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}"
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}"
elif [ "$fileName" ]; then
# restore single file
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc extract --list ::"${archiveName}" "${fileName}"
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}" "${fileName}"
fi
fi