Use this when automation must return systems to a known good state after a failed change.
Rollback & Recovery
Rollback and recovery in automation returns systems to a known good state after a failed change, through reverse steps, restored backups or snapshots, or redeploying the previous version.
1. Rollback & recovery: backups, checkpoints, transactions, automatic and manual rollback, resume.
2. Plan before changing.
3. Test.
4. Some changes need roll-forward fixes.
5. Verify recovery.
change → failure → rollback/recover → verify
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Target-state verification ladder Verify boundary
Rollback & Recovery uses a strict target-state ladder for rollback request to restored effective state: request accepted → job/task succeeded → target object changed → effective runtime state confirmed → original workload verified.
Step 2 Verification path Verify boundary
Before change, verify the recovery point exists and is readable/restorable, capture target version/config and define the service check that will show recovery. During a controlled test, introduce a bounded failure after at least one mutation and verify the workflow identifies partial completion. Execute rollback/recovery according to policy, then independently query configuration/data consistency and consumer-facing service health. For backups/checkpoints, a creation success message is insufficient—perform periodic restore tests. For forward-fix recovery, verify the new state explicitly rather than labelling it rollback. Capture which steps were compensated, which were left in place and why. Finally re-run the original transaction/service operation that motivated recovery to show the system is usable.
Step 3 Where it fails Narrow the fault
Separate original change failure, partial-commit detection, recovery artifact availability, restore/compensation execution, dependent-system convergence and service verification. A backup can be healthy while restore fails; restore can complete while database/application versions are incompatible; rollback can succeed on nine targets while the tenth remains changed. Do not retry the original change until current state is re-established. If target state is uncertain after timeout, inspect it before choosing rollback to avoid double-reversal. Preserve the original evidence and recovery point before additional mutation. Recovery is complete only when intended invariants and consumer-facing service are verified, not when the rollback command exits zero.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
Subtopics
Go one level deeper into this subject.
A rollback strategy decides in advance how each change is undone — reverse steps, restore backup, redeploy previous version, snapshot revert — and when to trigger it.
Subtopic Configuration BackupConfiguration backup saves the current configuration before a change, such as copying running configs to Git or exporting settings, so the previous state can be restored exactly.
Subtopic State BackupState backup saves tool state such as Terraform state files, databases or inventories before changes, so automation does not lose track of what it manages if a run goes wrong.
Subtopic CheckpointA checkpoint in rollback and recovery is a saved known-good point, such as a config archive, VM snapshot or database savepoint, that the system can return to.
Subtopic TransactionA transaction groups changes so they all succeed or all fail together, such as a database transaction or NETCONF candidate commit, avoiding half-applied changes.
Subtopic Automatic RollbackAutomatic rollback reverts a change by itself when post-change checks fail, such as a confirmed commit timing out, a deployment health check failing or a pipeline running its rollback job.
Subtopic Manual RollbackManual rollback is a documented procedure an engineer follows to undo a change when automatic rollback is not possible or safe, with clear steps and verification.
Subtopic Partial FailurePartial failure in rollback and recovery means some targets were changed and some not.
Subtopic ResumeResume in recovery continues a failed job from its last successful checkpoint after the cause is fixed, instead of rolling everything back and starting again.
Subtopic Recovery VerificationRecovery verification confirms that after a rollback or restore, systems are back to the expected configuration and services work, using the same checks as normal post-change verification.
- Plan rollback before the change.
- Back up configuration and state first.
- Verify after rollback, not just run it.
- Rollback strategy per automation — plan
- Backups/snapshots before change — restore points
- Recovery verification — proof
ReferenceWhy it matters1 section · depth on demand
In depth
Rollback and recovery are the plans and mechanisms for returning systems to a known-good state when a change or failure goes wrong. In automation they must be designed and tested as carefully as the change itself.
| Mechanism | Example |
|---|---|
| Revert configuration | configure replace, git revert + redeploy |
| Restore snapshot | VM or storage snapshot |
| Previous artifact | Redeploy previous image/tag |
| Forward fix | Small corrective change |
| Restore from backup | Data recovery |
Not every change can be rolled back (database migrations, deleted data) — identify those in planning and protect them with backups.
ReferenceImportant terms & boundaries1 section · depth on demand
Mechanics
Rollback and Recovery are not synonyms. Rollback attempts to restore a known previous state or configuration; recovery restores service/consistency and may require a forward fix, failover, replay or selective compensation rather than literal reversal. Many automation operations are not transactionally reversible: external APIs can create durable IDs, schema migrations can destroy information, and fan-out changes can partially complete. A safe design records pre-change state and a recovery point before mutation, tracks exactly which steps/targets committed, and defines compensation per boundary. Block/rescue constructs can orchestrate recovery logic, but successful rescue only means the recovery steps ran according to their tool semantics—it does not show business/service state is healthy.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle
For each mutating automation path, classify reversibility before release: reversible by config restore, recoverable from backup/checkpoint, forward-fix only, or manually escalated. Define backup freshness, restore ownership, retention and test cadence. Keep rollback scripts/config under the same review/version control as deployment logic and ensure they support the currently deployed schema/version, not merely the prior one. Avoid automatic rollback for failures where the previous state is unknown or rollback itself can worsen partial data. Record change checkpoints and per-target progress so recovery can be selective. Regularly exercise recovery in a representative environment, including controller restart/interruption. Retire recovery artifacts only after the corresponding deployment/version is no longer recoverable through them.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in > Rollback & Recovery. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://docs.ansible.com/projects/ansible-core/2.18/playbook_guide/playbooks_blocks.html · confidence 94%Quick lookup tables
→ Rollback & Recovery · operational reference
Context-specific ownership, verification, output and failure-boundary lookup for → Rollback & Recovery.
| Layer | Rollback & Recovery operational reference |
|---|---|
| Runtime/ownership | Automation rollback/recovery patterns / Ansible current · identify controller/worker/target ownership before mutation |
| Persistent intent | Versioned configuration/playbook/workflow with explicit dependencies and least-privilege identity |
| Verification | ansible-playbook recovery.yml --check --diff; ansible-playbook recovery.yml -vv |
| Expected interpretation | Pre-change evidence and recovery points exist, partial completion is identified, rollback/forward-fix changes only demonstrated state, and final service state is independently verified. |
| Recovery boundary | Preserve correlation IDs + pre-state, then verify target/service independently after remediation |
Deep reference
Healthy vs suspicious evidence
Output interpretation
Recovery output should preserve change/execution ID, pre-change version/checkpoint/backup ID, completed-step/target set, original failure, selected recovery strategy, each compensation/restore result and final verification. Distinguish “rollback started,” “rollback completed technically,” and “service recovered.” When a rescue handler changes the final automation result, retain the original failure so it is not erased from audit history. For distributed changes, output per-target recovery state and any manual follow-up. Store checksums/version IDs for restored configuration/artifacts where possible. Sensitive backup locations/credentials must be protected. This structure lets an operator show exactly what state was restored instead of relying on a generic recovered flag.