From d000369b7da3c5663bf17156728254c24888fc94 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Fri, 27 Mar 2020 00:36:35 -0600 Subject: [PATCH] add file/pattern search to archive contents list --- borghelper.sh | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/borghelper.sh b/borghelper.sh index 0b03e5d..0fd64ca 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -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.'