Rollback strategies
AWS CodeDeploy rollback
Automatic rollback to previous deployment
Manual rollback
Manual restoration of previous version
Database rollback
Reverting database migrations
Configuration rollback
Restoring previous configuration
AWS CodeDeploy automatic rollback
AWS CodeDeploy can automatically rollback failed deployments.Enable automatic rollback
Configure in CodeDeploy deployment group:Rollback triggers
Automatic rollback occurs when:- Deployment fails on any instance
- Health check fails after deployment
- CloudWatch alarm triggers
- Manual stop of deployment
Rollback process
- CodeDeploy detects failure condition
- Stops current deployment
- Retrieves previous successful deployment
- Redeploys previous version to all instances
- Runs deployment hooks
- Verifies health checks
Monitor rollback
Manual rollback via CodeDeploy
If automatic rollback is not configured, manually trigger rollback:Step 1: Identify previous deployment
Step 2: Create rollback deployment
Step 3: Monitor rollback
Manual rollback on Windows Server
If CodeDeploy is unavailable, manually rollback on the server.Step 1: Stop IIS
Step 2: Restore previous version
Step 3: Start IIS
Step 4: Verify application
Database rollback
Migration rollback
If database migrations were applied, rollback using Entity Framework:Database restore from backup
For critical database issues, restore from backup:Verify database state
Configuration rollback
Restore configuration files
Restore secrets from AWS Secrets Manager
Rollback verification
After rollback, verify system health:Health checks
- API health
- Admin health
- Database connectivity
- Payment processing
Application logs
Performance metrics
Monitor key metrics after rollback:- Response times
- Error rates
- Database query performance
- Memory and CPU usage
- Active connections
Rollback decision matrix
| Scenario | Recommended Action | Urgency |
|---|---|---|
| Failed deployment | AWS CodeDeploy automatic rollback | Immediate |
| Application crashes | Manual rollback + investigation | High |
| Database errors | Database rollback + application rollback | High |
| Performance degradation | Monitor, then rollback if worsening | Medium |
| Configuration issues | Configuration rollback only | Medium |
| Minor bugs | Fix forward in hotfix | Low |
Post-rollback actions
After successful rollback:1. Incident documentation
Document the incident:- What failed and why
- Rollback steps taken
- Time to recovery
- Root cause analysis
- Prevention measures
2. Notify stakeholders
3. Root cause analysis
Investigate the failure:- Review deployment logs
- Analyze application errors
- Check configuration changes
- Review code changes
- Identify testing gaps
4. Prevention measures
Implement safeguards:- Add automated tests
- Improve deployment validation
- Update runbooks
- Enhance monitoring
- Review change management process
Rollback best practices
Test rollback procedures
Regularly test rollback in non-production environments
Maintain backups
Keep multiple backup versions of deployments and databases
Document procedures
Keep rollback procedures up-to-date and accessible
Monitor after rollback
Closely monitor system after rollback for stability
Emergency contacts
For critical production issues:- On-call engineer: Check PagerDuty rotation
- DevOps team: [email protected]
- Database admin: [email protected]
- Security team: [email protected]
