PBS + Rclone Backup Email Notification Setup for PacketRealm.io
This document outlines how to configure email notifications for Proxmox Backup Server (PBS) backup syncs using rclone
and msmtp
, and send logs via email from [email protected]
.
1. Email Account: [email protected]
This email address is used as the sender for:
- PBS backup reports
- Grafana alerts
- General system monitoring
You may use it with msmtp
as an SMTP client to send messages.
2. Install Required Packages
sudo apt update
sudo apt install msmtp msmtp-mta
3. Configure msmtp
Edit /root/.msmtprc
:
defaults
auth on
tls on
tls_trust_file /etc/ssl/certs/ca-certificates.crt
logfile /var/log/backup-logs/msmtp.log
account packetrealm
host smtp.yourprovider.com
port 587
from [email protected]
user [email protected]
passwordeval "gpg --quiet --batch --yes --passphrase 'your-gpg-pass' --decrypt /root/.monitor-password.gpg"
account default : packetrealm
Make sure permissions are secure:
chmod 600 /root/.msmtprc /root/.monitor-password.gpg
4. Encrypt Your SMTP Password Using GPG
echo 'your-smtp-app-password' | gpg --symmetric --cipher-algo AES256 --batch --yes --passphrase 'your-gpg-pass' -o /root/.monitor-password.gpg
5. Define Log Paths
In your backup script:
DATE=$(date +%Y-%m-%d)
RCLONE_LOG="/var/log/backup-logs/rclone-backup-${DATE//-/}.log"
PBS_LOG="/var/log/backup-logs/pbs-backup-${DATE}.log"
mkdir -p /var/log/backup-logs
exec > >(tee -a "$PBS_LOG") 2>&1
6. Email Notification Block
Append this to the end of your backup script:
TO="[email protected]"
FROM="[email protected]"
SUBJECT_SUCCESS="✅ PBS Backup Success - ${DATE}"
SUBJECT_FAIL="❌ PBS Backup Failure - ${DATE}"
sync
sleep 1
if grep -Ei "error|fail|cannot" "$RCLONE_LOG" > /dev/null; then
SUBJECT="$SUBJECT_FAIL"
else
SUBJECT="$SUBJECT_SUCCESS"
fi
msmtp -a default -t <<EOF
To: $TO
From: $FROM
Subject: $SUBJECT
Content-Type: multipart/mixed; boundary="BOUNDARY"
--BOUNDARY
Content-Type: text/plain
PBS backup log for $DATE. See attached.
--BOUNDARY
Content-Type: text/plain
Content-Disposition: attachment; filename="$(basename "$RCLONE_LOG")"
$(cat "$RCLONE_LOG")
--BOUNDARY--
EOF
7. Test It
Manually run the script:
sudo /opt/scripts/pbs-backup-sync.sh
Then check the mailbox for a message from [email protected]
with the log file attached.