How to Monitor Your Automatic Backups
Never again discover a backup failed on the day you need it.
Backups are your safety net. But they can fail silently for weeks.
This guide shows you how to monitor your backup scripts with MoniTao Heartbeat.
Why Monitor Backups?
Backups can fail for many reasons:
- Insufficient disk space
- Incorrect permissions
- Network timeout to remote storage
- Update that breaks the script
Complete Configuration
Integrate heartbeat into your backup script:
Step 1: Create the Heartbeat Job
Create a job with your backup interval (e.g., 24h for daily backup).
Step 2: Get the Tokens
Copy the ping_token and api_secret from the MoniTao dashboard.
Step 3: Integrate into Script
Here's a complete bash script example with integrated heartbeat:
#!/bin/bash
# Script de backup MySQL avec heartbeat MoniTao
TOKEN="VOTRE_PING_TOKEN"
SECRET="VOTRE_API_SECRET"
API="https://monitao.com/api/heartbeat"
# Signal de debut
curl -s -X POST "$API/start/$TOKEN" -H "Authorization: Bearer $SECRET"
# Variables
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR="/backups"
DB_NAME="production"
DB_USER="backup_user"
DB_PASS="secure_password"
# Execution du backup
mysqldump -u $DB_USER -p"$DB_PASS" $DB_NAME | gzip > "$BACKUP_DIR/db_$DATE.sql.gz"
RESULT=$?
# Verification et signal
if [ $RESULT -eq 0 ] && [ -f "$BACKUP_DIR/db_$DATE.sql.gz" ]; then
# Backup reussi
curl -s -X POST "$API/ping/$TOKEN" -H "Authorization: Bearer $SECRET"
# Nettoyage des vieux backups (garder 7 jours)
find $BACKUP_DIR -name "db_*.sql.gz" -mtime +7 -delete
else
# Backup echoue
curl -s -X POST "$API/fail/$TOKEN" -H "Authorization: Bearer $SECRET"
exit 1
fi
Supported Backup Types
Heartbeat works with all types of backups:
- Database - MySQL, PostgreSQL, MongoDB...
- Files - rsync, tar, rclone to S3...
- Applications - WordPress, GitLab, etc.
Alert Examples
- Daily MySQL backup failing because database is locked
- S3 backup timing out due to network
- Script no longer starting after system update
Summary
- Create a heartbeat job with the backup interval
- Integrate start/ping/fail into your script
- Verify ping arrives after a manual test
Frequently Asked Questions
How do I know if the backup actually worked?
Check the backup command's return code before sending the success ping.
Can I monitor an incremental backup?
Yes, the principle is the same: ping after each successful execution.
What grace period for a backup that takes 2h?
Configure a 3-4h grace to give time for the backup to complete.
Can the heartbeat restart a failed backup?
No, MoniTao only alerts. Restart must be handled by your script or system.
Useful Links
Ready to Sleep Soundly?
Start free, no credit card required.