From 690c23ecefab9a5db9a95eae666696060619f402 Mon Sep 17 00:00:00 2001 From: KoenDR06 Date: Tue, 21 Jan 2025 13:47:08 +0100 Subject: [PATCH] backup system only saves file when hashes do not match --- misc/backup.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/misc/backup.sh b/misc/backup.sh index 555bc79..75ecac0 100755 --- a/misc/backup.sh +++ b/misc/backup.sh @@ -1,5 +1,13 @@ #!/run/current-system/sw/bin/zsh cd /home/horseman +file=backups/$(date +%Y-%m-%d).tar +tar -cf $file Documents -tar -cf backups/$(date +%Y-%m-%d).tar Documents +if grep -q $(sha256sum $file) backups/sum; then + echo 'hashes match, quitting' + rm $file + exit 0 +fi + +echo $(sha256sum ) > backups/sum