Backup & Restore
Strategi backup dan recovery untuk database MySQL di MStore Backend, mencakup full backup, incremental backup, dan point-in-time recovery.π― Backup Strategy
Backup Types
| Type | Frequency | Scope | Use Case |
|---|---|---|---|
| Full Backup | Daily (off-peak) | Entire database | Complete recovery |
| Incremental | Hourly | Changes only | Faster backup |
| Differential | Every 6 hours | Changes since last full | Balance speed & size |
| Transaction Log | Continuous | Binary logs | Point-in-time recovery |
Backup Tools
Primary: mysqldumpπ Backup Scheduling
Daily Backup Schedule
Backup Retention Policy
| Backup Type | Retention | Storage |
|---|---|---|
| Daily Full | 7 days | Local + S3 |
| Incremental | 24 hours | Local |
| Weekly Full | 4 weeks | S3 |
| Monthly Full | 12 months | Glacier |
Automated Backup Script
Cron Job
π Restore Procedures
Full Restore (Complete Database)
Selective Restore (Specific Table)
Point-in-Time Recovery (PITR)
Restore from AWS RDS Snapshot
β Backup Verification
Verify Backup Integrity
Backup Monitoring
π¨ Disaster Recovery Plan
Recovery Time Objective (RTO)
- Full backup restore: 30 minutes
- Incremental restore: 15 minutes
- PITR restore: 10 minutes
Recovery Point Objective (RPO)
- Maximum data loss: 1 hour (hourly incremental backups)
Recovery Steps
-
Assess Damage
- Identify what data is corrupted/lost
- Determine recovery point needed
- Notify stakeholders
-
Stop Application
-
Backup Current Database (for forensics)
-
Restore from Backup
-
Verify Data Integrity
-
Restart Application
-
Monitor Logs
π Backup Checklist
Pre-Backup
- Verify backup disk space
- Check database connectivity
- Verify backup script permissions
- Test backup on staging
- Notify team of maintenance window
During Backup
- Monitor backup progress
- Check CPU/disk usage
- Verify no application errors
- Monitor network bandwidth
Post-Backup
- Verify backup file integrity
- Verify backup file size (should be reasonable)
- Upload to S3/cloud storage
- Test restore on staging
- Document backup completion
- Update backup log
π Best Practices
DO β
- Backup regularly (daily minimum)
- Test restores on staging
- Keep backups off-site (S3, cloud)
- Encrypt backups at rest
- Monitor backup completion
- Document recovery procedures
- Use automated backup scripts
- Maintain backup retention policy
- Verify backup integrity regularly
DONβT β
- Skip backup testing
- Store backups only locally
- Use unencrypted backups
- Backup during peak hours
- Ignore backup failures
- Keep backups forever (cost)
- Restore to production without testing
- Forget to document recovery steps