Backup & Restore
Protect your data with regular backups.
Automated Backups
Cron Job
bash
# /etc/cron.d/ops-atlas-backup
0 2 * * * root /opt/ops-atlas/backup.shBackup Script
bash
#!/bin/bash
# backup.sh
DATE=$(date +%Y%m%d_%H%M%S)
BACKUP_DIR=/backups/ops-atlas
# Create backup directory
mkdir -p $BACKUP_DIR
# Backup PostgreSQL
docker exec ops-atlas-db pg_dump -U postgres opsatlas | gzip > $BACKUP_DIR/db_$DATE.sql.gz
# Backup Redis
docker exec ops-atlas-redis redis-cli BGSAVE
docker cp ops-atlas-redis:/data/dump.rdb $BACKUP_DIR/redis_$DATE.rdb
# Cleanup old backups (keep 30 days)
find $BACKUP_DIR -type f -mtime +30 -delete
# Upload to S3 (optional)
aws s3 sync $BACKUP_DIR s3://your-bucket/ops-atlas-backups/Manual Backup
bash
# Database
docker exec ops-atlas-db pg_dump -U postgres opsatlas > backup.sql
# Compress
gzip backup.sqlRestore
From SQL Backup
bash
# Stop application
docker-compose stop ops-atlas
# Restore database
gunzip -c backup.sql.gz | docker exec -i ops-atlas-db psql -U postgres opsatlas
# Start application
docker-compose start ops-atlasPoint-in-Time Recovery
For PostgreSQL with WAL archiving:
bash
# Restore to specific time
pg_restore --target-time="2025-01-15 10:30:00" ...Disaster Recovery
Recovery Plan
- RTO (Recovery Time Objective): 1 hour
- RPO (Recovery Point Objective): 1 hour
Steps
- Provision new infrastructure
- Restore database from backup
- Update DNS
- Verify functionality
- Notify stakeholders
Testing Backups
Regularly test your backups:
bash
# Monthly backup test
./test-restore.sh --backup=latest --target=staging