diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index a6000cf..04152df 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -4,15 +4,15 @@ "fsPath": "$ROOTPATH$/borghelper.sh", "bookmarks": [ -1, - 215, - 232, + 268, + 10, -1, -1, -1, -1, -1, -1, - 169 + 384 ] } ] diff --git a/borghelper.sh b/borghelper.sh index 9af2f54..086ef40 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -266,6 +266,21 @@ fi 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 ! touch "${restorePath}/touch.test" > /dev/null 2>&1; then + consoleError 5 'Cannot write to specified restore directory.' + fi + fi +fi + ### read borg information file @@ -372,6 +387,7 @@ exit 0 # 1: parameter error (missing, non-existant or invalid input) # 2: parameter missing/invalid in .borgvars file # 3: could not create/remove borg tmp directory +# 4: could not write sample borgvars file (permissions?) +# 5: cannot create/write to restore path or could not remove touch.test file -#EOF# 4: could not write sample borgvars file (permissions?) -# 5: cannot create/write to restore path +#EOF \ No newline at end of file