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"
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'."
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"
textblock "List all available archives within the repo specified in your .borgvars file."
ptextblock "-r|--restore"
@ -68,7 +68,7 @@ scriptHelp() {
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'."
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"
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"
@ -152,9 +152,9 @@ while [ $# -gt 0 ]; do
shift
;;
-f|--file)
# specific file to restore
# specific file/pattern to restore
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
fileName="$2"
shift
@ -360,7 +360,11 @@ if [ "$operation" = 'info' ]; then
elif [ "$operation" = 'listall' ]; then
borg list
elif [ "$operation" = 'viewarchive' ]; then
borg list ::"${archiveName}"
if [ "$fileName" ]; then
borg list ::"${archiveName}" "${fileName}"
else
borg list ::"${archiveName}"
fi
# restore operations
elif [ "$operation" = 'restore' ]; then
cd "$restorePath" || consoleError 4 'Could not change to restore directory.'