A failed deployment is easier to recover from when rollback is planned before release day. This runbook gives you a repeatable application backup checklist, a practical backup matrix, rollback decision points, and a review cadence for files, databases, environment variables, DNS, and persistent storage on cloud hosting or a VPS.
Overview
Rolling back application code is usually the simple part. The difficult part is restoring the rest of the system to a compatible state without overwriting newer customer data or losing configuration. A previous application version may expect an older database schema, a particular environment variable, a specific container image, or a persistent volume with a known structure.
Before every deployment, identify what will change, what must be preserved, and what can be reversed. Your rollback plan should answer five questions:
- Which application version was running successfully before the release?
- Where are the deployable files, container images, and infrastructure definitions stored?
- When was the last verified database and persistent-storage backup created?
- Which environment variables, secrets, DNS records, and scheduled jobs does the release depend on?
- Who has authority to pause traffic, restore data, or declare the rollback complete?
A rollback is not the same as a restore. A rollback changes the application to an earlier release. A restore replaces data or infrastructure with an earlier copy. Use the least destructive action that resolves the incident. If the new code is faulty but has not changed the data model, an application rollback may be enough. If a migration damaged or transformed data, you may need a carefully planned database recovery instead.
For broader disaster-recovery planning, compare this runbook with the cloud server backup and restore plan, which covers snapshots, offsite copies, and recovery testing.
What to track
Keep a release record for every deployment. It can live in version control, an issue tracker, or a simple operations log, provided the record is accessible during an incident. Record the commit or image digest, deployment time, operator, migration status, backup identifiers, and the result of post-deployment checks.
Application and infrastructure assets
- Source and build output: preserve the exact commit, build artifact, dependency lockfile, and container image tag or immutable digest. Avoid relying only on a moving tag such as
latest. - Deployment configuration: save the relevant compose file, manifest, service definition, reverse-proxy configuration, infrastructure code, and startup commands. Note the operating-system or server-image version when it affects the application.
- Environment variables and secrets: maintain a secure, versioned inventory of variable names, not plaintext secret values in a public repository. Confirm that the previous release can access the credentials it needs.
- Persistent storage: list attached volumes, upload directories, object-storage buckets, queues, and generated files. A virtual-machine snapshot may not cover external services or independently managed storage.
Data and control-plane changes
- Database: capture the database engine, schema version, backup timestamp, retention period, and restore procedure. For a relational database, a logical export such as
pg_dumpormysqldumpcan complement provider snapshots; adapt the command to your engine and access controls. - Migrations: label each migration as backward-compatible, reversible, or requiring a data recovery plan. Test whether the old application can read the post-migration schema before deploying code that depends on it.
- DNS and certificates: record the current DNS records, nameservers, proxy settings, certificate source, and renewal method. Do not change DNS as a first response when an application-only rollback will restore service.
- External integrations: note webhook endpoints, payment or email settings, API versions, queues, cron jobs, and callback URLs. These dependencies can remain pointed at a new release even after the web application has been reverted.
Backup matrix
| Asset | Before deployment | Recovery check | Rollback caution |
|---|---|---|---|
| Application artifact | Record immutable commit, image digest, or archive | Start it in a staging or isolated environment | Keep dependencies compatible with the runtime |
| Database | Create or verify a recent backup and record its ID | Restore a copy and run a smoke test | Do not overwrite newer valid data without an explicit decision |
| Environment configuration | Snapshot variable names and encrypted secret references | Check required values and permissions | Never place secret values in deployment logs |
| Persistent files | Copy or snapshot uploads and application data | Open representative files from the copy | Check consistency when writes continue during backup |
| DNS and certificates | Export records and document current providers | Confirm the expected endpoint and certificate chain | DNS changes may be cached and are not instant rollback controls |
Cadence and checkpoints
Use the following checkpoints as a minimum operating rhythm. High-risk releases, such as database migrations or changes to storage, need additional review.
Before each deployment
- Confirm the release identifier and save the last known-good identifier.
- Review migrations for compatibility, reversibility, and expected runtime.
- Verify the database backup completed successfully and is available from the recovery environment.
- Confirm that persistent-storage copies are current enough for the release risk.
- Record environment, DNS, certificate, queue, and scheduled-job dependencies.
- Write the rollback command sequence before starting the deployment.
Immediately after deployment
Run a short smoke-test set: load the public site, authenticate a test account, exercise the most important read and write path, inspect logs, check background workers, and verify error rates or application health checks. Keep the release record open until these checks pass.
Monthly or quarterly
Perform a restore drill in an isolated environment. Measure how long it takes to obtain the backup, restore the database, attach persistent storage, configure the application, and validate the result. Review backup retention, offsite access, encryption, permissions, and available disk space. Update commands and screenshots when your cloud provider, server image, deployment platform, or database version changes.
If your cloud server is regularly approaching resource limits, review the VPS capacity and right-sizing guide. A rollback can fail simply because the recovery target lacks storage, memory, or CPU capacity.
How to interpret changes
Use symptoms and change scope to choose the least destructive response. This decision table is a starting point, not a substitute for examining logs and data integrity.
| Observed problem | Likely first action | Escalate when |
|---|---|---|
| New code returns errors but data is intact | Pause the release and restore the last known-good application artifact | The old artifact cannot start with the current configuration or schema |
| Migration fails before completion | Follow the migration tool's documented recovery path and preserve logs | Schema state is uncertain or writes continued during the failure |
| Records or files are missing or corrupted | Stop destructive jobs and identify the latest trustworthy data point | A database or storage restore is required |
| Only one hostname or endpoint fails | Check application routing, certificate coverage, and DNS records | Nameservers or DNS records were changed and propagation is involved |
| Workers repeatedly process old or duplicate jobs | Pause workers and inspect queue visibility, idempotency, and release compatibility | External side effects cannot be safely repeated or reversed |
Be especially cautious with irreversible migrations, destructive scripts, and changes that write to an external service. A code rollback cannot undo an email sent, a payment initiated, or a record deleted in another system. For DNS symptoms, use a measured review of nameservers, TTLs, caches, and authoritative answers rather than repeatedly changing records; the DNS propagation troubleshooting guide provides a useful companion workflow.
Define recovery objectives in practical terms: the maximum acceptable amount of lost data and the target time to restore service. These limits determine whether a daily backup, frequent logical export, replica, snapshot, or another design is appropriate. Do not promise a recovery time your team has not tested.
When to revisit
Revisit this runbook before every deployment and after any infrastructure change. Schedule a formal review at least monthly or quarterly, depending on release frequency and business risk. Trigger an immediate update when you change cloud hosting providers, VPS images, databases, container runtimes, deployment tools, DNS providers, certificate automation, storage locations, or secret-management systems.
Use a simple review checklist:
- Can a new operator find the last known-good release and the required backup?
- Do the rollback commands still match the current deployment architecture?
- Has a restore been completed recently, rather than merely marked successful by a backup job?
- Are database and storage backups protected from the same failure that affects production?
- Do retention periods match the data's operational and legal requirements?
- Are DNS, email, certificates, queues, and external integrations included in the recovery test?
Before your next release, create one release folder or ticket containing the artifact identifier, backup IDs, migration notes, configuration references, smoke-test results, and rollback owner. Then run a small restore test before you need a full one. A rollback plan is useful only when its files are accessible, its commands are current, and its recovery steps have been proven against the stack you operate today.