diff --git a/.vscode/numbered-bookmarks.json b/.vscode/numbered-bookmarks.json index a33e492..a6000cf 100644 --- a/.vscode/numbered-bookmarks.json +++ b/.vscode/numbered-bookmarks.json @@ -4,15 +4,15 @@ "fsPath": "$ROOTPATH$/borghelper.sh", "bookmarks": [ -1, - 151, - 168, + 215, + 232, -1, -1, -1, -1, -1, -1, - 105 + 169 ] } ] diff --git a/borghelper.sh b/borghelper.sh index 23755e9..66fe8c7 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -23,10 +23,66 @@ consoleError() { exit "$1" } +scriptHelp() { + printf "\n" + textblock "${bold}Usage: borghelper.sh [parameters]${norm}" + printf "\n" + textblock "Simple script to read connection parameters from a flat text file and process borg 'info', 'list' and 'restore' commands without the very long command lines that are required when specifying repo names and passwords, etc." + printf "\n" + textblock "${magenta}The script has the following parameters:${norm}" + printf "\n" + textblock "${magenta}--- Required Parameters ---${norm}" + printf "\n" + ptextblock "-v|--vars" + textblock "Path to the .borgvars file from which to read borg connection information. This is not required if run with '--makevars'." + printf "\n" + textblock "${magenta}--- Operation Modes ---${norm}" + printf "\n" + ptextblock "--makevars" + textblock "Create a sample .borgvars file that you can fill in and use with this script." + ptextblock "-i|--info" + textblock "Get information about a specified borg repo archive. Requires you supply '--archive'." + ptextblock "-l|--list" + textblock "List contents of a specified borg repo archive. Requires you supply '--archive'." + ptextblock "-la|--list-all" + textblock "List all available archives within the repo specified in your .borgvars file." + ptextblock "-r|--restore" + textblock "Restore the specified borg repo archive/file(s). Requires you supply '--archive'." + printf "\n" + textblock "${magenta}--- Selector Parameters ---${norm}" + printf "\n" + ptextblock "-a|--archive" + textblock "The archive within your borg repo you wish to work with." + ptextblock "--exclude" + textblock "Pattern (python/borg) of files to exclude from a restore operation." + ptextblock "-f|--file" + textblock "Specific file/pattern (python/borg) you want to restore from an archive. Requires that you supply '--archive'." + ptextblock "-p|--path" + textblock "Path to which you want your archive/files restored. This script will attempt to create the directory for you if it does not already exist." + printf "\n" + textblock "${magenta}--- Restore Options ---${norm}" + printf "\n" + ptextblock "--progress" + textblock "Display progress indicator during restore operations. WARNING: This can drastically slow down operations on larger archives!" + ptextblock "--verbose" + textblock "List the individual files being processed during restore operations." + printf "\n" + textblock "${magenta}--- Other Parameters ---${norm}" + printf "\n" + ptextblock "-h|-?|--help" + textblock "This help screen." + printf "\n" + exit 0 +} + textblock() { printf "%s\n" "$1" | fold -w "$width" -s } +ptextblock() { + printf "%s%s%s\n" "$cyan" "$1" "$norm" +} + trapExit () { cleanup printf "%s\nScript execution terminated via signal.\n\n%s" "$err" "$norm" @@ -36,12 +92,20 @@ trapExit () { ### text formatting presets if command -v tput > /dev/null; then + bold=$(tput bold) + cyan=$(tput setaf 6) err=$(tput bold)$(tput setaf 1) + magenta=$(tput setaf 5) norm=$(tput sgr0) + yellow=$(tput setaf 3) width=$(tput cols) else + bold="" + cyan="" err="[ERROR] " + magenta="" norm="" + yellow="" width=80 fi @@ -87,7 +151,7 @@ while [ $# -gt 0 ]; do ;; -h|-\?|--help) # display help - printf "\nStill working on the help text :-)\n\n" + scriptHelp exit 0 ;; -i|--info)