Rollback Strategies
Every deployment needs a way back. Fast, practised rollback turns a bad release into a minor incident.
On this page · 5 min · Advanced
On this page
- Learning objectives
- Explanation
- Code example
- Step by step
- Real-world use
- Common mistakes
- Best practices
- Remember this
- Practice exercise
- Mini quiz
- Related topics
- My notes
- Reading time
- 5 min
- Difficulty
- Advanced
- Updated
- Oct 29, 2026
Related tutorials
Interview questions
Learning objectives#
- Roll back by redeploying a previous version
- Use platform rollback features
- Decide between rollback and roll-forward
- Keep databases rollback-safe
Explanation#
Because each release is an immutable versioned artifact, rolling back means deploying the previous version.
Platforms help: App Service slot swap back, kubectl rollout undo, ECS deployment circuit breaker with automatic rollback.
Roll forward (ship a quick fix) when rollback is risky, e.g. after a data migration.
Database changes must work with both versions (expand/contract), or rollback becomes impossible.
Code example: Three ways back#
# Kubernetes: return to the previous ReplicaSet
kubectl rollout history deployment/shop-api -n shop
kubectl rollout undo deployment/shop-api -n shop
# Azure App Service: swap production back with staging (the previous version)
az webapp deployment slot swap -g rg-shop -n app-shop-api --slot staging
# Any platform: redeploy the last good tag through the pipeline
gh workflow run release.yml -f version=v1.4.0
Each command restores the last known good version in under a minute without rebuilding anything.
This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.
Step-by-step explanation#
- rollout history lists previous revisions.
- rollout undo switches back to the previous one.
- Swapping slots again restores the old production build.
- A pipeline with a version input redeploys any earlier tag.
Real-world use case#
An alert fires five minutes after release; the on-call engineer runs one command from the runbook and service is restored.
Common mistakes#
The first time should not be during an outage. Rehearse it.
Dropping columns makes rollback impossible. Contract in a later release.
Best practices#
- Immutable, versioned artifacts
- One-command rollback in the runbook
- Automatic rollback on failed health checks
- Backward-compatible database changes
Remember this#
Rollback = deploy the previous artifact.
undo / swap back / redeploy tag.
Practise before you need it.
Practice exercise#
Your task: When is rolling forward better than rolling back?
Show solution
When the release ran an irreversible data migration, or the fix is tiny and well understood — reverting could cause more harm.
Mini quiz#
Which command rolls back a Kubernetes Deployment?
Want more? Practise all DevOps MCQs · DevOps interview questions
My notes#
Saved in this browser.