Monitoring Database Backups
Database backups are scheduled jobs that run pg_dump, mysqldump, or custom backup scripts. A failed backup often goes unnoticed until you need to restore—by then it’s too late.
Configuration
Section titled “Configuration”Set your API key as an environment variable. For cron jobs, add it to your crontab:
# Edit crontabcrontab -e
# Add at top of crontabPAKYAS_API_KEY=pk_live_xxxxx
# Then your backup job0 3 * * * pakyas monitor pg-backup -- pg_dump mydb > /backups/mydb.sqlOr source from a file:
0 3 * * * . ~/.pakyas_env && pakyas monitor pg-backup -- pg_dump mydb > /backups/mydb.sqlSee Environment Variables for all options.
When to use this
Section titled “When to use this”- Backups run on a schedule
- Missing a backup is a serious failure
- You need to know immediately when a backup fails
Basic example
Section titled “Basic example”pakyas monitor pg-backup -- pg_dump mydb > backup.sqlPakyas wraps your backup command, reports start time, and alerts you if the backup fails or doesn’t run.
Scheduler setup
Section titled “Scheduler setup”# crontab example - runs every night at 3am0 3 * * * pakyas monitor pg-backup -- pg_dump mydb > /backups/mydb-$(date +\%Y\%m\%d).sqlWhat Pakyas detects
Section titled “What Pakyas detects”- Backup script exits non-zero
- Backup runs longer than expected
- Backup never runs (missed schedule)