Browse Source

add backup_report.sh

Helmut Pozimski 7 years ago
parent
commit
513d3dd9ba
2 changed files with 29 additions and 0 deletions
  1. 1 0
      README.md
  2. 28 0
      backup_report.sh

+ 1 - 0
README.md

@@ -5,6 +5,7 @@ This repository contains a collection of scripts written by me which are not big
 ## Scripts currently in the repository
 
 * voixicron.py: Simple script that checks for available updates on a Void Linux system with xbps-install and sends a report about the available updates to the administrator via e-mail.
+* backup_report.sh: Bash script that generates a report about created backups using [storeBackup](http://storebackup.org/). Can be used to track the creation of backups and detect failed backups so they can be cleaned up manually.
 
 ## Copying
 

+ 28 - 0
backup_report.sh

@@ -0,0 +1,28 @@
+#!/bin/bash
+
+# A little script to generate a monthly report about storeBackup backups
+# written by Helmut Pozimski <helmut@pozimski.eu> in 2013
+
+# Define the hosts to be checked
+hosts=""
+backupdir=""
+tmpfile="/tmp/backup_report.mail"
+mailto="root"
+sender="backup-report@$(hostname -f)"
+
+for host in $hosts; do
+	echo "*Backups for host $host:*" >> $tmpfile
+	printf "\n" >> $tmpfile
+	echo "Correctly finished backups:" >> $tmpfile
+	printf "\n" >> $tmpfile
+	storeBackupls.pl $backupdir/$host/default 2>&1 | grep -v unresolved >> $tmpfile
+	printf "\n" >> $tmpfile
+	echo "Failed or not yet linked backups:" >> $tmpfile
+	printf "\n" >> $tmpfile
+	storeBackupls.pl $backupdir/$host/default 2>&1 | grep unresolved >> $tmpfile
+	printf "\n" >> $tmpfile
+done
+
+mailx -r $sender -s "Backup-Report for $(LANG=C date +%B) $(date +%Y)" $mailto < $tmpfile
+
+rm $tmpfile