summaryrefslogtreecommitdiff
path: root/borgAuto.sh
diff options
context:
space:
mode:
authorSt33v <github@f3rr3t.com>2020-02-27 22:35:49 +1100
committerSt33v <github@f3rr3t.com>2020-02-27 22:35:49 +1100
commit8a2dc47f89dd06b0f45e26accd8f8d0d2715a681 (patch)
tree9ef42101a4c9dedecabf07b118358dd6e54677dc /borgAuto.sh
parent2e4d7b7e9bb061a605904f7b5552fbdf96794617 (diff)
summarise diffs to MAXLINE
Diffstat (limited to 'borgAuto.sh')
-rwxr-xr-xborgAuto.sh28
1 files changed, 24 insertions, 4 deletions
diff --git a/borgAuto.sh b/borgAuto.sh
index 74a3485..07c83c3 100755
--- a/borgAuto.sh
+++ b/borgAuto.sh
@@ -4,11 +4,34 @@
# the envvar $REPONAME is something you should just hardcode
export BORG_REPO="/mnt/bak/borg" # (now set in ~/.bashrc)
+MAXFILES=20 #Max number of file changes to log
+
+# Route the normal process logging to journalctl
+2>&1
+
# DIFF function
# List changes between this archive and the previous one
function Differ {
newArchive=$(borg list :: -P $1 --last 2 --format {name}{NL})
- borg diff ::$newArchive
+ diffTmpFile=`mktemp /tmp/borgAutoXXXXX` # in /tmp dir
+ borg diff ::$newArchive > $diffTmpFile
+ addFiles=$(grep '^added' ${diffTmpFile} | wc -l)
+ remFiles=$(grep '^removed' ${diffTmpFile} | wc -l)
+ totFiles=$(wc -l ${diffTmpFile} | awk '{print $1}')
+ changeFiles=$(awk -v tot=$totFiles -v a=$addFiles -v r=$remFiles 'BEGIN {print tot - a - r}')
+ if [ ${totFiles} -eq 0 ]; then
+ echo "No changes, additions or deletions since last backup"
+ elif [ ${totFiles} -gt ${MAXFILES} ]; then
+ #echo $(head ${diffTmpFile})
+ head ${diffTmpFile}
+
+ midFiles=$(awk -v tot=$totFiles -v max=$MAXFILES 'BEGIN {print tot - max}')
+ echo " ... ${midFiles} more changes (Changed $changeFiles, Added ${addFiles}, Removed ${remFiles})"
+ tail ${diffTmpFile}
+ else
+ cat ${diffTmpFile}
+ fi
+ rm ${diffTmpFile}
}
# Backup all of /home except a few excluded directories and files
@@ -36,9 +59,6 @@ echo $'\nCreating Image archive'
borg create -v --stats --compression none \
::'olho-{now:%Y%m%dT%H%M}' /mnt/olho
-# Route the normal process logging to journalctl
-2>&1
-
Differ olho
backup_exit=$?