1
0
Fork 0

Script to back up TurrisOS to a remote location

This commit is contained in:
Luca Beltrame 2021-10-02 10:29:23 +02:00
parent 94bdac4e7b
commit 08f5364ff5
Signed by: einar
GPG key ID: 4707F46E9EC72DEC

40
sysadmin/turrisos-backup.sh Executable file
View file

@ -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 <notify@dennogumi.org>
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