add file/pattern search to archive contents list

This commit is contained in:
Asif Bacchus 2020-03-27 00:36:35 -06:00
parent f18de4f411
commit d000369b7d

View File

@ -55,7 +55,7 @@ scriptHelp() {
ptextblock "-i|--info" ptextblock "-i|--info"
textblock "Get information about a specified borg repo archive. Requires you supply '--archive'." textblock "Get information about a specified borg repo archive. Requires you supply '--archive'."
ptextblock "-l|--list" ptextblock "-l|--list"
textblock "List contents of a specified borg repo archive. Requires you supply '--archive'." textblock "List contents of a specified borg repo archive. Requires you supply '--archive'. You can optionally specify a file/pattern to search for using '--file'."
ptextblock "-la|--list-all" ptextblock "-la|--list-all"
textblock "List all available archives within the repo specified in your .borgvars file." textblock "List all available archives within the repo specified in your .borgvars file."
ptextblock "-r|--restore" ptextblock "-r|--restore"
@ -68,7 +68,7 @@ scriptHelp() {
ptextblock "--exclude" ptextblock "--exclude"
textblock "Pattern (python/borg) of files to exclude from a restore operation." textblock "Pattern (python/borg) of files to exclude from a restore operation."
ptextblock "-f|--file" ptextblock "-f|--file"
textblock "Specific file/pattern (python/borg) you want to restore from an archive. Requires that you supply '--archive'." textblock "Specific file/pattern (python/borg) within an archive for which you want to restore or search. Requires that you supply '--archive'."
ptextblock "-p|--path" 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." 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" printf "\n"
@ -152,9 +152,9 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;
-f|--file) -f|--file)
# specific file to restore # specific file/pattern to restore
if [ -z "$2" ]; then if [ -z "$2" ]; then
consoleError 1 'Please provide the name of the specific file you want to restore.' consoleError 1 'Please provide the name of the specific file/pattern for which you want to restore or search.'
fi fi
fileName="$2" fileName="$2"
shift shift
@ -360,7 +360,11 @@ if [ "$operation" = 'info' ]; then
elif [ "$operation" = 'listall' ]; then elif [ "$operation" = 'listall' ]; then
borg list borg list
elif [ "$operation" = 'viewarchive' ]; then elif [ "$operation" = 'viewarchive' ]; then
if [ "$fileName" ]; then
borg list ::"${archiveName}" "${fileName}"
else
borg list ::"${archiveName}" borg list ::"${archiveName}"
fi
# restore operations # restore operations
elif [ "$operation" = 'restore' ]; then elif [ "$operation" = 'restore' ]; then
cd "$restorePath" || consoleError 4 'Could not change to restore directory.' cd "$restorePath" || consoleError 4 'Could not change to restore directory.'