Compare commits
No commits in common. "9ef05505a62eaf783995ae6382262ae6fd1e4786" and "91359306aae0d03e7e7c46f2f201f85c1b961393" have entirely different histories.
9ef05505a6
...
91359306aa
4
.vscode/numbered-bookmarks.json
vendored
4
.vscode/numbered-bookmarks.json
vendored
@ -4,15 +4,15 @@
|
|||||||
"fsPath": "$ROOTPATH$/borghelper.sh",
|
"fsPath": "$ROOTPATH$/borghelper.sh",
|
||||||
"bookmarks": [
|
"bookmarks": [
|
||||||
-1,
|
-1,
|
||||||
|
253,
|
||||||
151,
|
151,
|
||||||
168,
|
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
-1,
|
-1,
|
||||||
105
|
84
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -49,9 +49,9 @@ fi
|
|||||||
### pre-requisites
|
### pre-requisites
|
||||||
|
|
||||||
# is user root?
|
# is user root?
|
||||||
if [ ! "$( id -u )" -eq 0 ]; then
|
#if [ ! "$( id -u )" -eq 0 ]; then
|
||||||
consoleError 1 'You must be root to run this script.'
|
# consoleError 1 'You must be root to run this script.'
|
||||||
fi
|
#fi
|
||||||
|
|
||||||
# has a parameter been passed to this script?
|
# has a parameter been passed to this script?
|
||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
@ -69,14 +69,6 @@ while [ $# -gt 0 ]; do
|
|||||||
archiveName="$2"
|
archiveName="$2"
|
||||||
shift
|
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)
|
-f|--file)
|
||||||
# specific file to restore
|
# specific file to restore
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
@ -103,10 +95,6 @@ while [ $# -gt 0 ]; do
|
|||||||
# list all backup archives
|
# list all backup archives
|
||||||
operation='listall'
|
operation='listall'
|
||||||
;;
|
;;
|
||||||
--makevars)
|
|
||||||
# make a borgvars template file
|
|
||||||
operation='makevars'
|
|
||||||
;;
|
|
||||||
-p|--path)
|
-p|--path)
|
||||||
# path to restore files
|
# path to restore files
|
||||||
if [ -z "$2" ]; then
|
if [ -z "$2" ]; then
|
||||||
@ -149,15 +137,6 @@ while [ $# -gt 0 ]; do
|
|||||||
done
|
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
|
### check parameter validity
|
||||||
|
|
||||||
# no operation
|
# no operation
|
||||||
@ -194,8 +173,8 @@ if [ "$fileName" ] && [ -z "$archiveName" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# clean-up leading spaces in option strings
|
# clean-up leading spaces in option strings
|
||||||
if [ "$commonOptions" ]; then commonOptions=${commonOptions##[[:space:]]}; fi
|
commonOptions=${commonOptions##[[:space:]]}
|
||||||
if [ "$restoreOptions" ]; then restoreOptions=${restoreOptions##[[:space:]]}; fi
|
restoreOptions=${restoreOptions##[[:space:]]}
|
||||||
|
|
||||||
|
|
||||||
### read borg information file
|
### read borg information file
|
||||||
@ -274,21 +253,14 @@ elif [ "$operation" = 'viewarchive' ]; then
|
|||||||
borg list ::"${archiveName}"
|
borg list ::"${archiveName}"
|
||||||
# restore operations
|
# restore operations
|
||||||
elif [ "$operation" = 'restore' ]; then
|
elif [ "$operation" = 'restore' ]; then
|
||||||
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
|
|
||||||
if [ -z "$fileName" ]; then
|
if [ -z "$fileName" ]; then
|
||||||
# restore entire archive
|
# restore entire archive
|
||||||
if [ "$exclusions" ]; then
|
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
|
||||||
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" --exclude "${exclusions}"
|
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}"
|
||||||
else
|
|
||||||
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}"
|
|
||||||
fi
|
|
||||||
elif [ "$fileName" ]; then
|
elif [ "$fileName" ]; then
|
||||||
# restore file/pattern
|
# restore single file
|
||||||
if [ "$exclusions" ]; then
|
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'
|
||||||
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}" --exclude "${exclusions}"
|
borg --show-rc "$commonOptions" extract "$restoreOptions" ::"${archiveName}" "${fileName}"
|
||||||
else
|
|
||||||
borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user