Skip to content

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.

Set your API key as an environment variable. For cron jobs, add it to your crontab:

Terminal window
# Edit crontab
crontab -e
# Add at top of crontab
PAKYAS_API_KEY=pk_live_xxxxx
# Then your backup job
0 3 * * * pakyas monitor pg-backup -- pg_dump mydb > /backups/mydb.sql

Or source from a file:

Terminal window
0 3 * * * . ~/.pakyas_env && pakyas monitor pg-backup -- pg_dump mydb > /backups/mydb.sql

Or skip the API key and ping by public ID: pakyas monitor --public-id <PUBLIC_ID> -- .... See Environment Variables for all options.

  • Backups run on a schedule
  • Missing a backup is a serious failure
  • You need to know immediately when a backup fails
Terminal window
pakyas monitor pg-backup -- pg_dump mydb > backup.sql

Pakyas wraps your backup command, reports start time, and alerts you if the backup fails or doesn’t run.

pakyas monitor writes nothing to stdout and passes the dump through unchanged, so redirecting the output to a file is safe. The command after -- runs without a shell; to monitor a pipeline and catch failures anywhere in it, run it through bash with pipefail:

Terminal window
pakyas monitor pg-backup -- bash -c 'set -o pipefail; pg_dump mydb | gzip > /backups/mydb.sql.gz'
Terminal window
# crontab example - runs every night at 3am
0 3 * * * pakyas monitor pg-backup -- pg_dump mydb > /backups/mydb-$(date +\%Y\%m\%d).sql
  • Backup script exits non-zero
  • Backup runs longer than expected
  • Backup never runs (missed schedule)