create restorePath if it does not exist

This commit is contained in:
Asif Bacchus 2020-03-26 06:44:38 -06:00
parent cfd7d6ede0
commit 7cc69a616a
2 changed files with 21 additions and 5 deletions

View File

@ -4,15 +4,15 @@
"fsPath": "$ROOTPATH$/borghelper.sh",
"bookmarks": [
-1,
215,
232,
268,
10,
-1,
-1,
-1,
-1,
-1,
-1,
169
384
]
}
]

View File

@ -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