From ff98225921e04e40a1247ac27915f09a19a375b2 Mon Sep 17 00:00:00 2001 From: Asif Bacchus Date: Thu, 26 Mar 2020 05:40:23 -0600 Subject: [PATCH] process exclusions --- borghelper.sh | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/borghelper.sh b/borghelper.sh index 7b8b856..4ccb10f 100755 --- a/borghelper.sh +++ b/borghelper.sh @@ -261,14 +261,21 @@ elif [ "$operation" = 'viewarchive' ]; then borg list ::"${archiveName}" # restore operations elif [ "$operation" = 'restore' ]; then + cd "$restorePath" || consoleError 4 'Could not change to restore directory.' if [ -z "$fileName" ]; then # restore entire archive - cd "$restorePath" || consoleError 4 'Could not change to restore directory.' - borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" + if [ "$exclusions" ]; then + borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" --exclude "${exclusions}" + else + borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" + fi elif [ "$fileName" ]; then - # restore single file - cd "$restorePath" || consoleError 4 'Could not change to restore directory.' - borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}" + # restore file/pattern + if [ "$exclusions" ]; then + borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}" --exclude "${exclusions}" + else + borg --show-rc ${commonOptions} extract ${restoreOptions} ::"${archiveName}" "${fileName}" + fi fi fi