summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xborgAuto.sh28
-rwxr-xr-x[-rw-r--r--]borgBackup.timer0
-rwxr-xr-xdiff.sh32
3 files changed, 56 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=$?
diff --git a/borgBackup.timer b/borgBackup.timer
index 5a61a06..5a61a06 100644..100755
--- a/borgBackup.timer
+++ b/borgBackup.timer
diff --git a/diff.sh b/diff.sh
new file mode 100755
index 0000000..74fc1af
--- /dev/null
+++ b/diff.sh
@@ -0,0 +1,32 @@
+
+function Differ {
+ MAXFILES=20
+ newArchive=$(borg list :: -P $1 --last 2 --format {name}{NL})
+ diffTmpFile=`mktemp /tmp/borgAutoXXXXX` # in /tmp dir
+ borg diff ::$newArchive > $diffTmpFile
+ echo made the difffile $diffTmpFile
+ echo $(wc $diffTmpFile)
+ addFiles=$(grep '^added' ${diffTmpFile} | wc -l)
+ echo $addFiles
+ remFiles=$(grep '^removed' ${diffTmpFile} | wc -l)
+ echo $remFiles
+ totFiles=$(wc -l ${diffTmpFile} | awk '{print $1}')
+ echo $totFiles
+ echo $totFiles $addFiles $remFiles
+ if [ ${totFiles} -eq 0 ]; then
+ echo "No 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 files changed (Added ${addFiles}, Removed ${remFiles})"
+ tail ${diffTmpFile}
+ else
+ cat ${diffTmpFiles}
+
+ fi
+ rm ${diffTmpFile}
+}
+
+Differ $1