> For the complete documentation index, see [llms.txt](https://developer.harness.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.harness.io/continuous-delivery/use-continuous-delivery/manage-deployments/rollback-deployments.md).

# Post-deployment rollback

Rollback your most recent successful deployment.

{% hint style="info" %}
This feature is in Beta[^1] and requires enablement. [View all early access features.](/release-notes/features.md)

{% @harness-feature-flag-access/request-feature-flag-access module="continuous-delivery" pagePath="continuous-delivery/use-continuous-delivery/manage-deployments/rollback-deployments" featureFlags="%5B%7B%22name%22%3A%22Bulk%20post-production%20rollback%22%2C%22key%22%3A%22CDS\_BULK\_POST\_PROD\_ROLLBACK%22%2C%22status%22%3A%22BETA%22%2C%22description%22%3A%22Lets%20you%20select%20multiple%20infrastructures%20from%20the%20service%20dashboard%20and%20trigger%20rollback%20for%20all%20of%20them%20in%20a%20single%20action.%20Requires%20the%20CDC\_SERVICE\_DASHBOARD\_REVAMP\_NG%20flag%20as%20a%20prerequisite.%22%7D%2C%7B%22name%22%3A%22Pipeline-level%20service%20rollback%22%2C%22key%22%3A%22CDS\_ROLLBACK\_OPTION%22%2C%22status%22%3A%22BETA%22%2C%22description%22%3A%22Adds%20a%20dedicated%20Rollback%20button%20to%20pipeline%20execution%20pages%2C%20letting%20you%20start%20a%20rollback%20directly%20instead%20of%20navigating%20through%20instance%20details.%22%7D%5D" %}
{% endhint %}

Post-deployment rollback reverts your most recent successful deployment. This allows rapid, predictable recovery after a deployment that met technical criteria, even if you want to roll back for other reasons.

## What you will learn from this topic

* How to [roll back deployments at the project level](#roll-back-deployments-at-project-level)
* How to [roll back deployments at the account and organization level](#roll-back-deployments-at-account-level-and-organisation-level)
* How to [roll back multiple infrastructures in a single action](#roll-back-multiple-infrastructures-in-a-single-action)
* How to [perform a pipeline-level service rollback](#pipeline-level-service-rollback)
* How to [roll back deployments using API](#rollback-using-api)

## Before you begin

* Post-deployment rollback is supported for the following deployment types only:
  * Kubernetes
  * AWS Auto Scale Group (ASG)
  * Tanzu Application Services (TAS)
  * Amazon Elastic Container Service (ECS)
  * Native Helm
  * Google Managed Instance Group (MIG)

    Harness anticipates expanding this feature to other deployment types in the future.
* Alternatively, for unsupported deployment types such as SSH deployments, users can retrieve the previous version and create a new forward deployment using the required artifact version and manifest.
* You can roll back only successful pipelines. The rollback option is not available for failed pipelines.
* Only the rollback steps that are part of the stage can be used during rollback.
* You cannot roll back the same pipeline more than once. You can perform a rollback if the pipeline is executed again.
* If the pipeline configuration has changed between executions, the previous execution's YAML is used as a reference for rolling back.
* Rollback steps can use expressions that refer to steps executed during the previous pipeline execution. The expressions are automatically resolved with values from the original execution.
* The stages should roll back in reverse order when deployment rollback is triggered.
* Rolling back to a previous post-production deployment is only possible for executions that occurred within the past 30 days.
* You cannot roll back an execution if it is marked successful by the ignore failures failure strategy.

### Roll back deployments at the project level <a href="#roll-back-deployments-at-project-level" id="roll-back-deployments-at-project-level"></a>

For post-deployment rollback, Harness assumes you have created a pipeline with multiple deployments so the rollback steps can revert the pipeline to the last successful deployment.

For more details on creating a pipeline, go to [Create your first CD pipeline](/continuous-delivery/troubleshooting-and-resources/tutorials/kubernetes-container-deployments/manifest.md).

1. Open your [services dashboard](/continuous-delivery/use-continuous-delivery/monitor-deployments/monitor-cd-deployments.md#individual-service-dashboards).
2. In **Summary**, in the **Environments & Groups** panel, select the deployment you want to roll back, and then select the **instances** link.

   Here is an example pipeline where the artifact `library/nginx:stable-perl` is deployed first, and `library/nginx:stable-bullseye-perl` is deployed next.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-cc77536b6b081395af2679a3fbe4f00533f5b76e%2Frollback-deployments-1.png?alt=media)
3. In **Instance Details**, select **Rollback**.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-d8a67253ab133bf8ed44ae67f0186ded46c96490%2Frollback-deployments.png?alt=media)

   Here, you are rolling back the deployed instance with the artifact `library/nginx:stable-bullseye-perl` to the previously deployed instance with the artifact `library/nginx:stable-perl`.
4. In the **Rollback infrastructure** dialog, select **Confirm**.

   The pipeline execution for the rollback stage appears in a new tab.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-59c863a83e5302cf79231b38c94385e8c22377bb%2Frolling-deployments-2.png?alt=media)

   Once the rollback is complete, your deployed instances will revert to their state before the most recent deployment.

   ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-2549e238fc3979d6372e05c33364cd448cffedb4%2Frollback-deployment-3.png?alt=media)

### Permissions required for project-level rollback <a href="#permissions-required-for-project-level-rollback" id="permissions-required-for-project-level-rollback"></a>

To perform post-deployment rollback, the user must have the following permissions:

1. Pipeline **Execute** permission.
2. Environment **Rollback** permission. ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-869d46b2cd22fb937cd11879fde31e51ce1aeafd%2Fpost_prod_rollabck.png?alt=media)

{% hint style="info" %}
A user will be allowed to execute rollbacks on any instance only if they possess these two specified permissions for the pipeline and environment through which the deployment occurred. Otherwise, they will see the following message when they click **Rollback**.

<img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-4854c94b9ecf242594673559345cbbd0e07011f1%2Fpermissions_post_rollback.png?alt=media" alt="" data-size="original">
{% endhint %}

### Roll back deployments at the account level and organization level <a href="#roll-back-deployments-at-account-level-and-organisation-level" id="roll-back-deployments-at-account-level-and-organisation-level"></a>

Users can perform service rollbacks at both the account and organization levels using **Service Dashboards**.

1. For an account-level overview, go to **Account Settings** -> **Services**. For an organization-level overview, go to **Organization Settings -> Services**.
2. Select the service for which you want to perform a rollback. You can also use the search bar to simplify your search.
3. In the Summary tab, you can view all the service deployments performed at the account or organization level.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-957862099e8562c9a53e0ac3ed902a52fe1fae4a%2Frollback-deployment-4.png?alt=media)

4. To distinguish between environments, hover over the Organization/Project on the card to view the service deployment's org\_id and project\_id. You can view the deployments in the Environment, Artifacts, or Charts view.
5. Click **View Instance and Rollback**. All executions are displayed along with their environment details. You can only perform a rollback in the Environment view.
6. Select the deployment for which the rollback is to be performed, and click **Confirm** to initiate the rollback. ![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-72fe48330a007c12413c8189f96b54bea6abd0c3%2Frollback-deployment-5.png?alt=media)

You will be directed to the pipeline execution page, and the Rollback Rollout Step will be executed.

![](https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-c95d98f07a1859b4d9fa8af68e38b286f57ace8e%2Frollback-deployment-6.png?alt=media)

Similarly, users can perform service rollbacks at both the account and organization levels in **Environment Dashboards** by following the same procedures.

1. For an account-level overview, go to **Account Settings** -> **Environments**. For an organization-level overview, go to **Organization Settings -> Environments**.

The remaining steps are the same as those outlined for the Service Dashboards.

### Permissions required for the account and organization-level rollback <a href="#permissions-required-for-account-and-organisation-level-rollback" id="permissions-required-for-account-and-organisation-level-rollback"></a>

To perform a post-deployment rollback, the user must have the following permissions:

1. Pipeline **Execute** permission for the specific pipeline.
2. Environment **Rollback** permission.

A user is allowed to execute rollbacks on any instance only if they possess these two permissions for the pipeline and environment through which the deployment occurred. Otherwise, they see the following message when attempting to click **Rollback**.

### Roll back multiple infrastructures in a single action <a href="#roll-back-multiple-infrastructures-in-a-single-action" id="roll-back-multiple-infrastructures-in-a-single-action"></a>

{% hint style="info" %}
This feature is behind the feature flag `CDS_BULK_POST_PROD_ROLLBACK`. The feature flag `CDC_SERVICE_DASHBOARD_REVAMP_NG` is also required as a prerequisite. Contact [Harness Support](mailto:support@harness.io) to enable the feature.
{% endhint %}

A single service is often deployed across multiple environments and infrastructure types simultaneously. When you need to revert that service across all of them, rolling back the infrastructure one by one is slow. Bulk rollback lets you select multiple infrastructures on the service dashboard and trigger a rollback for all of them in a single action.

Harness processes each selected infrastructure independently. If the rollback for one infrastructure fails, the remaining infrastructures still roll back, and Harness reports the outcome for each target separately.

### Roll back multiple infrastructures <a href="#roll-back-multiple-infrastructures" id="roll-back-multiple-infrastructures"></a>

To roll back a service across multiple infrastructures at once, do the following:

1. Open your [services dashboard](/continuous-delivery/use-continuous-delivery/monitor-deployments/monitor-cd-deployments.md#individual-service-dashboards) and select the service you want to roll back.
2. In **Summary**, select the **instances** link to open the **Bulk Rollback - Instance details** view. This view lists every environment and infrastructure where the service is deployed, along with the environment type, infrastructure, chart version, artifact, and instance count for each row.
3. Select the checkbox next to each infrastructure you want to roll back. You can use the search bar to filter the list when the service is deployed to many infrastructures.
4. To review the deployed instances for a row before you select it, select the view icon in the **Action** column. The **Instance Details** panel shows the pod, artifact, container list, namespace, release name, and deployment metadata for that infrastructure.
5. Select **Rollback selected**.
6. In the **Confirm Rollback** dialog, review each infrastructure and its current artifact. For every infrastructure, select the execution to use for the rollback under **Select Execution to Use for Rollback**. Each execution card shows the instances, artifact, infrastructure, and deployment details for that execution, so you can confirm the target state before you proceed.
7. Select **Confirm Rollback**.

Harness triggers a rollback execution for each selected infrastructure and reports how many rollbacks were triggered and how many failed. You can track the progress of each rollback from its pipeline execution view.

### Permissions required for bulk rollback <a href="#permissions-required-for-bulk-rollback" id="permissions-required-for-bulk-rollback"></a>

The permissions for bulk rollback are the same as for a single post-deployment rollback. For each infrastructure you select, you need Pipeline **Execute** permission on the pipeline that performed the deployment and Environment **Rollback** permission on the target environment. Harness skips any infrastructure for which you do not have both permissions and reports it as a failed target in the response.

### Pipeline-level service rollback <a href="#pipeline-level-service-rollback" id="pipeline-level-service-rollback"></a>

{% hint style="info" %}
This feature is behind the feature flag `CDS_ROLLBACK_OPTION`. Contact [Harness Support](mailto:support@harness.io) to enable the feature.
{% endhint %}

The Service Rollback feature initiates rollbacks directly from pipeline execution pages. Instead of navigating through instance details to find the rollback option, you can start the rollback process with a dedicated **Rollback** button.

This streamlined experience is available across multiple execution views:

**Pipeline Execution Listing Page**

View all pipeline executions in a consolidated list format. The Rollback option is available for each successful deployment execution. Click the three dots menu to the left of the execution to access the rollback option.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-69de699ad6201297b32c3761dc01823bfda3d114%2Fexecutions-listing-page.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

**Pipeline Execution Summary Page**

Detailed view of a specific pipeline execution with all its stages and steps. Access rollback directly from the execution summary by clicking the **Rollback** button at the top right corner of the page.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-373b9568b9fe6085b3da90b1ca4000c3645a8c45%2Fpipeline-execution.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

**Execution History Page**

Comprehensive history of all executions with filtering and search capabilities. Quickly identify and rollback any deployment. Click the three dots menu to the left of the execution to access the rollback option.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-12f5634330601d32dbabeaa44574e7ade1c617c0%2Fexecution-history-page.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

### Service rollback <a href="#how-to-perform-service-rollback" id="how-to-perform-service-rollback"></a>

Perform the following steps to rollback a service:

1. Navigate to any of the execution views described above and locate your deployment.
2. Initiate the rollback:

   * From Pipeline Execution Listing or History Page: Click the three dots menu next to the execution
   * From Pipeline Execution Summary: Click the **Rollback** button in the top right corner

   Select **Service Rollback** from the menu options. A step wizard opens to guide you through the process.
3. **Select Service**: In the first step of the wizard, select the service you want to roll back using the radio button option, then click **Next**.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-bec9c8ff58d0d2a7c76d96f9baa13b20bc35c95d%2Fservice-rollback-1.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

4. **Select Environment**: In the second step, you will see a table that groups deployment instances by environment, along with details such as group, type, infrastructure, artifact, and chart version. Each row represents a specific deployment state. Select the instance you want to roll back to, then click **Next**.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-69b2af2c36e191bcae27a280f91ac176db552d9f%2Fservice-rollback-2.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

The blue-highlighted box shows pipeline executions where this service was deployed. Select the execution you want to roll back to. On the right, you will see the instances deployed in that execution. There can be one or multiple instances depending on how the service was deployed in that particular execution. In this example, the selected execution deployed one instance, but other executions might have deployed multiple instances.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-8642bdc40c8a45ee37e60350bec32206b0c3738f%2Fservice-rollback-3.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

5. **Confirm Rollback**: In the final step, review your selections:
   * Service name
   * Environment name
   * Infrastructure identifier

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-95a132315e9fbad9ac07671cd2d4d931dded1969%2Fservice-rollback-4.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

Click **Confirm** to initiate the rollback.

6. Once confirmed, Harness begins the rollback. The wizard closes, and you are redirected to the execution page, where you can monitor the rollback progress.

<figure><img src="https://3694223630-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fy1JhZ4oKIppwY7d5AhPj%2Fuploads%2Fgit-blob-2740529c3effb456f1d72f5a6920a16a2c53ad5a%2Frollback-initiated.png?alt=media" alt=""><figcaption><p>Click to view full size image</p></figcaption></figure>

The rollback will begin immediately, and you can track its progress in real time through the pipeline execution view.

### Rollback using API <a href="#rollback-using-api" id="rollback-using-api"></a>

You can roll back deployments programmatically using Harness APIs. For more information, go to [Harness API Documentation](https://apidocs.harness.io/tag/Rollback).

To roll back multiple services, environments, and infrastructure targets in a single request, go to the [batch rollback API reference](https://apidocs.harness.io/rollback/triggerrollbackv3).

## Next steps

* Go to [Monitor CD deployments](/continuous-delivery/use-continuous-delivery/monitor-deployments/monitor-cd-deployments.md) to track the status of a rollback execution.

{% @harness-feedback/feedback %}

[^1]: Beta features are feature-complete but still being validated. Available on request.
