Kokil Thapa - Professional Web Developer in Nepal
Freelancer Web Developer in Nepal with 15+ Years of Experience

Kokil Thapa is an experienced full-stack web developer focused on building fast, secure, and scalable web applications. He helps businesses and individuals create SEO-friendly, user-focused digital platforms designed for long-term growth.

Infrastructure Rollback Strategies

By Kokil Thapa | Last reviewed: September 2026

A bad deploy at 11 PM should not mean rebuilding servers from scratch. Infrastructure rollback strategies define how you undo application releases, server config, and cloud resources without guessing under pressure. On production Linux VPS and EC2 stacks I maintain with Deployer 7 and GitLab CI, rollback is a first-class step—not a panic button. This guide covers the patterns that actually work for Laravel 12/13 apps, Terraform-managed cloud, and small teams running business-critical sites in Nepal and abroad.

How do infrastructure rollback strategies differ from application rollbacks?

Application rollback usually means reverting code. Infrastructure rollback covers everything the app runs on: web server config, PHP-FPM pools, DNS, firewall rules, database schema, and cloud networking. A Laravel deploy can succeed while Nginx still points at the wrong socket.

Think in layers. Each layer needs its own undo path and its own time limit. Mixing them causes the classic failure: code rolls back but migrations do not, and the site white-screens.

Rollback LayersLayer 1: Application release (Git tag, symlink, container tag)Layer 2: Runtime config (Nginx, PHP-FPM, env, systemd)Layer 3: Infrastructure as Code (Terraform, Ansible state)Layer 4: Data (MySQL 9.7 dumps, Redis 8.10, file storage)Rollback fastest at top; data layer is slowest and highest risk
Infrastructure rollback strategies stack from fast code undo to slow data restore

Immutable infrastructure—new servers from golden images—changes the model. You do not patch a broken box; you replace it with the last known-good image. That trades speed for predictability. See immutable vs mutable infrastructure for when each fits.

Rollback speed vs blast radius

LayerTypical rollback timeBlast radius if skippedBest fit
Release symlink / image tag30–90 secondsBad code live on trafficLaravel, WordPress 7.1, WooCommerce 11.1
Config rollback2–10 minutes502 errors, wrong PHP versionApache/Nginx + PHP-FPM 8.3–8.5
Terraform revert5–30 minutesWrong SG, broken subnetAWS/Azure managed stacks
Database restore15 minutes–hoursData loss, legal exposureBooking, eCommerce, legal-tech portals

Your runbook should name the layer first. Teams that jump straight to database restore often overwrite good data while the real bug was a stale opcache after deploy.

What rollback patterns work best for Laravel deployments on Linux?

For Laravel 12 or 13 on Ubuntu 22/24, symlink-based releases remain the most reliable pattern I use in production. Deployer 7 keeps the last five releases under releases/ and swaps the current symlink. Rollback is one command—not a re-clone from Git.

Sister legal-tech sites on shared EC2—Notary Kathmandu, Court Marriage In Nepal, Translation Nepal—share this pipeline. The same GitLab CI job that deploys can trigger rollback when smoke tests fail.

Symlink Release RollbackRelease Ncurrent symlinkRelease N-1previous goodRelease N-2older backupshared/.env storageFAILdep rollbacksymlink points to N-1, reload PHP-FPMPost-rollback checkshealth route, queue worker, cron path, opcache clear
Deployer symlink swap is a core infrastructure rollback strategy for Laravel on VPS

Deployer rollback commands

# Roll back to previous release on production host
dep rollback production

# List available releases before choosing
dep releases production

# After symlink swap, reload PHP-FPM (opcache stale code is common)
sudo systemctl reload php8.4-fpm

Keep shared/.env and shared/storage outside releases. Rolling back code must not roll back uploaded documents on a client portal. That pattern appears on projects like Mijar Law Associates where file integrity matters.

Laravel-specific rollback checklist

  1. Confirm whether migrations ran in the failed release. Forward-only migrations need a compensating migration, not just dep rollback.
  2. Restart queue workers after symlink swap. Old workers still hold old autoload paths in memory.
  3. Verify cron entries point at current/artisan, not a stale release path. I have seen scheduled jobs silently stop after rollback.
  4. Clear config and route cache if you deploy with config:cache and route:cache.
  5. Run a smoke test against login, checkout, or booking—whatever path pays the bills.

Pair this with Ubuntu server backup strategies so rollback covers files and database, not only PHP code.

How do you roll back Terraform infrastructure safely?

Cloud rollback through Terraform is git revert plus plan, not a magic undo button. Terraform tracks desired state. Rolling back means re-applying an older commit that described working infrastructure.

