From d29dec95e210db5e4b870a3311d0088e834f1a3f Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 26 Mar 2020 08:06:01 -0600 Subject: [PATCH] only create restorePath if operation is 'restore' --- borghelper.sh | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/borghelper.sh b/borghelper.sh index 0b03e5d..c78fa05 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -272,21 +272,22 @@ if [ "$commonOptions" ]; then commonOptions=${commonOptions##[[:space:]]}; fi if [ "$restoreOptions" ]; then restoreOptions=${restoreOptions##[[:space:]]}; fi # check/create restore path -if [ -d "$restorePath" ]; then - if ! touch "${restorePath}/touch.test" > /dev/null 2>&1; then - consoleError 5 'Cannot write to specified restore directory.' - fi -else - if ! mkdir -p "${restorePath}" > /dev/null 2>&1; then - consoleError 5 'Cannot create specified restore directory.' - else +if [ "$operation" = 'restore' ]; then + if [ -d "$restorePath" ]; then if ! touch "${restorePath}/touch.test" > /dev/null 2>&1; then - consoleError 5 'Cannot write to specified restore directory.' + consoleError 5 'Cannot write to specified restore directory.' + fi + else + if ! mkdir -p "${restorePath}" > /dev/null 2>&1; then + consoleError 5 'Cannot create specified restore directory.' + else + if ! touch "${restorePath}/touch.test" > /dev/null 2>&1; then + consoleError 5 'Cannot write to specified restore directory.' + fi fi fi fi - ### read borg information file # check if file was provided as a relative or absolute path