AI and Automation

Rollback Plans for Automated Fixes: A Practical Guide

22 September 2026 9 min read

An automated fix that cannot be undone is not automation, it is a bet. Before any patching pipeline pushes a change without a human watching every step, the team running it needs a documented, tested answer to one question: if this breaks something, how exactly do we get back to the last known-good state, and how long will that take. Most remediation programs write extensive rules for what to patch and when, then treat rollback as an afterthought, a manual SSH session and institutional memory. That gap is where automated patching programs lose trust after the first bad deployment.

Why every automated change needs a defined reverse action before it runs

A patch job that has no rollback definition is not safe to run unattended, regardless of how well-tested the forward path is. The reasoning is simple: the forward path was tested against a staging environment or a representative sample, but production has configuration drift, third-party agents, custom kernel modules, and load patterns that staging does not reproduce. Some fraction of automated fixes will fail against a live host in ways the pre-deployment checks did not catch.

The practical rule is to require a reverse action as a field in the change definition itself, not as separate documentation. If a runbook says “patch OpenSSL to 3.0.14 on all Ubuntu 22.04 web nodes,” the same record should carry the exact downgrade command, the package version being replaced, and the verification check that proves the downgrade succeeded. When rollback is a property of the job rather than a hope, it survives staff turnover and 3 a.m. incidents where nobody remembers which engineer wrote the original patch script.

This also changes what “automated” should mean in a remediation pipeline. Automating the forward action while leaving rollback manual just moves the bottleneck; you have automated the easy 95% of the work and kept the hard, time-pressured 5% fully manual. A pipeline is genuinely automated only when both directions, apply and revert, are codified and tested with the same rigor.

Rollback patterns per change type: package downgrade, config restore, service state, registry key

Rollback is not one mechanism. Each class of change has a distinct reversal method, a distinct verification step, and a distinct time budget. Treating them uniformly is where automation scripts break.

Package downgrade

On Debian-based systems, pin the previous version before patching with apt-mark hold-equivalent state capture: record the output of dpkg -l | grep <package> before applying the update, and store the exact version string. Rollback is apt-get install <package>=<previous-version> followed by a hold to prevent the scheduler from re-patching it on the next cycle before the incident is understood. On RHEL-family systems, yum history gives you a transaction ID; yum history undo <id> reverses a specific transaction cleanly, provided the local repo cache still holds the old package, which is why remediation pipelines should mirror packages locally rather than relying on upstream repos that prune old versions after 90 days.

Config restore

Never edit a config file in place without a timestamped copy first. The convention that scales is /etc/app/config.yaml.pre-patch.<job_id>, written before the automated edit touches the live file, with a SHA-256 checksum logged against the job record. Rollback is a file copy plus a service reload, not a re-run of whatever templating logic produced the new file, because that logic may itself be the thing that is broken.

Service state

Service and daemon changes (a new systemd unit, a changed restart policy, a modified firewall rule set) need their own state snapshot. Capture systemctl show <unit> --no-page output and the active firewall ruleset (iptables-save or nft list ruleset) before modification. Rollback restores the exact unit file and reloads the daemon manager, then confirms the service reaches the “active (running)” state within a defined timeout, typically 30 to 60 seconds depending on startup complexity.

Registry key

On Windows endpoints, export the affected key before any write with reg export HKLMSoftware<path> backup.reg. Rollback is reg import backup.reg. For changes that touch multiple keys or that a group policy refresh could partially overwrite, a full System Restore point taken immediately before the change gives a coarser but more reliable fallback, at the cost of reverting unrelated changes made in the same window. Choose the restore point approach when the fix touches more than three related keys or any key under a path that other agents also write to.

Change type Pre-change capture Rollback action Verification
Package update Exact version string, repo mirror snapshot Pinned reinstall of prior version Version check plus service health check
Config file Timestamped copy with checksum File restore plus reload Checksum match, config lint pass
Service state systemctl show output, firewall ruleset Unit file restore, daemon reload Active/running state within timeout
Registry key reg export of affected keys reg import or restore point Key value diff against export

Capturing pre-change state so restoration is exact, not approximate

An approximate rollback is worse than no rollback, because it gives the on-call engineer false confidence that the system is back to normal when it is actually in a third, undocumented state. Exact restoration requires capturing state at the right granularity, not just “before” and “after” but the specific artifacts that changed.

Three practical habits make the difference. First, hash everything you back up. A config copy without a checksum cannot prove it is the file that was actually running before the patch, versus a stale copy from a previous job. Second, capture state immediately before the change executes, inside the same automation run, not from a nightly backup that might be 20 hours stale. A rollback built on a stale backup can reintroduce a vulnerability that a separate, unrelated fix had already closed. Third, store the pre-change state alongside the job ID and the finding ID that triggered the patch, so a rollback six weeks later doesn’t require reconstructing which change caused which state from log timestamps.

For infrastructure that supports it, snapshot-based capture removes most of the exactness problem entirely. LVM snapshots, ZFS snapshots, or VM-level snapshots taken immediately before a patch window let you revert an entire host to its pre-patch state in one operation, at the cost of storage overhead and a coarser blast radius (a VM snapshot rollback reverts everything on that host, not just the patched component). For single-host fixes with tight change scope, file and key level rollback is cheaper and faster; for kernel updates or changes with wide blast radius, snapshot rollback is worth the storage cost.