State file integrity is the constraint. Without remote state in S3 or Terraform Cloud, two engineers applying different commits will corrupt rollback paths. Locking and versioning are non-negotiable for production.

Safe Terraform rollback workflow

# 1. Identify last good commit on main
git log --oneline infrastructure/

# 2. Revert the bad commit (prefer revert over reset on shared branches)
git revert abc1234

# 3. Plan before apply — read every destroy/create line
terraform plan -out=rollback.tfplan

# 4. Apply only after human review
terraform apply rollback.tfplan

Some resources cannot roll back cleanly. RDS instance class downsizing may force replacement. DNS TTL delays propagation. Security group changes can drop active connections. That is why zero-downtime Terraform updates and drift detection belong in the same pipeline as rollback planning.

Official guidance from HashiCorp on Terraform state stresses that state is the source of truth for what exists in the cloud. Treat state backups like database backups.

When Terraform rollback is the wrong move

  • Destructive changes already deleted data-bearing resources.
  • Manual console edits created drift Terraform will fight on apply.
  • Cross-stack dependencies mean reverting one module breaks another.

In those cases, forward-fix from a known-good plan or restore from snapshot. Infrastructure as Code does not remove judgment—it documents it.

When should you restore from backup instead of rolling back a release?

Release rollback fixes bad code. It does not fix corrupted data, ransomware, or a migration that dropped a column. Backup restore is the infrastructure rollback strategy of last resort—and the one you must rehearse.

On small MySQL 9.7 or MariaDB 12.3 VPS hosts, I keep nightly logical dumps plus binlogs where budget allows. Restore time beats backup frequency every time. A hourly dump you cannot restore in under an hour is theatre.

Rollback or Restore?Production incidentBad deploy only?YESRelease rollbacksymlink or image tagNOData damaged?migration, delete, breachBackup restorepoint-in-time if availableSweet spotSMB Laravel on VPS
Decision tree for infrastructure rollback strategies: release undo vs backup restore

Read design a backup strategy that works and database backup strategies for small servers before you need them. Validate dumps monthly with a restore to a staging schema—use the JSON formatter to inspect API health responses during restore tests if your app exposes structured status endpoints.

Point-in-time recovery basics

# Restore logical dump to staging (never test on production first)
mysql -u root -p staging_db < /backups/nightly_2026-09-11.sql

# Verify row counts and critical business rows
mysql -u root -p staging_db -e "SELECT COUNT(*) FROM orders WHERE created_at > CURDATE() - INTERVAL 1 DAY;"

For eCommerce stacks like Quick And Easy Nepalese Grocery, order and payment tables define whether rollback or restore is safer. Never restore a full dump over production without a written decision and a maintenance window.

How do you test rollback procedures before production fails?

Untested rollback is wishful thinking. Schedule a quarterly rollback drill on staging that mirrors production: same Deployer recipe, same PHP-FPM version, same queue driver. Document actual minutes, not estimates.

GitOps-style pipelines add promotion gates. A failed smoke test should block traffic shift automatically. Compare approaches in GitOps for infrastructure vs application GitOps.

Rollback Drill PipelineCI deployGitLab jobSmoke testHTTP 200 + loginPass?branch gateFAILAuto rollbackdep rollback hookLive trafficsymlink currentRunbook records: RTO, owner, comms templateIdempotent steps per /blog/idempotency-in-infrastructure-automation
Automated smoke tests turn infrastructure rollback strategies into pipeline defaults

Minimum runbook fields

  • Trigger: error rate, failed health check, payment webhook failures.
  • Owner: who executes rollback and who approves database restore.
  • Steps: exact commands, hostnames, no placeholders.
  • Verification: URLs, SQL checks, queue depth normal.
  • Comms: status page or client email template for Nepal business hours.
  • RTO target: e.g. 15 minutes for symlink, 4 hours for full DB restore.

Store runbooks in Git beside infrastructure code. Declarative vs imperative infrastructure debates matter less than whether the on-call engineer can follow steps at 2 AM.

For booking platforms such as Adventure Third Pole Trek, rollback drills should include Livewire session behaviour and supplier notification queues. A silent queue stall hurts revenue even when the homepage loads.

What common mistakes break infrastructure rollback strategies?

Teams often optimize deploy speed and treat rollback as an appendix. These failures recur on client projects and my own maintained servers.

Mutable server drift

SSH fixes applied directly on production are invisible to Deployer and Terraform. Rollback restores code but leaves manual Nginx edits. Prefer config in Git and documented maintenance windows.

Non-reversible migrations

