A bad backend release needs a rehearsed undo path: redeploy the previous image, watch database expand/contract rules, and use feature flags when compute alone cannot save you. How rollback works on AWS and Kubernetes, and how Encore environments and deploy history fit without inventing a one-click traffic switch.
A deployment rollback is the rehearsed path that returns a backend to a known-good revision when a release fails in production. Compute is the easy half: point the load balancer or task set at the previous image. Shared state is the hard half, because a forward migration the old code cannot read turns a fast undo into an outage with homework.
This guide covers the common undo patterns for backends, the database rules that decide whether rollback is safe, and what Encore does for environments, deploy visibility and rolling updates without claiming a blue-green traffic switch it does not have.
Teams running rolling deploys on ECS, Cloud Run or Kubernetes undo a bad release by deploying the previous container image or git commit. Kubernetes keeps ReplicaSet history so kubectl rollout undo can move the Deployment back. ECS and many CI pipelines do the same by re-applying the prior task definition or image digest.
The requirement is that the previous binary still runs against the current database and message schemas. If the bad release already applied a breaking migration, redeploying the old image fails even though the deploy machinery worked.
Blue-green deployment keeps an idle production-capable environment so rollback is the same traffic switch in reverse: send users back to blue and investigate green offline. Canary deployments undo by shifting weight from the canary cohort back to stable, often automatically when error or latency alarms fire.
AWS documents weighted target groups on an Application Load Balancer and canary or linear schedules in CodeDeploy for ECS and Lambda. Those paths need the extra target groups, roles and controllers set up before the incident. They are not free side effects of a normal rolling update.
Treat schema changes as a sequence the old code can survive:
Destructive changes in the same deploy as the code that needs them remove the rollback path. Encore applies up migrations automatically and requires down migrations to be run manually, which is a reminder that database undo is an explicit operation, not a side effect of redeploying compute.
Feature flags turn off a risky code path without moving traffic or images. They help when the bug is behavioral and the schema is still compatible. They do not reverse a migration that already rewrote rows, and they do not replace health checks or a rehearsed redeploy for process crashes and bad images.
Releases in Encore are infrastructure from code, provisioned and deployed into your own AWS or GCP account. Encore does not document a one-click rollback that flips traffic to an idle blue environment or a weighted canary schedule. Rollback for compute is redeploying a previous commit; safer releases come from preview environments, expandable migrations and rolling updates behind health checks.

Run in your terminal to get started locally.
Keep a version marker and expandable schema so a redeploy of the previous commit stays valid:
// hello/hello.ts
import { api } from "encore.dev/api";
import { SQLDatabase } from "encore.dev/storage/sqldb";
const db = new SQLDatabase("hello", { migrations: "./migrations" });
export const version = api(
{ expose: true, method: "GET", path: "/version" },
async (): Promise<{ release: string }> => {
return { release: "2026-11-06" };
},
);
export const greet = api(
{ expose: true, method: "GET", path: "/hello/:name" },
async ({ name }: { name: string }): Promise<{ message: string }> => {
const row = await db.queryRow<{ note: string | null }>`
SELECT note FROM greets WHERE name = ${name}
`;
return { message: row?.note ?? `hello ${name}` };
},
);
Add columns in a forward migration without dropping the old shape in the same change:
-- hello/migrations/2_add_note.up.sql
ALTER TABLE greets ADD COLUMN IF NOT EXISTS note TEXT;
Link the app to GitHub, and each pull request can get a preview environment with its own API URL so QA hits the change before merge. Production uses Encore's rolling deploy into your account: new tasks come up, pass health checks, take traffic, and old tasks drain. Encore provisions an IAM role for the service. When a release is bad and the schema is still compatible, revert or push the previous commit to the environment branch and watch the new deploy under Deployments. An AI coding agent can ship the /version and migration change in one pull request, run it under encore run, and rely on the preview environment for the shared check before anyone talks about rollback.
Best fit: Teams that want infrastructure from code, preview environments and fast redeploys of previous commits in their own cloud, with expand/contract migrations as the rule that keeps rollback possible.
A deployment rollback returns production traffic to a known-good application revision after a bad release. That usually means redeploying a previous container image or switching a load balancer back to the prior environment, while leaving shared databases in a state both versions can use.
Ship schema changes as expand/contract steps: add columns or tables first, deploy code that dual-reads or dual-writes, then remove old columns only after the old code is gone. Never roll back compute onto a schema the previous revision cannot read.
Blue-green cutover and weighted canary shifts undo with a traffic switch when you already run those patterns. For ordinary rolling deploys, the usual path is redeploying the previous commit or image while feature flags turn off the risky behavior. Preview environments catch many failures before production.
Encore does not document a dedicated one-click rollback control that switches traffic to an idle environment. You monitor Deployments in the dashboard, redeploy a previous commit by pushing or reverting that revision, and use rolling updates behind load balancer health checks. Preview environments per GitHub pull request catch many failures before production.
Deploy to your cloud on AWS and Google Cloud
without managing infrastructure
Encore lets developers and agents define application infrastructure directly in code, then automatically provisions it from local development to production in your AWS or GCP account.