A dependable rollback process turns a stressful deployment failure into a coordinated team response. This playbook gives open-source maintainers and development teams a reusable incident workflow, rollback-strategy comparison, runbook checklist, starter scripts, and postmortem template for CI/CD systems built around Git, containers, and self-hosted infrastructure.
Overview
A rollback is not simply the command that restores an earlier version. It is a collaboration process: someone identifies the impact, someone coordinates communication, someone verifies the recovery, and the team records what happened. In an open-source project, that process may also involve maintainers in different time zones, external contributors, public issue discussions, and deployment credentials held by only a few people.
Prepare the process before an incident. Every release should have a known artifact, a version identifier, a health check, and a documented way to restore the previous safe state. The pipeline should also make it possible to distinguish an application failure from a database, infrastructure, dependency, configuration, or third-party service problem.
Keep the workflow independent of a particular vendor. The same principles can be implemented with a hosted Git service, a self-hosted CI/CD platform, or a runner connected to Docker and Kubernetes. For background on runner choices, see the comparison of self-hosted CI/CD tools. If your team deploys directly from a repository, the repeatable Git deployment workflow provides useful preparation steps.
Define the incident before choosing the response
Write down what qualifies as an incident and who can declare one. Useful signals include failed health checks, elevated error reports, broken authentication, data integrity concerns, a security alert, or a release that prevents users from completing a core task. Avoid waiting for perfect certainty. The incident lead can classify the event as an initial hypothesis and revise it as evidence improves.
- Impact: Which users, environments, regions, APIs, or project services are affected?
- Scope: Did the problem begin with a release, configuration change, dependency update, infrastructure change, or external service?
- Owner: Who is coordinating the response and who is authorized to approve a rollback?
- Evidence: Which logs, metrics, traces, deployment records, and issue reports support the current assessment?
- Exit criteria: What must be true before the incident can be considered contained and resolved?
Checklist by scenario
Choose a rollback strategy
| Strategy | Best fit | Strength | Double-check |
|---|---|---|---|
| Blue/green | Two separately deployable application environments | Fast traffic switch with a preserved previous version | Both environments must use compatible configuration and data contracts |
| Canary | Releases that can be exposed to a limited audience | Limits impact while health signals are collected | Define automatic and manual promotion or rollback thresholds |
| Feature flags | Changes that can be disabled independently of a deployment | Separates code release from user-facing activation | Flags need ownership, safe defaults, and an expiration or cleanup plan |
| Revert PR or commit | Projects where the prior source revision can be rebuilt and redeployed | Creates a visible, reviewable history in the repository | Confirm that rebuilding produces the intended artifact and does not repeat the failure |
Before every release
- Record the commit identifier, build identifier, image digest, configuration revision, and migration state.
- Confirm that the previous known-good artifact is still available and that the team knows how to deploy it.
- Run unit, integration, smoke, and security checks appropriate to the project.
- Test the rollback path in a non-production environment when the release changes deployment logic, data access, authentication, or infrastructure.
- Assign a release owner and a rollback decision-maker. These can be the same person for a small project, but the responsibility must be explicit.
- Publish the expected change window, validation checks, and escalation channel in the team’s normal collaboration space.
When a deployment is failing
- Declare and record: Open an incident issue or channel. Add the start time, affected component, suspected release, and current impact.
- Pause forward motion: Stop automatic promotion and prevent unrelated releases from entering the same environment.
- Check the smallest safe action: If a feature flag can disable the failing behavior without masking a deeper issue, use it. Otherwise, select the tested rollback path.
- Preserve evidence: Save logs, deployment output, relevant configuration, image digests, and a timeline before rotating or deleting resources.
- Execute with two-person verification where practical: One person runs or supervises the action while another confirms the target version and environment.
- Validate: Check service health, error rates, key user journeys, background jobs, queues, and data-writing operations. A green deployment command is not proof of recovery.
- Communicate: State what changed, what users should expect, and when the next update will arrive. Avoid assigning blame while facts are still incomplete.
- Stabilize: Keep the failing release blocked until the team has identified a safe correction, test coverage, and a new release plan.
Starter rollback commands
Use placeholders rather than copying commands directly into production. The exact syntax depends on your deployment system, permissions, namespaces, and release process.
# Generic container rollback: replace values after verification
export IMAGE_REF="registry.example/project/app@sha256:KNOWN_GOOD_DIGEST"
export ENVIRONMENT="staging"
# Build or select the approved deployment artifact
./scripts/deploy.sh --environment "$ENVIRONMENT" --image "$IMAGE_REF"
# Run project-specific checks
./scripts/smoke-test.sh --environment "$ENVIRONMENT"
# Kubernetes-style example: verify the target before changing production
kubectl -n YOUR_NAMESPACE rollout history deployment/YOUR_DEPLOYMENT
kubectl -n YOUR_NAMESPACE rollout undo deployment/YOUR_DEPLOYMENT --to-revision=KNOWN_GOOD_REVISION
kubectl -n YOUR_NAMESPACE rollout status deployment/YOUR_DEPLOYMENT --timeout=TIMEOUT
For a Git-based revert, create a clearly named branch or revert change, run the normal checks, and let the same protected deployment path build and promote the result. Do not treat a source revert as a substitute for checking schema compatibility, queues, caches, or external side effects.
What to double-check
Data and migrations
Application code may be reversible while a database change is not. Prefer additive schema changes when possible: introduce a compatible field, deploy code that can use both shapes, migrate data, and remove the old shape only after the rollback window has passed. A rollback runbook should identify whether the database requires a separate action, a forward fix, or restoration from a verified backup. The database migration workflow covers this distinction in more detail.
Secrets, configuration, and dependencies
- Confirm that the previous version works with the current secrets and environment variables.
- Record configuration changes separately from application releases so the team can identify which one introduced the problem.
- Check whether a dependency update changed runtime behavior even when application code did not. An automated update workflow should still produce a reviewable, reproducible artifact; see the Renovate and Dependabot workflow guide.
- Keep an SBOM or equivalent dependency record for release comparison and incident investigation. The SBOM and dependency scanning workflow provides a practical model.
Access and observability
Test that the people on call can actually read deployment logs, inspect health signals, access the repository, and run the rollback command. Use short-lived or narrowly scoped credentials where possible, and document an emergency access path without placing secrets in the repository. Define service-level objectives and a target mean time to recovery appropriate to the project’s risk and capacity. These are planning targets, not universal standards; review them with maintainers and users.
Reusable runbook template
# Incident: [short name]
Date and time started: [UTC timestamp]
Incident lead: [name or handle]
Technical lead: [name or handle]
Affected service and environment: [value]
User impact: [plain-language summary]
Suspected change: [commit, artifact, config, dependency, or infrastructure]
Known-good version: [commit, image digest, or release identifier]
Rollback method: [blue/green, canary, flag, revert, or other]
Validation checks: [links or commands]
Communication channel: [link]
Decision log:
- [UTC time] [decision] [owner]
Recovery confirmed at: [UTC timestamp]
Follow-up owner and due date: [name] [date]
Common mistakes
- Keeping only source code: A repository may point to a prior commit while the built artifact, package lockfile, or deployment metadata is unavailable. Retain enough information to reproduce or select the known-good release.
- Rolling back without checking data compatibility: Reverting application code can make a previously valid schema or event format unreadable.
- Making the incident lead debug everything: Separate coordination, technical investigation, communications, and release execution when staffing allows. This reduces duplicated work and keeps decisions visible.
- Using chat as the only record: Chat is useful for fast coordination, but summarize decisions in a durable incident issue or document.
- Automating an unsafe rollback: Automation should verify environment, target version, permissions, and health signals before changing traffic or workloads.
- Declaring success too early: A restored process may still leave queued jobs, partial writes, stale caches, or a degraded user journey. Validate the system from the user’s perspective.
- Blaming the contributor: A blameless review examines system conditions, review gaps, test coverage, release controls, and unclear ownership. It should still produce specific corrective actions.
Postmortem template
Complete the postmortem after recovery, while the timeline and decisions are still available. Keep it factual and concise enough that contributors will use it.
- Summary: What happened, which component was affected, and how users experienced it?
- Timeline: List detection, declaration, key decisions, rollback or mitigation, validation, and resolution in UTC.
- Trigger and contributing factors: Identify the immediate change and the conditions that allowed the issue to reach users.
- What worked: Note tests, alerts, documentation, communication, or rollback controls that reduced impact.
- What failed: Describe missing signals, confusing ownership, unsafe assumptions, or unavailable artifacts.
- Actions: Assign each corrective action an owner, a due date, and a verification method. Prefer changes to automation, tests, access, or documentation over vague reminders.
- Follow-up: Link the relevant issue, release, security review, or dependency record.
When to revisit
Review this playbook on a monthly or per-release cadence, especially after a rollback drill. A drill should use a disposable environment or a carefully bounded test and should answer practical questions: Can the team identify the correct artifact? Can an authorized person execute the procedure? Do health checks detect the failure? Does the previous version work with current data and configuration? Are the logs sufficient to reconstruct the timeline?
Refresh commands, starter scripts, and integration notes quarterly and immediately after a major CI/CD tool release or a widely reported security incident affecting your stack. Revisit the document before seasonal planning cycles, a change in hosting model, a new Kubernetes or container workflow, a repository migration, or a significant change in maintainer availability.
After each drill or real incident, record the outcome beside the runbook rather than silently changing it. Remove commands that no longer match the deployment system, add the missing validation step, and update ownership. Teams that use self-hosted infrastructure may also want to review their local development assumptions with a reproducible dev container setup and keep repository responsibilities visible through an open-source maintenance checklist.
Next action: choose one non-production service this week, identify its known-good artifact, run the rollback procedure with the people who would respond to an incident, and turn every point of confusion into a concrete runbook update.