Scenario
Your production database (MySQL or PostgreSQL) suffers from slow backup and recovery times, impacting your Service Level Agreements (SLAs).
Symptoms
Backup jobs take significantly longer than expected; Recovery Time Objective (RTO) is breached; high I/O wait during backups; slow restore processes.
Diagnosis
- Analyze backup method: Logical (mysqldump/pg_dump) vs physical (XtraBackup/pg_basebackup). Physical backups are usually faster but larger.
- Check hardware resources: Use
iostat,vmstatto monitor disk I/O and CPU load. High I/O during backup may coincide with database slowdowns. - Benchmark restore times: Restore backup in a test environment and time it. Compare compression levels (e.g., gzip vs lz4).
- Review configuration parameters: MySQL’s
innodb_io_capacityandinnodb_flush_log_at_trx_commitaffect writes; PostgreSQL’swal_compressionandcheckpoint_completion_targetaffect backup speed.
Commands
MySQL
- Time a mysqldump:
time mysqldump -u root -p database > dump.sql - Check InnoDB status:
mysql> SHOW ENGINE INNODB STATUS\Gto see if background threads are blocked by backup. - Analyze slow queries during backup with Percona Toolkit:
pt-query-digest /var/log/mysql/slow.log
PostgreSQL
- Time pg_dump:
time pg_dump -U postgres database > dump.sql - Monitor active queries:
SELECT * FROM pg_stat_activity WHERE state = 'active';Look for long-running queries triggered by backup. - Check vacuum settings:
SHOW autovacuum_vacuum_threshold;Too frequent vacuuming can increase I/O.
Risk Controls
- Always test backup and restore on staging before applying changes to production.
- Use incremental backups (e.g., mysqlbinlog or PostgreSQL WAL archiving) to reduce full backup frequency.
- Monitor resource utilization: set alerts when I/O utilization exceeds 80%.
- Set reasonable lock timeouts: MySQL
lock_wait_timeout, PostgreSQLstatement_timeout. - Use compression carefully: high compression (e.g., gzip -9) consumes CPU and may slow the database.
Rollback
If backup performance degrades after changes, revert parameters incrementally or switch back to previous backup method. Always keep a last-known-good backup strategy configuration.
Verification
- Validate backup integrity with checksum:
mysqldump ... | md5sumand compare with previous backup. - Restore backup in isolated environment and verify row counts:
SELECT COUNT(*) FROM table; - Perform test writes to ensure the database is writable.
When to Submit an OpsGlobal Ticket
- RTO consistently exceeds defined threshold (e.g., 4 hours) and cannot be improved with internal tuning.
- Backup failure rate >1% with unknown root cause.
- Hardware is suspected as bottleneck (e.g., disk response time >20ms) but no ability to upgrade.
- Need professional assessment of backup strategy (e.g., hybrid cloud archiving).
OpsGlobal’s SRE team can provide deep audits, tool integration, and 24/7 monitoring support.
Use cases
Useful for teams handling Database issues and needing a clear troubleshooting and delivery workflow.
Problem background
A deep dive into diagnosing and optimizing backup and recovery performance for MySQL and PostgreSQL, with real-world scenarios, commands, risk controls, and when to escalate to OpsGlobal.
Troubleshooting steps
Confirm impact and recent changes, collect logs, configuration and metrics, then apply fixes from low to high risk.
Command examples
Replace sample resource names with real values and store passwords, tokens and keys in environment variables.
Risks
Before production changes, confirm backups, access boundaries, change windows and rollback paths.
Rollback plan
Keep original configuration and release versions; roll back config, images or database changes if metrics degrade.
Deliverables
Root-cause notes, key commands, remediation steps, verification results and follow-up recommendations.
Need help with a similar technical issue?
If your servers, Kubernetes, Docker, CI/CD, databases or monitoring systems have similar issues, submit logs and config files for remote diagnosis.