Laravel migrations without down() methods—or destructive down() on large tables—block clean release rollback. Ship backward-compatible migrations first; drop columns in a later release after rollback is no longer needed.

Single copy of Terraform state

Local terraform.tfstate on a laptop cannot support team rollback. Use remote backend with versioning per HashiCorp S3 backend documentation.

Ignoring opcache and workers

PHP 8.4 opcache can serve old bytecode after symlink swap until FPM reload. Horizon and queue:work processes need restart too. This is the top “rollback did not work” report I see on Laravel hosts.

Container teams face parallel issues: rolling back an image tag while Kubernetes still runs old pods with imagePullPolicy: IfNotPresent. Tag immutability and explicit rollouts matter—see Docker image tagging strategies.

Key Takeaways

  • Map rollback per layer: release, config, IaC, and data each need a distinct undo path and time budget.
  • Use symlink releases with Deployer 7 for Laravel on VPS; run dep rollback then reload PHP-FPM and restart queues.
  • Revert Terraform via Git and reviewed terraform plan; never apply blind after infrastructure changes.
  • Restore from backup when data is corrupt—not when only application code is wrong.
  • Run quarterly rollback drills with timed runbooks; automate rollback on failed smoke tests in CI.
  • Keep migrations backward-compatible until you are sure the release will not be rolled back.

People Also Ask

What is the difference between rollback and failover?

Rollback returns a system to a previous known-good version on the same infrastructure. Failover shifts traffic to standby servers or another region. Rollback fixes bad changes; failover handles total site loss. Multi-region failover adds cost and complexity most SMB Laravel VPS setups do not need until uptime SLAs demand it.

How many old releases should you keep for rollback?

Deployer’s default of five releases is a sensible minimum for PHP apps. Keep enough disk for at least three full releases plus shared storage. For container registries, retain the last ten immutable tags and delete untagged layers on a schedule.

Can you roll back a database migration automatically?

Laravel supports php artisan migrate:rollback, but automatic migration rollback in production is risky on large tables. Prefer forward-fix migrations unless the schema change is trivial and tested. Always take a pre-deploy dump when migrations touch production data.

Does blue-green deployment eliminate rollback?

Blue-green reduces downtime by switching traffic between two environments. You still need a rollback strategy—switch traffic back to blue if green fails smoke tests. The idle environment is your rollback target, not a substitute for backups or tested runbooks.

Build rollback into your next deploy

Strong infrastructure rollback strategies cost little upfront and save hours when a payment gateway webhook or migration misfires. Start with symlink releases, remote Terraform state, verified backups, and a one-page runbook your team has actually executed once. If you want help wiring Deployer, GitLab CI, or backup drills into a production Laravel or legal-tech stack, contact us or explore enterprise application development and full-stack delivery from Kathmandu. Related reading: cloud backup and disaster recovery, infrastructure promotion pipelines, and testing infrastructure code.

Frequently Asked Questions

Planned ways to undo application releases, server config, and cloud resources without rebuilding from scratch—combining release undo, IaC state rollback, and backup restore when forward rollback is unsafe.

Application rollback usually means reverting code. Infrastructure rollback covers everything the app runs on: web server config, PHP-FPM pools, DNS, firewall rules, database schema, and cloud networking. A Laravel deploy can succeed while Nginx still points at the wrong socket. Each layer needs its own undo path and time limit. Mixing them causes classic failures—code rolls back but migrations do not, and the site white-screens. Map rollback per layer: release, config, IaC, and data.

For Laravel 12 or 13 on Ubuntu 22/24, symlink-based releases with Deployer 7 remain the most reliable pattern. Deployer keeps the last five releases under releases/ and swaps the current symlink—rollback is one command, not a re-clone from Git. Sister legal-tech sites on shared EC2 share this GitLab CI pipeline. Keep shared/.env and shared/storage outside releases so rolling back code does not roll back uploaded documents. After dep rollback production, reload PHP-FPM, restart queue workers, verify cron points at current/artisan, and clear config/route cache if deployed with caching.

Cloud rollback through Terraform is git revert plus plan, not a magic undo button. Identify the last good commit on main, revert the bad commit preferring revert over reset on shared branches, then run terraform plan and read every destroy/create line before terraform apply. Remote state in S3 or Terraform Cloud with locking and versioning is non-negotiable—without it, two engineers applying different commits corrupt rollback paths. Treat state backups like database backups. Some resources cannot roll back cleanly: RDS downsizing may force replacement, DNS TTL delays propagation, and security group changes can drop active connections.

