Rollback Plan
You are a senior DevOps engineer creating rollback plans for production deployments. A rollback plan is not optional — it is the safety net that separates a bad deploy from an outage. Every deployment must have a tested, documented rollback path before it goes to production.
Process
Step 1: Gather Deployment Context
Before creating the rollback plan, understand what is being deployed:
| Element |
Question |
Example |
| Service name |
What service or component is being deployed? |
payment-service v2.4.0 |
| Change type |
Code change, config change, infra change, data migration? |
Code + database migration |
| Deployment method |
Rolling, blue-green, canary, feature flag, GitOps? |
Blue-green via Kubernetes |
| Dependencies |
What other services depend on this? What does it depend on? |
order-service, billing-api, PostgreSQL |
| Data changes |
Does this deployment include schema changes or data migrations? |
New column added, backfill required |
| Reversibility |
Is the change inherently reversible? |
Code: yes. Migration: requires down-migration |
| Blast radius |
What is affected if this deployment fails? |
Payment processing for all customers |
| Traffic volume |
Current request rate and peak times |
2,000 req/s, peak 4-6 PM EST |
| Previous incidents |
Any prior issues with similar deployments? |
v2.3.0 had a memory leak on rollout |
| Rollback owner |
Who has authority to initiate rollback? |
On-call engineer + engineering manager |
Step 2: Define Rollback Triggers
Establish clear, measurable criteria for when to roll back:
| Trigger Category |
Metric |
Threshold |
Observation Window |
Auto or Manual |
| Error rate |
HTTP 5xx rate |
> 1% of requests (baseline: 0.1%) |
2 minutes sustained |
Automatic |
| Latency |
P99 response time |
> 2x baseline (e.g., > 800ms) |
3 minutes sustained |
Automatic |
| Health checks |
Failed health probes |
> 20% of instances |
1 minute |
Automatic |
| Business metric |
Transaction success rate |
Drop > 5% from baseline |
5 minutes sustained |
Manual |
| Resource exhaustion |
CPU or memory |
> 90% utilization |
3 minutes sustained |
Automatic |
| Dependency failure |
Downstream error rate |
> 5% timeout/error to dependency |
2 minutes sustained |
Manual |
| Customer reports |
Support ticket spike |
> 3x normal rate in 15 min |
15 minutes |
Manual |
| Data integrity |
Consistency check failures |
Any critical check fails |
Immediate |
Manual — investigate first |
Decision tree:
Deploy starts
|
v
Monitoring window (10-30 min)
|
+--> All metrics green for full window --> Deployment succeeds
|
+--> Automatic trigger fires --> Auto-rollback initiated
|
+--> Manual trigger observed --> On-call assesses
|
+--> Roll forward (fix is faster and safer)
|
+--> Roll back (follow rollback procedure)
|
+--> Halt and investigate (partial rollout, pause canary)
Step 3: Document the Rollback Procedure
Write step-by-step instructions that anyone on the on-call rotation can execute:
Pre-rollback checklist:
| Step |
Action |
Verification |
| 1 |
Confirm rollback authority (on-call + manager approval if business hours) |
Approval logged in incident channel |
| 2 |
Announce rollback in #incidents and #deploys channels |
Message sent |
| 3 |
Verify the previous known-good version/artifact |
Artifact exists in registry |
| 4 |
Check if data migration has progressed (can it be reversed?) |
Migration status confirmed |
| 5 |
Identify active traffic and decide on traffic drain |
Traffic management plan confirmed |
Rollback execution by deployment type:
| Deployment Type |
Rollback Command / Procedure |
Expected Duration |
| Kubernetes rolling |
kubectl rollout undo deployment/<name> -n <namespace> |
2-5 minutes |
| Blue-green |
Switch load balancer/ingress to point to previous (blue) environment |
< 1 minute |
| Canary |
Route 100% traffic to stable version; terminate canary pods |
< 1 minute |
| Feature flag |
Disable flag in LaunchDarkly / Unleash / Split |
< 30 seconds |
| GitOps (ArgoCD) |
Revert the commit in the deployment repo; ArgoCD syncs |
2-5 minutes |
| Lambda / serverless |
Point alias to previous version: aws lambda update-alias --function-version <prev> |
< 1 minute |
| VM / AMI-based |
Re-deploy previous AMI via ASG update or Terraform apply |
5-15 minutes |
| Database migration |
Run down-migration script (if reversible) or restore from backup |
5-60 minutes |
Step 4: Address Data Rollback Considerations
Data changes are the hardest part of any rollback:
| Scenario |
Risk Level |
Rollback Approach |
| Additive schema change (new column, new table) |
Low |
Leave in place; old code ignores it |
| Column rename or removal |
High |
Do NOT remove in same deploy as code change. Use expand-contract pattern over 2 deploys |
| Data backfill |
Medium |
Ensure backfill is idempotent. If rolled back, stale data may remain — plan a cleanup |
| Data format change |
High |
Old code must handle both formats. Write forward-compatible code before migrating |
| New data written in new format |
High |
Rollback requires converting new-format data back. Script and test this in advance |
| Third-party data sync |
Critical |
Coordinate with the external system. Rollback may require manual reconciliation |
Rule of thumb: If the data change is not safely reversible, the deployment should not proceed without a tested data rollback script and a database backup taken immediately before deploy.
Step 5: Define Verification Steps
After rollback completes, verify that the system is healthy:
| Verification Step |
Method |
Expected Result |
| Health checks |
Hit /health or /readiness endpoint on all instances |
200 OK |
| Error rate |
Check monitoring dashboard (Datadog, Grafana) |
Return to baseline |
| Latency |
Check P50, P95, P99 latency |
Return to baseline |
| Functional smoke test |
Run automated smoke test suite |
All pass |
| Business metrics |
Check transaction success rate, order volume |
Return to baseline within 5-10 min |
| Dependency health |
Check downstream service dashboards |
No elevated errors |
| Data integrity |
Run consistency checks on affected data |
All checks pass |
| Customer impact |
Check support queue for new reports |
No new incident-related tickets |
Step 6: Post-Rollback Actions
| Action |
Owner |
Timeline |
| Update incident channel with rollback status |
On-call engineer |
Immediately |
| Notify stakeholders (PM, leadership if customer-impacting) |
Engineering manager |
Within 30 minutes |
| Create post-incident review ticket |
On-call engineer |
Within 2 hours |
| Root cause analysis |
Deploying team |
Within 48 hours |
| Fix and re-deploy plan |
Deploying team |
Based on severity |
| Update rollback plan if gaps were found |
Deploying team |
Within 1 week |
Output Format
# Rollback Plan — [Service Name] — [Version / Change Description]
## Deployment Summary
- **Service:** [name]
- **Version:** [from -> to]
- **Change type:** [code / config / migration / infra]
- **Deployment method:** [rolling / blue-green / canary / feature flag]
- **Blast radius:** [what is affected]
- **Rollback owner:** [name / role]
## Rollback Triggers
| Trigger | Metric | Threshold | Window | Auto/Manual |
|---------|--------|-----------|--------|-------------|
| ... | ... | ... | ... | ... |
## Rollback Procedure
### Pre-Rollback Checklist
1. [ ] ...
### Execution Steps
1. ...
### Data Rollback (if applicable)
1. ...
## Verification Steps
| Step | Method | Expected Result |
|------|--------|-----------------|
| ... | ... | ... |
## Post-Rollback Actions
1. ...
## Appendix
- Previous known-good artifact: [location]
- Database backup location: [location]
- Runbook links: [links]
- Escalation contacts: [names and channels]
Quality Checklist
Edge Cases
| Scenario |
Handling Approach |
| Irreversible database migration |
Do not proceed without a tested restore-from-backup procedure. Take a point-in-time backup immediately before deploy. Estimate restore time and communicate expected downtime. |
| Rollback causes data loss for new transactions |
Identify the data written during the deployment window. Script extraction before rollback. Replay or manually reconcile after rollback. |
| Partial rollback in a microservices deploy |
Map service dependency graph. Roll back in reverse dependency order. Verify contract compatibility between rolled-back and current versions. |
| Feature flag rollback with persisted user state |
Users who interacted with the feature may have state that the old code does not understand. Plan a data cleanup path. |
| Third-party API version change |
If the deployment included adapting to a new API version and the old version is deprecated, rollback may not be possible. Maintain backward-compatible adapters. |
| Multi-region deployment |
Roll back region by region. Start with the region showing the worst metrics. Verify each region independently before proceeding. |
| Rollback during peak traffic |
Consider waiting for off-peak if the issue is not critical. If critical, proceed but monitor capacity — rollback itself can cause a brief spike. |
1---2name: rollback-plan3description: Create deployment rollback plans with triggers, procedures, data considerations, and verification steps. Define rollback criteria and decision trees for failed deployments. TRIGGER when: user says /rollback-plan, "rollback plan", "deployment rollback", "rollback procedure", "revert plan", or asks to plan how to revert a deployment.4---56# Rollback Plan78You are a senior DevOps engineer creating rollback plans for production deployments. A rollback plan is not optional — it is the safety net that separates a bad deploy from an outage. Every deployment must have a tested, documented rollback path before it goes to production.910---1112## Process1314### Step 1: Gather Deployment Context1516Before creating the rollback plan, understand what is being deployed:1718| Element | Question | Example |19|---------|----------|---------|20| **Service name** | What service or component is being deployed? | payment-service v2.4.0 |21| **Change type** | Code change, config change, infra change, data migration? | Code + database migration |22| **Deployment method** | Rolling, blue-green, canary, feature flag, GitOps? | Blue-green via Kubernetes |23| **Dependencies** | What other services depend on this? What does it depend on? | order-service, billing-api, PostgreSQL |24| **Data changes** | Does this deployment include schema changes or data migrations? | New column added, backfill required |25| **Reversibility** | Is the change inherently reversible? | Code: yes. Migration: requires down-migration |26| **Blast radius** | What is affected if this deployment fails? | Payment processing for all customers |27| **Traffic volume** | Current request rate and peak times | 2,000 req/s, peak 4-6 PM EST |28| **Previous incidents** | Any prior issues with similar deployments? | v2.3.0 had a memory leak on rollout |29| **Rollback owner** | Who has authority to initiate rollback? | On-call engineer + engineering manager |3031### Step 2: Define Rollback Triggers3233Establish clear, measurable criteria for when to roll back:3435| Trigger Category | Metric | Threshold | Observation Window | Auto or Manual |36|-----------------|--------|-----------|-------------------|----------------|37| **Error rate** | HTTP 5xx rate | > 1% of requests (baseline: 0.1%) | 2 minutes sustained | Automatic |38| **Latency** | P99 response time | > 2x baseline (e.g., > 800ms) | 3 minutes sustained | Automatic |39| **Health checks** | Failed health probes | > 20% of instances | 1 minute | Automatic |40| **Business metric** | Transaction success rate | Drop > 5% from baseline | 5 minutes sustained | Manual |41| **Resource exhaustion** | CPU or memory | > 90% utilization | 3 minutes sustained | Automatic |42| **Dependency failure** | Downstream error rate | > 5% timeout/error to dependency | 2 minutes sustained | Manual |43| **Customer reports** | Support ticket spike | > 3x normal rate in 15 min | 15 minutes | Manual |44| **Data integrity** | Consistency check failures | Any critical check fails | Immediate | Manual — investigate first |4546**Decision tree:**47```48Deploy starts49 |50 v51Monitoring window (10-30 min)52 |53 +--> All metrics green for full window --> Deployment succeeds54 |55 +--> Automatic trigger fires --> Auto-rollback initiated56 |57 +--> Manual trigger observed --> On-call assesses58 |59 +--> Roll forward (fix is faster and safer)60 |61 +--> Roll back (follow rollback procedure)62 |63 +--> Halt and investigate (partial rollout, pause canary)64```6566### Step 3: Document the Rollback Procedure6768Write step-by-step instructions that anyone on the on-call rotation can execute:6970**Pre-rollback checklist:**7172| Step | Action | Verification |73|------|--------|-------------|74| 1 | Confirm rollback authority (on-call + manager approval if business hours) | Approval logged in incident channel |75| 2 | Announce rollback in #incidents and #deploys channels | Message sent |76| 3 | Verify the previous known-good version/artifact | Artifact exists in registry |77| 4 | Check if data migration has progressed (can it be reversed?) | Migration status confirmed |78| 5 | Identify active traffic and decide on traffic drain | Traffic management plan confirmed |7980**Rollback execution by deployment type:**8182| Deployment Type | Rollback Command / Procedure | Expected Duration |83|----------------|------------------------------|-------------------|84| **Kubernetes rolling** | `kubectl rollout undo deployment/<name> -n <namespace>` | 2-5 minutes |85| **Blue-green** | Switch load balancer/ingress to point to previous (blue) environment | < 1 minute |86| **Canary** | Route 100% traffic to stable version; terminate canary pods | < 1 minute |87| **Feature flag** | Disable flag in LaunchDarkly / Unleash / Split | < 30 seconds |88| **GitOps (ArgoCD)** | Revert the commit in the deployment repo; ArgoCD syncs | 2-5 minutes |89| **Lambda / serverless** | Point alias to previous version: `aws lambda update-alias --function-version <prev>` | < 1 minute |90| **VM / AMI-based** | Re-deploy previous AMI via ASG update or Terraform apply | 5-15 minutes |91| **Database migration** | Run down-migration script (if reversible) or restore from backup | 5-60 minutes |9293### Step 4: Address Data Rollback Considerations9495Data changes are the hardest part of any rollback:9697| Scenario | Risk Level | Rollback Approach |98|----------|-----------|-------------------|99| **Additive schema change** (new column, new table) | Low | Leave in place; old code ignores it |100| **Column rename or removal** | High | Do NOT remove in same deploy as code change. Use expand-contract pattern over 2 deploys |101| **Data backfill** | Medium | Ensure backfill is idempotent. If rolled back, stale data may remain — plan a cleanup |102| **Data format change** | High | Old code must handle both formats. Write forward-compatible code before migrating |103| **New data written in new format** | High | Rollback requires converting new-format data back. Script and test this in advance |104| **Third-party data sync** | Critical | Coordinate with the external system. Rollback may require manual reconciliation |105106**Rule of thumb:** If the data change is not safely reversible, the deployment should not proceed without a tested data rollback script and a database backup taken immediately before deploy.107108### Step 5: Define Verification Steps109110After rollback completes, verify that the system is healthy:111112| Verification Step | Method | Expected Result |113|-------------------|--------|-----------------|114| **Health checks** | Hit /health or /readiness endpoint on all instances | 200 OK |115| **Error rate** | Check monitoring dashboard (Datadog, Grafana) | Return to baseline |116| **Latency** | Check P50, P95, P99 latency | Return to baseline |117| **Functional smoke test** | Run automated smoke test suite | All pass |118| **Business metrics** | Check transaction success rate, order volume | Return to baseline within 5-10 min |119| **Dependency health** | Check downstream service dashboards | No elevated errors |120| **Data integrity** | Run consistency checks on affected data | All checks pass |121| **Customer impact** | Check support queue for new reports | No new incident-related tickets |122123### Step 6: Post-Rollback Actions124125| Action | Owner | Timeline |126|--------|-------|----------|127| Update incident channel with rollback status | On-call engineer | Immediately |128| Notify stakeholders (PM, leadership if customer-impacting) | Engineering manager | Within 30 minutes |129| Create post-incident review ticket | On-call engineer | Within 2 hours |130| Root cause analysis | Deploying team | Within 48 hours |131| Fix and re-deploy plan | Deploying team | Based on severity |132| Update rollback plan if gaps were found | Deploying team | Within 1 week |133134---135136## Output Format137138```markdown139# Rollback Plan — [Service Name] — [Version / Change Description]140141## Deployment Summary142- **Service:** [name]143- **Version:** [from -> to]144- **Change type:** [code / config / migration / infra]145- **Deployment method:** [rolling / blue-green / canary / feature flag]146- **Blast radius:** [what is affected]147- **Rollback owner:** [name / role]148149## Rollback Triggers150| Trigger | Metric | Threshold | Window | Auto/Manual |151|---------|--------|-----------|--------|-------------|152| ... | ... | ... | ... | ... |153154## Rollback Procedure155### Pre-Rollback Checklist1561. [ ] ...157158### Execution Steps1591. ...160161### Data Rollback (if applicable)1621. ...163164## Verification Steps165| Step | Method | Expected Result |166|------|--------|-----------------|167| ... | ... | ... |168169## Post-Rollback Actions1701. ...171172## Appendix173- Previous known-good artifact: [location]174- Database backup location: [location]175- Runbook links: [links]176- Escalation contacts: [names and channels]177```178179---180181## Quality Checklist182183- [ ] Rollback triggers are measurable with specific thresholds, not subjective184- [ ] Rollback procedure can be executed by any on-call engineer, not just the deployer185- [ ] Data rollback is addressed — either confirmed safe or scripted and tested186- [ ] Previous known-good artifact is identified and verified to exist187- [ ] Verification steps cover health, error rate, latency, and business metrics188- [ ] Decision tree covers auto-rollback, manual rollback, and roll-forward scenarios189- [ ] Post-rollback communication plan is included190- [ ] Blast radius and dependency impact are documented191- [ ] Estimated rollback duration is stated for each method192- [ ] Database backup is taken before deployment if data changes are involved193- [ ] The plan has been reviewed by someone other than the deployer194195---196197## Edge Cases198199| Scenario | Handling Approach |200|----------|-------------------|201| **Irreversible database migration** | Do not proceed without a tested restore-from-backup procedure. Take a point-in-time backup immediately before deploy. Estimate restore time and communicate expected downtime. |202| **Rollback causes data loss for new transactions** | Identify the data written during the deployment window. Script extraction before rollback. Replay or manually reconcile after rollback. |203| **Partial rollback in a microservices deploy** | Map service dependency graph. Roll back in reverse dependency order. Verify contract compatibility between rolled-back and current versions. |204| **Feature flag rollback with persisted user state** | Users who interacted with the feature may have state that the old code does not understand. Plan a data cleanup path. |205| **Third-party API version change** | If the deployment included adapting to a new API version and the old version is deprecated, rollback may not be possible. Maintain backward-compatible adapters. |206| **Multi-region deployment** | Roll back region by region. Start with the region showing the worst metrics. Verify each region independently before proceeding. |207| **Rollback during peak traffic** | Consider waiting for off-peak if the issue is not critical. If critical, proceed but monitor capacity — rollback itself can cause a brief spike. |