Rollback
In short
A rollback is the process of returning software to a previous, known-good version after a new deployment causes errors, outages, or other unexpected problems.
What is a rollback in deployment?
A rollback in deployment means undoing a release by switching production back to the last version that worked. Teams roll back when a new release causes errors, slow responses, or broken features, because restoring the old version is usually the fastest way to stop the damage. Once users are safe again, developers can investigate the bug without time pressure.
How a rollback works depends on the deployment method. With containers, you redeploy the previous image version; with blue-green deployment, you switch traffic back to the old environment; and with feature flags, you turn off the new feature without redeploying at all. Good rollbacks are fast and automated, and they are often triggered by monitoring alerts when error rates rise after a release.
Think of it like the undo button in a text editor: when a change goes wrong, you step back to the last good state instead of trying to fix things live. The hardest part is usually data, not code. If a release changed the database schema or wrote data in a new format, the old code may not understand it, so teams design database migrations to be backward compatible, for example by adding new columns before removing old ones.
A deployment rollback is often confused with a roll-forward and with a database transaction rollback. Rolling forward means fixing the problem by quickly deploying a new version that contains a fix, instead of going back. A transaction rollback is a database operation that cancels the uncommitted changes of a single transaction, a much smaller and automatic undo than reverting an entire release.
Key takeaways
- A rollback restores the last known-good version of an application after a bad release.
- It is usually the fastest way to reduce user impact during an incident.
- Blue-green deployments and versioned container images make rollbacks quick.
- Database changes should stay backward compatible so the old code can still run.
- Rolling forward, shipping a quick fix instead, is the main alternative.
Example
# See the revision history of a deployment
kubectl rollout history deployment/web-app
# Roll back to the previous revision
kubectl rollout undo deployment/web-app
# Or roll back to a specific revision number
kubectl rollout undo deployment/web-app --to-revision=3
# Watch until the rollback has finished
kubectl rollout status deployment/web-appReaders ask
What is the difference between a rollback and a roll-forward?
A rollback returns to the previous working version, while a roll-forward fixes the problem by deploying a new version with a patch. Rollbacks are usually faster and safer during an outage, and roll-forwards are useful when going back is impossible, such as after an irreversible data change.
How do you roll back a database change?
Most migration tools let you write a down migration that reverses an up migration, but reversing can lose data written since the change. That is why teams prefer backward-compatible changes, so the old application version keeps working and the schema can be cleaned up later.
What is an automatic rollback?
An automatic rollback is when the deployment system watches health checks or error rates after a release and reverts to the previous version on its own if they cross a threshold, without waiting for a human.
See also
- CI/CDDevOps & Cloud, p. 9CI/CD is a set of automated practices that build, test, and release code changes frequently, so software can be delivered to users quickly and safely.
- Blue-Green DeploymentDevOps & Cloud, p. 5Blue-green deployment is a release strategy that uses two identical production environments and moves all traffic from the old version to the new one at once.
- Database MigrationDatabases, p. 8A database migration is a versioned script that changes a database's schema, such as adding a column, so every environment applies the same changes in order.
- ObservabilityDevOps & Cloud, p. 38Observability is the ability to understand what is happening inside a running software system by collecting and analyzing its logs, metrics, and traces.
- TransactionDatabases, p. 47A transaction is a group of database operations that succeed or fail as a single unit, so the data is never left in a half-finished, inconsistent state.
- KubernetesDevOps & Cloud, p. 32Kubernetes is an open-source system that automates deploying, scaling, and managing containerized applications across a cluster of machines.
Spotted a mistake or something missing on this page?Suggest an edit