Compare commits

..

No commits in common. "9ef05505a62eaf783995ae6382262ae6fd1e4786" and "91359306aae0d03e7e7c46f2f201f85c1b961393" have entirely different histories.

2 changed files with 12 additions and 40 deletions

View File

@ -4,15 +4,15 @@
"fsPath": "$ROOTPATH$/borghelper.sh",
"bookmarks": [
-1,
253,
151,
168,
-1,
-1,
-1,
-1,
-1,
-1,
105
84
]
}
]

View File

@ -49,9 +49,9 @@ fi
### pre-requisites
# is user root?
if [ ! "$( id -u )" -eq 0 ]; then
consoleError 1 'You must be root to run this script.'
fi
#if [ ! "$( id -u )" -eq 0 ]; then
# consoleError 1 'You must be root to run this script.'
#fi
# has a parameter been passed to this script?
if [ -z "$1" ]; then
@ -69,14 +69,6 @@ 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
@ -103,10 +95,6 @@ while [ $# -gt 0 ]; do
# list all backup archives
operation='listall'
;;
--makevars)
# make a borgvars template file
operation='makevars'
;;
-p|--path)
# path to restore files
if [ -z "$2" ]; then
@ -149,15 +137,6 @@ while [ $# -gt 0 ]; do
done
### process 'makevars' operation
if [ "$operation" = 'makevars' ]; then
if ! printf "sshKeyFile=\nborgBaseDir=\nborgRepo=\nborgRepoPassword=\nborgRemote=\n" > ./sample.borgvars; then
consoleError 4 'Could not write sample borgvars file.'
else
exit 0
fi
fi
### check parameter validity
# no operation
@ -194,8 +173,8 @@ if [ "$fileName" ] && [ -z "$archiveName" ]; then
fi
# clean-up leading spaces in option strings
if [ "$commonOptions" ]; then commonOptions=${commonOptions##[[:space:]]}; fi
if [ "$restoreOptions" ]; then restoreOptions=${restoreOptions##[[:space:]]}; fi
commonOptions=${commonOptions##[[:space:]]}
restoreOptions=${restoreOptions##[[:space:]]}
### read borg information file
@ -274,21 +253,14 @@ elif [ "$operation" = 'viewarchive' ]; then
borg list ::"${archiveName}"
# restore operations
elif [ "$operation" = 'restore' ]; then
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
if [ -z "$fileName" ]; then
# restore entire archive
if [ "$exclusions" ]; then
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" --exclude "${exclusions}"
else
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}"
fi
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}"
elif [ "$fileName" ]; then
# restore file/pattern
if [ "$exclusions" ]; then
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}" --exclude "${exclusions}"
else
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}"
fi
# restore single file
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}" "${fileName}"
fi
fi