diff --git a/sysadmin/turrisos-backup.sh b/sysadmin/turrisos-backup.sh new file mode 100755 index 0000000..32f849d --- /dev/null +++ b/sysadmin/turrisos-backup.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +CURRENT_DATE=$(date +"%Y%m%d") +DATE_PRETTY=$(date) +HOST="maru" + +create_snapshot () { + logger -p user.info -t schnapps_backup "Creating schnapps backup for host ${HOST}" + if /usr/bin/schnapps upload > /dev/null; + then + logger -p user.info -t schnapps_backup "Snapshot for host ${HOST} created successfully" + return 0 + else + logger -p user.err "Snapshot creation for host ${HOST} failed" + return 1 + fi +} + +if ! create_snapshot; +then + exit 1 +fi + +read -r -d '' TEMPLATE << EOF +From: Backup Robot +To: einar@heavensinferno.net +X-Notification-System: ${HOST} +Subject: [${CURRENT_DATE}] TurrisOS backup created for host ${HOST} + +Hello, + +the schnapps backup has been created successfully on date ${DATE_PRETTY}. + +Note that snapshots older than 30 days are automatically deleted. + +-- +Automated notification system +EOF + +echo "$TEMPLATE" | msmtp --from=notify@dennogumi.org einar@heavensinferno.net,einar@mailbox.org