Script to back up TurrisOS to a remote location
This commit is contained in:
parent
94bdac4e7b
commit
08f5364ff5
1 changed files with 40 additions and 0 deletions
40
sysadmin/turrisos-backup.sh
Executable file
40
sysadmin/turrisos-backup.sh
Executable 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
|
Loading…
Add table
Reference in a new issue