From bcb6c9c5efdef95011f0283d309f3f9c7fa8213b Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 26 Mar 2020 05:37:03 -0600 Subject: [PATCH] fix option string spacing issues, unquote them! --- .vscode/numbered-bookmarks.json | 6 +++--- borghelper.sh | 16 ++++++++++++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index e6b9404..b575bcb 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -4,15 +4,15 @@ "fsPath": "$ROOTPATH$/borghelper.sh", "bookmarks": [ -1, - 253, - 151, + 261, + 159, -1, -1, -1, -1, -1, -1, - 84 + 92 ] } ] diff --git a/borghelper.sh b/borghelper.sh index acaaac3..7b8b856 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -69,6 +69,14 @@ while [ $# -gt 0 ]; do archiveName="$2" shift ;; + --exclude) + # exclude files from restore + if [ -z "$2" ]; then + consoleError 1 "Please provide a list of exclusions in the proper borg format." + fi + exclusions="$2" + shift + ;; -f|--file) # specific file to restore if [ -z "$2" ]; then @@ -173,8 +181,8 @@ if [ "$fileName" ] && [ -z "$archiveName" ]; then fi # clean-up leading spaces in option strings -commonOptions=${commonOptions##[[:space:]]} -restoreOptions=${restoreOptions##[[:space:]]} +if [ "$commonOptions" ]; then commonOptions=${commonOptions##[[:space:]]}; fi +if [ "$restoreOptions" ]; then restoreOptions=${restoreOptions##[[:space:]]}; fi ### read borg information file @@ -256,11 +264,11 @@ elif [ "$operation" = 'restore' ]; then if [ -z "$fileName" ]; then # restore entire archive cd "$restorePath" || consoleError 4 'Could not change to restore directory.' - borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${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 "$commonOptions" extract "$restoreOptions" ::"${archiveName}" "${fileName}" + borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}" fi fi