• Docs
  • Talk to an expert
Blog
Blog
BlogProductCase studiesNewsInsights
Blog

What is a deployment rollback?

deploymentGitDevOps
23 November 2026
Share

TL;DR

  • A rollback returns an app to the last version that worked, after a release causes problems.
  • Rolling back code is usually quick. Rolling back data is the hard part, because users may have created or changed data since the release.
  • Common ways to roll back are redeploying the previous version, reverting the change in Git, switching traffic back to the old version, or restoring a backup.
  • Sometimes it's safer to fix forward: ship a small fix instead of undoing the whole release.
  • Plan rollbacks before you need them, especially for releases that change the database.
  • On Upsun Cloud, you roll back code by reverting it in Git and pushing, and you can restore an environment's code and data from a backup.

A deployment rollback is the process of undoing a release by returning an app to its previous working version. When a new release causes errors, slows the site down, or breaks a feature, rolling back gets users back to something that works while the team investigates.

It sounds simple, and for code it often is. The complications come from data, and from changes that can't easily be undone. This guide explains the ways to roll back, how to handle the database, and when fixing forward is the better choice.

How a rollback works

Key takeaway: a rollback has two parts, the code and the data. Code is easy to restore. Data usually isn't.

Code lives in version control, so every previous version still exists. Putting an older version back is mostly a matter of deploying it again.

Data is different. Between the release and the rollback, users may have signed up, placed orders, or edited content. If the release also changed how data is stored, the old code may not understand the new data, and putting the old data back would erase everything users did in between.

So rollbacks usually restore the code and leave the data alone, and the hard cases are releases that changed the database.

Ways to roll back a deployment

Key takeaway: the right method depends on how fast you need to act and whether the release changed data.

MethodHow it worksSpeedUndoes data changes?
Redeploy the previous versionDeploy the last working version againMinutesNo
Revert in GitCreate a new commit that undoes the bad change, then deploy itMinutesNo
Switch traffic backWith blue-green deployments, send traffic back to the old copy that's still runningSecondsNo
Turn off a feature flagDisable the new feature without deployingSecondsNo
Restore a backupReturn code and data to the moment the backup was takenMinutes to hoursYes, and it erases everything since

Reverting in Git keeps a clear record of what happened, because the undo is a commit of its own. Restoring a backup is the most complete option and the most drastic, because data created after the backup is lost.

Rollback vs fixing forward

Key takeaway: if the problem is small and the fix is obvious, shipping a fix can be safer than undoing the whole release.

Fixing forward, also called rolling forward, means releasing a new version that fixes the problem instead of returning to the old one. It avoids the data complications of a rollback, and it suits small, well-understood bugs.

Roll back when the problem is serious, the cause is unclear, or a fix would take more than a few minutes to write and test. Fix forward when the cause is obvious, the fix is small, and rolling back would cause its own trouble, for example because the release changed the database.

Rollbacks and the database

Key takeaway: plan database changes so the previous version of the code can still run against them.

A database migration that adds a column is easy to live with: the old code simply ignores it. A migration that renames or removes a column is not, because the old code expects it to be there.

Two habits make rollbacks safer:

  1. Make database changes in steps that the old code can survive, for example by adding the new column first and removing the old one in a later release.
  2. Take a backup before any release that changes the database, so a full restore is possible if everything else fails.

Common rollback mistakes

Key takeaway: many rollback problems come from not planning the rollback before the release.

MistakeWhat happensHow to avoid it
No rollback planThe team works out how to undo a release in the middle of an incidentDecide how each release would be rolled back before it ships
Restoring a backup by reflexEvery order, sign-up, or edit since the backup is lostRestore code first, and only restore data when you must
Rolling back code but not configurationThe old code runs with new settings and fails differentlyKeep configuration in version control alongside the code
A migration the old code can't handleThe rollback itself breaks the siteMake database changes the previous version can live with
Testing only the happy pathProblems appear only with real data and real trafficTest releases against a realistic copy of production first

Rollbacks on Upsun Cloud

Key takeaway: on Upsun Cloud, you roll back code through Git, and you can restore an environment's code and data from a backup.

Upsun Cloud deploys whatever is in your Git repository, so the usual way to roll back code is to revert the change in Git and push. That creates a new commit that undoes the bad one, and Upsun Cloud builds and deploys it like any other change.

If a bad push is still building or deploying, you can stop it with upsun activity:cancel, as described in the docs on cancelling an activity.

For changes that affect data, backups give you a fuller rollback:

What to knowDetails from the Upsun docs
What a backup includesThe environment's complete code and data, including every service's data and files stored on mounts
Automatic backupsProduction environments are backed up automatically on a schedule
Manual backupsAdmins can take one before a risky change with upsun backup:create
Restoringupsun backup:restore <BACKUP_ID> returns the environment's code and data to the moment of the backup. The resources of each container also return to what they were then
Your Git repositoryIsn't changed by a restore. To keep the restored code, revert it in Git yourself. To go back to your latest code, redeploy or push a new change
DownloadingBackups are stored on Upsun Cloud and can't be downloaded. Export your data separately if you need a copy

The docs suggest taking a backup before merging another environment into production. Testing the change in a preview environment first, which by default starts with a copy of its parent's data, also catches many problems before a rollback is needed. Our guide What is a preview environment? explains how.

You can deploy on Upsun Cloud free for 15 days, with no card needed, or read the docs on restoring an environment.

Frequently asked questions

What is a rollback in software deployment?

Returning an app to its previous working version after a release causes problems.

What is the difference between a rollback and a roll forward?

A rollback returns to the previous version. A roll forward, or fix forward, releases a new version that fixes the problem instead.

Can you roll back a database migration?

Sometimes. Some migrations include an undo step, but data written since the release can make it unsafe. Restoring a backup also undoes data changes, but loses everything created since the backup.

How do you roll back with Git?

Use git revert to create a new commit that undoes the bad change, then deploy that commit. This keeps the full history, unlike rewriting it.

How long should a rollback take?

As short as possible. Redeploying or reverting code usually takes minutes, switching traffic back in a blue-green setup takes seconds, and restoring a large backup can take longer.

How do I roll back on Upsun Cloud?

Upsun Cloud rolls back code through Git: revert the change and push. For code and data together, restore the environment from a backup.

Stay updated

Subscribe to our monthly newsletter for the latest updates and news.

Deploy possibility.
Try Upsun for free.

Build with DispatchDeploy on Cloud