34 lines
954 B
Bash
34 lines
954 B
Bash
#!/bin/bash
|
|
MAILFILE="/tmp/mailtxt"
|
|
SERVER_NAME=$HOSTNAME
|
|
SENDER=$(whoami)
|
|
USER="noreply"
|
|
MAILHEADER="/opt/b2backup/mailheader.txt"
|
|
MAILFOOTER="/opt/b2backup/mailfooter.txt"
|
|
. ${PWD}/config.txt
|
|
|
|
export B2_ACCOUNT_ID="$B2_ACCOUNT_ID"
|
|
export B2_ACCOUNT_KEY="$B2_ACCOUNT_KEY"
|
|
export RESTIC_REPOSITORY="$RESTIC_REPOSITORY"
|
|
export RESTIC_PASSWORD_FILE="$RESTIC_PASSWORD_FILE"
|
|
|
|
/usr/bin/restic backup $BACKUPDATA
|
|
/usr/bin/restic forget --keep-last $KEEPLAST --keep-daily $KEEPDAILY --keep-weekly $KEEPWEEKLY --keep-monthly $KEEPMONTHLY --keep-yearly $KEEPYEARLY
|
|
|
|
echo "Backup Complete. Currently available snapshots:" > $MAILFILE
|
|
echo "<pre style='font:monospace'>" >> $MAILFILE
|
|
echo "$(/usr/bin/restic snapshots)" >> $MAILFILE
|
|
|
|
(
|
|
echo "Subject: $EMAILSUB"
|
|
echo "From: $SENDER"
|
|
echo "To: $RECIPIENT"
|
|
cat $MAILHEADER $MAILFILE $MAILFOOTER
|
|
) | sendmail -t
|
|
|
|
rm $MAILFILE
|
|
|
|
for var in $(awk -F"=" '{print $1}' ${PWD}/config.txt); do
|
|
unset $var
|
|
done
|