Changes that cannot be rolled back, and how to treat them differently

Some remediation actions are irreversible by nature, and pretending otherwise creates false confidence. Database schema migrations that drop a column, credential rotations that invalidate old keys, and firmware updates on network hardware typically fall into this category. Treat these differently at three points in the pipeline:

  • Pre-execution gate: any change flagged as irreversible should require explicit human approval regardless of how the rest of the pipeline is configured, even if lower-risk changes in the same batch are fully automated.
  • Forward-only verification: since you cannot revert, the pre-deployment test coverage for this change class needs to be higher than for reversible changes. Run the change against a full staging replica, not a subset, before it touches production.
  • Compensating action instead of rollback: for credential rotation, the compensating action is re-issuing the old credential alongside the new one during a grace window, not literally reversing the rotation. For a schema change that drops a column, the compensating action is restoring from a database backup taken before the migration, which is a different operation with a different time cost (often 30 minutes to several hours depending on database size) than an in-place rollback.

Document this distinction explicitly in the runbook: “no rollback exists, recovery requires restore from backup taken at <time>, estimated recovery time <X> minutes.” An honest “this will take 40 minutes to fix if it goes wrong” is more useful to an on-call engineer than a rollback button that silently does not work.

Automatic rollback triggers versus human-invoked rollback

Deciding whether a rollback fires automatically or waits for a person is a risk calibration problem, not a binary automation preference. The criteria that should drive the decision:

  • Blast radius: a change scoped to one non-production-facing host is a reasonable candidate for automatic rollback on failure. A change touching a load-balanced tier of customer-facing nodes should require a human to confirm the rollback, because an automatic rollback across an entire tier can itself cause an outage if triggered by a flaky health check rather than a real regression.
  • Health check confidence: automatic rollback needs a health check that is hard to false-positive on. A single HTTP 200 check is not enough; combine it with an error rate threshold (for example, rollback if 5xx responses exceed 2% of traffic over a 5-minute rolling window) and a latency threshold, so a transient blip does not trigger a full reversal.
  • Time-to-detect versus time-to-harm: if the failure mode for a given change could cause data loss or a security exposure within minutes, automatic rollback with a short detection window is justified even at the cost of occasional false triggers. If the worst case is degraded performance that a human would notice within the normal on-call response time, human-invoked rollback with a clear alert is the better trade-off.

Platforms that automate the remediation phase, such as SITEY, apply this distinction at the pipeline level: low blast-radius patches inside a defined maintenance window can auto-rollback on a failed health check, while changes flagged as high-impact route through an approval gate before either the forward action or a rollback executes, so a person confirms the direction of travel in both cases. The mechanism that matters here is not the approval step itself but the health check feeding it: a rollback trigger is only as trustworthy as the signal that decides whether the patch worked, which is why re-testing the specific vulnerability after the fix, rather than trusting a script’s exit code, catches failures that a generic uptime check misses.

Testing rollback paths regularly so they work under pressure

A rollback procedure that has never been executed outside of documentation is unverified code, and unverified code fails at the worst possible time. The fix is to exercise rollback paths on a schedule, not just after an incident forces you to.

Concrete practices that hold up under audit and under pressure:

  • Run a scheduled “game day” quarterly where a subset of production-representative staging hosts are patched and then deliberately rolled back, timing each step against the documented estimate. If the documented rollback says 5 minutes and the actual run takes 25, fix the documentation or the tooling before the next real incident exposes the gap.
  • Include rollback verification in the same test suite that validates the forward patch. If a CI pipeline checks that a patch applies cleanly, it should also check that the corresponding rollback script executes against a snapshot of the pre-patch state and restores the exact checksum.
  • Rotate which engineer runs the rollback drill. A rollback that only the original author can execute correctly is a rollback that fails when that person is unavailable, which is disproportionately likely during a major incident that pulls in whoever is on call rather than whoever wrote the original fix.
  • Track rollback drill results as a metric, not just a checklist item: success rate, time-to-complete, and number of manual interventions required. A rollback path that needed three manual interventions in the last drill is not ready to be trusted as automatic.

The goal is not a rollback plan that exists on paper. It is a rollback plan that a tired engineer, at 2 a.m., following the documented steps exactly, can execute correctly on the first attempt. That standard is only reachable through repetition before the pressure is real.

About SITEY

SITEY is an autonomous vulnerability management platform. It discovers, validates, prioritizes, remediates and re-tests vulnerabilities through an eight-phase automated pipeline, unifying output from 17 integrated scanners. SITEY is self-hosted: it runs in your own infrastructure and your findings are stored there. Outbound connections are limited to licence activation and the optional services you enable, such as an AI provider, CVE enrichment and patch catalogues. Pricing is 599 USD per month or 5,999 USD for a perpetual lifetime license. See pricing or how the platform works.

SITEY closes the loop, not just the report.Discover, validate, fix and verify in your own infrastructure.

See pricing