Release rollback fixes bad code—it does not fix corrupted data, ransomware, or a migration that dropped a column. Backup restore is the strategy of last resort and the one you must rehearse. On small MySQL 9.7 or MariaDB 12.3 VPS hosts, keep nightly logical dumps plus binlogs where budget allows. Restore time beats backup frequency: an hourly dump you cannot restore in under an hour is theatre. For eCommerce stacks, order and payment tables define whether rollback or restore is safer. Never restore a full dump over production without a written decision and a maintenance window.

Untested rollback is wishful thinking. Schedule a quarterly rollback drill on staging that mirrors production: same Deployer recipe, same PHP-FPM version, same queue driver. Document actual minutes, not estimates. GitOps-style pipelines add promotion gates—a failed smoke test should block traffic shift automatically. For booking platforms, drills should include Livewire session behaviour and supplier notification queues, because a silent queue stall hurts revenue even when the homepage loads. Store runbooks in Git beside infrastructure code so the on-call engineer can follow steps at 2 AM.

Teams often optimize deploy speed and treat rollback as an appendix. Recurring failures include mutable server drift from SSH fixes invisible to Deployer and Terraform, non-reversible Laravel migrations without safe down() methods, a single local terraform.tfstate that cannot support team rollback, and ignoring opcache and workers—PHP 8.4 opcache can serve old bytecode after symlink swap until FPM reload. Container teams face parallel issues rolling back image tags while Kubernetes still runs old pods with imagePullPolicy IfNotPresent. Prefer config in Git, backward-compatible migrations, remote Terraform state, and explicit worker restarts after every rollback.

Rollback returns a system to a previous known-good version on the same infrastructure. Failover shifts traffic to standby servers or another region. Rollback fixes bad changes; failover handles total site loss.

Deployer's default of five releases is a sensible minimum for PHP apps. Keep enough disk for at least three full releases plus shared storage. For container registries, retain the last ten immutable tags.

Laravel supports php artisan migrate:rollback, but automatic migration rollback in production is risky on large tables. Prefer forward-fix migrations unless the schema change is trivial and tested. Ship backward-compatible migrations first and drop columns in a later release after rollback is no longer needed. Destructive down() methods on large tables block clean release rollback. Always take a pre-deploy dump when migrations touch production data, and confirm whether migrations ran in the failed release before choosing dep rollback alone.

Blue-green reduces downtime by switching traffic between two environments, but you still need a rollback strategy. Switch traffic back to blue if green fails smoke tests—the idle environment is your rollback target, not a substitute for backups or tested runbooks. Automated smoke tests can turn rollback into a pipeline default when health checks or payment webhook failures trigger it. Zero-downtime updates and drift detection belong in the same pipeline as rollback planning, because switching environments does not fix corrupted data or irreversible schema changes.

Release symlink or image tag rollback takes 30–90 seconds. Config rollback for Apache, Nginx, or PHP-FPM 8.3–8.5 takes 2–10 minutes. Terraform revert on AWS or Azure managed stacks takes 5–30 minutes. Database restore takes 15 minutes to hours depending on dump size and verification. Your runbook should name the layer first—teams that jump straight to database restore often overwrite good data while the real bug was stale opcache after deploy.

The symlink swap worked but supporting processes did not refresh. PHP 8.4 opcache can serve old bytecode until you sudo systemctl reload php8.4-fpm. Horizon and queue:work processes still hold old autoload paths in memory and need restart. Cron entries pointing at a stale release path silently stop scheduled jobs after rollback. If you deploy with config:cache and route:cache, clear those caches post-rollback. This is the top rollback-did-not-work report on Laravel hosts I maintain with Deployer 7.

Do not revert Terraform when destructive changes already deleted data-bearing resources, manual console edits created drift Terraform will fight on apply, or cross-stack dependencies mean reverting one module breaks another. In those cases, forward-fix from a known-good plan or restore from snapshot. Infrastructure as Code documents judgment—it does not remove it. RDS instance class downsizing may force replacement rather than in-place rollback, and security group changes can drop active connections during apply, so read terraform plan output line by line before approving any rollback apply.

At minimum: trigger conditions such as error rate spikes, failed health checks, or payment webhook failures; owner who executes rollback and who approves database restore; exact steps with commands and hostnames and no placeholders; verification URLs, SQL checks, and queue depth checks; comms template for status page or client email during Nepal business hours; and RTO targets—for example 15 minutes for symlink rollback and four hours for full database restore. Store runbooks in Git beside infrastructure code and execute them once in a quarterly drill so documented minutes reflect reality, not estimates.

Share this article

0 Comments

Leave a comment

Your email is not published. Comments appear once they have been read. Sign in to have your details filled in.

Quick Contact Options
Choose how you want to connect me: