🚧 Under construction — VoTechWorks is being built. A free tech program — complimentary, as our commitment to get America working.
voTechWorksGrade 13 · a vocational technology learning center, by urbanicity
newSchoolWorks.com › VoTechWorks › Technology & Design › Web & Software Development › Deployment: Servers, CI/CD, and Cloud Publishing › Lesson 11
TEC-WEB46-07 · Lesson 11 · 14 clock hours · practice

Rollback Strategies and Deployment Safety

Objective. Students execute a deployment rollback using Git to revert a bad release on their VPS and document the procedure in a professional deployment runbook.

⚠ Pending professional review

This lesson, its worked examples and its practice questions has not yet been verified by an industry-certified professional or by a certification or approval body. It is a study draft and may contain errors. Do not use it as instructions for work on a job site or on live equipment. Always follow your instructor, your supervising professional, and current official references and regulations.

VoTechWorks program approval and accreditation are still in progress. Credentials are issued only by the certifying bodies named in each program, after their own exams.

Why Rollback Matters

Every deployment carries risk. A rollback is the controlled act of returning a production system to a previously known-good state after a bad release is detected. The goal is to restore service quickly and safely, before users or business operations suffer lasting harm. Experienced developers treat rollback not as a sign of failure but as a planned, rehearsed procedure — just like a fire drill.

In a professional environment, the time between detecting a bad release and completing a rollback is measured and tracked. A common target is to restore service within ten minutes of detection. Meeting that target requires preparation: you must know your commands, your trigger criteria, and your steps before an incident happens.

Detecting a Bad Release

Before you can roll back, you must recognize something is wrong. The primary tools are your application logs and a smoke test.

Reading logs on a Linux VPS — If your application runs under systemd, check its status and recent log lines:

```

sudo systemctl status your-app.service

sudo journalctl -u your-app.service -n 50

```

For web servers such as Nginx or Apache, check the error log in `/var/log/nginx/error.log` or `/var/log/apache2/error.log`. Look for stack traces, HTTP 500 responses, import errors, or crash loops. These are common signals of a broken release.

Smoke test — A smoke test is a minimal check that the application is responding correctly after a deploy. At the simplest level this is a `curl` command that checks for a 200 HTTP status:

```

curl -I http://your-server-ip

```

A smoke test should run automatically immediately after every deployment.

Rollback with Git

If your application is deployed directly from a Git repository on the VPS, you have two main options.

Option 1 — `git checkout` to a previous commit (detached HEAD)

Use this when you need to quickly return the working files to a specific earlier state without adding a new commit to history:

```

git log --oneline -5 # identify the last good commit hash

git checkout <good-commit-hash>

sudo systemctl restart your-app.service

```

Be aware that detached HEAD is a temporary state. After stabilizing the system, you should create a branch or revert properly.

Option 2 — `git revert` (preferred for shared repositories)

`git revert` creates a new commit that undoes the changes introduced by the bad commit. This preserves full history and is safer when other team members are working in the same repository:

```

git revert <bad-commit-hash> # opens an editor for the commit message

git push origin main

sudo systemctl restart your-app.service

```

After either approach, run your smoke test again to confirm the application is serving correct content.

Rollback Trigger Criteria

A runbook must state clearly when a rollback should be initiated — not left to guesswork under pressure. Common trigger criteria include:

Define your triggers before you deploy, not after.

Writing a Deployment Runbook

A runbook is a written, step-by-step procedure document for a specific operational task. It serves as the single source of truth during an incident, when stress makes improvisation dangerous. A professional deployment runbook contains these sections:

1. Pre-deployment checklist — backups verified, tests passing, team notified, maintenance window opened.

2. Deploy steps — exact commands in order, with expected output noted.

3. Smoke test steps — commands and expected results that confirm success.

4. Rollback trigger criteria — specific, measurable conditions that require a rollback.

5. Rollback procedure — exact commands to return to the previous release and restart services.

Write commands that are specific to your stack. A runbook with vague steps like "restart the server" is far less useful than one that says `sudo systemctl restart myapp.service`.

Safety Considerations

Deployment safety on a shared VPS overlaps with general system administration safety:

Connecting to Your Credentials

The CompTIA Linux+ exam tests your ability to manage services with systemd, read log files, and perform administrative tasks on Linux servers — all skills exercised in this lesson. Git version control and deployment procedures also appear in professional development workflows assessed in broader IT certification contexts. Building runbook habits now prepares you for the operational expectations of any development or DevOps role.

Key terms9

rollbackThe controlled process of returning a production system to a previously known-good state after a failed or harmful deployment.
git revertA Git command that creates a new commit undoing the changes introduced by a specified commit, preserving full repository history.
git checkoutA Git command used to switch branches or restore working-tree files; can point the working directory at a specific earlier commit (detached HEAD state).
smoke testA minimal, fast check run immediately after deployment to confirm the application is responding and serving content correctly before deeper testing begins.
runbookA written, step-by-step procedure document for a specific operational task such as deploying or rolling back an application, used to ensure consistent and safe execution under pressure.
rollback trigger criteriaPre-defined, specific conditions (such as error rate thresholds or a failed smoke test) that require a team to immediately initiate a rollback rather than continuing to investigate.
systemdThe init system and service manager used by most modern Linux distributions to start, stop, restart, and monitor services and daemons.
journalctlA command-line tool for querying and viewing logs collected by the systemd journal, commonly used to diagnose application failures on Linux servers.
post-mortemA structured written report completed after an incident that documents the timeline, root cause, impact, rollback actions taken, and steps to prevent recurrence.
In class: Instructor deploys a deliberately broken version of an application to the student's VPS by pushing a bad commit; students must identify the failure via logs and roll back to the previous release using git checkout or git revert followed by a server restart. · As a class, build a reusable deployment runbook template covering: pre-deployment checklist, deploy steps, smoke test steps, rollback trigger criteria, and rollback procedure. · Each student completes their own runbook for their VPS application, including specific commands for their stack, and peer-reviews a classmate's runbook against a provided rubric.
Materials: Student VPS, Git, runbook template, peer review rubric, student notebooks
Check: Instructor confirms the student successfully rolled back the broken release and the application serves correct content within 10 minutes; runbook peer review score must be 80% or above.

Practice check8

Answer each question, then check it. Nothing is recorded; this is your own practice.

Deployment and operations safety
1. After deploying a new release, your smoke test returns an HTTP 500 status. According to professional deployment safety practice, what is your immediate next action?
Version control and source management
2. Which Git command creates a new commit that undoes a specified bad commit while keeping the full repository history intact?
Linux system administration and logging
3. You need to view the last 50 log lines from a systemd-managed application called `webapp.service` on your Linux VPS. Which command should you run?
Deployment planning and documentation
4. A deployment runbook's rollback trigger criteria section is best described as:
Linux system administration and security
5. What is the primary risk of running all deployment commands as the root user on a Linux VPS?
Deployment operations and professional practice
6. After completing a rollback, what professional practice should always follow?
Version control and source management
7. You run `git checkout <old-commit-hash>` on your VPS to restore a previous version. Which statement accurately describes the resulting Git state?
Deployment planning and documentation
8. Which section of a professional deployment runbook contains the exact commands used to bring the application back online after a rollback is complete?
Record this lesson on my transcript. Sign in with your key and enrollment email to record lessons (enroll free if you have no key). This page stays open to read and practise.