Deployment and rollback
Quick answer
A safe deployment validates a candidate release, switches traffic only when appropriate, checks health and keeps a tested rollback path.
Rolling back application files may not reverse a database schema change. Plan compatibility between versions, retain the previous artifact and verify service behavior after recovery. Treat destructive data changes as a separate recovery problem.
Prepare the practice environment
Run python3 lab-fixtures/servers/setup.py from the extracted root as an ordinary user. Enter the printed fresh private path and check pwd. Use fresh fixtures, Bash with set -e -o pipefail, LC_ALL=C and umask 077. Only local loopback services and private files are used. Optional examples require an authorized snapshot VM. Never expose a lab listener publicly or modify system services. Review the lab guide.
How it works
Keep versioned artifacts, configuration and release records. A health check should reflect readiness for its intended traffic; a simple 200 does not guarantee business correctness. A symlink can select a release directory on one filesystem; replacing it atomically reduces partial updates, but a running application may need restart or reload. Preserve prior configuration, validate the candidate, activate, monitor and rollback if defined thresholds fail. Database migrations may be incompatible with old application versions, so coordinate backward-compatible changes or a tested recovery plan. The helper models two release directories using a private symlink, tests an actual loopback HTTP readiness endpoint, rejects a failed candidate and restores the original pointer. This is not a production deployment manager.
Try the examples
These markers represent synthetic readiness states. They are not real service metrics.
Expected stdout:
readynot-readyThe private symlink switches to v2, the HTTP check returns 503, and the original v1 target is restored and checked again.
Expected stdout:
v1 readyv2 rejectedv1 restoredVM-only: inspect an instructor-provided service; no restart or configuration change is authorized by this example. Check application-specific health separately.
Manual example; not executed locally. Follow its stated environment restrictions.
Common mistakes
Do not overwrite the only working release or assume reverting code reverses database changes. Never skip recovery testing because the deployment command succeeded.
Practice
Write a deployment checklist for a static site and a database-backed application. Identify a health criterion, rollback trigger, previous artifact and migration risk for each.
Related references
Study: systemctl, curl. These are reference names, not deployed links.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Deployment and rollback — Knowledge Check
Apply hosting and deployment concepts to synthetic fixtures and VM-only scenarios.
What should precede switching a candidate into service?
What does a 503 from the readiness endpoint mean in the lab?
Can application rollback reverse every database migration?
What should be checked after rollback?