Updating a configured Debian server: APT and a managed reboot

Four actual upgrades, an explicit maintenance window and service/data checks after reboot, manually and through the CLI.

A green steam train on a turntable beside a depot and parcels.
A green steam train on a turntable beside a depot and parcels.

After Nginx, PHP-FPM and the data services are running, the server needs regular updates. We now need to preserve working settings, understand package changes and separately check that services return after reboot. We followed this process manually and then through our CLI, using two separate copies of the retained training Debian 13 VM. The production server was unchanged.

Choosing the update window

We chose an explicit operator maintenance window: review updates at least weekly and handle urgent fixes separately. We recorded two settings in /etc/apt/apt.conf.d/99-deploy-cli-maintenance. In the manual copy, this file was added after postboot checks; in the CLI run it preceded the index refresh. The file does not create a schedule: an operator must initiate the review. This is the policy chosen for the training fixture, rather than a universal requirement for every server.

APT::Periodic::Enable "0";
Unattended-Upgrade::Automatic-Reboot "false";

APT::Periodic::Enable disables periodic operations in the standard APT mechanism; the other setting prevents unattended-upgrades from automatically rebooting. Separate third-party jobs are outside these settings. We read the effective values using apt-config shell ENABLE APT::Periodic::Enable REBOOT Unattended-Upgrade::Automatic-Reboot:

ENABLE='0'
REBOOT='false'

From fresh indexes to an exact list

We first refreshed metadata with signature verification. apt-get update refreshes indexes rather than installed programs. Error-Mode=any prevents silently accepting a partially failed index refresh. Command behavior is described in the Debian apt-get manual.

apt-get -o APT::Update::Error-Mode=any update

The approved plan contained four upgrades. These versions are the actual outcome of this run; another server needs its own fresh plan. The kernel, PHP, MySQL, Redis and Elasticsearch were outside this upgrade list.

PackageBeforeAfter
bind9-host1:9.20.29-1~deb13u11:9.20.30-1~deb13u1
bind9-libs1:9.20.29-1~deb13u11:9.20.30-1~deb13u1
ca-certificates2025041920250419+deb13u1
tzdata2026c-0+deb13u12026e-0+deb13u1

Downloading and installing are separate steps

In the manual run, we first downloaded only the exact versions. The following is an abbreviated Bash equivalent of the arguments actually executed; the packages array is also used in the next example.

packages=(
  'bind9-host=1:9.20.30-1~deb13u1'
  'bind9-libs=1:9.20.30-1~deb13u1'
  'ca-certificates=20250419+deb13u1'
  'tzdata=2026e-0+deb13u1'
)
DEBIAN_FRONTEND=noninteractive apt-get --yes --no-remove \
  --no-install-recommends --download-only install "${packages[@]}"

Before installation, we separately checked the SHA256 and size of all four .deb files against the authenticated plan. Downloading left the package database unchanged. We then installed from local archives, prohibited removals and retained existing conffiles. The actual invocation also disabled interactive prompts in supporting tools.

DEBIAN_FRONTEND=noninteractive apt-get --yes --no-remove \
  --no-install-recommends --no-download \
  -o Dpkg::Options::=--force-confdef \
  -o Dpkg::Options::=--force-confold install "${packages[@]}"
dpkg --audit

dpkg --audit returned no messages; dpkg-query confirmed all four versions. Package scripts can restart services or regenerate GRUB, so install needs a separate state inspection afterward. Preserving conffiles does not imply that a package has no other side effects. In the manual copy, an ordinary systemctl --check-inhibitors=yes reboot was followed by HTTP, PHP and data checks.

The CLI continues package history

For the CLI run, we used another copy of the initial disk. Separate policy-plan/policy-apply operations first set the same APT policy, followed by refresh-plan/refresh for signed indexes. The installation plan contained the same four version transitions. The examples below use private absolute paths in place of real identifiers.

deploy-cli host maintenance plan \
  --profile <administrator> --request-file <private-request> \
  --history-head-file <verified-head> --plan-file <new-plan>

deploy-cli host maintenance apply \
  --profile <administrator> --request-file <private-request> \
  --plan-file <reviewed-plan> --plan-sha256 <reviewed-sha256> \
  --approve-privileges --output-file <new-head>

The CLI holds APT/dpkg locks, checks authenticated archives and their control fields, executes install once, then verifies through a fresh SSH connection. History retains the before and after states. The four approved records were replaced; the other 388 package records remained exact. The older reader, which allowed only newly added packages, did not silently start accepting upgrades: a separate version-transition reader handles them.

A recovery path before reboot

Before the managed reboot, the controller refused to proceed: the test image had only one kernel, while EFI BootOrder began with other active options. The refusal made no changes. A separate plan added fallback kernel 6.12.111 and efibootmgr; the running kernel and ordinary default remained 6.12.113. EFI order was corrected in a separate manual operation confined to this VM. These are two additional fixture prerequisite packages, rather than two more upgrades in the initial list.

We checked the independent serial console before acting. A separate boot-menu plan/apply enabled a visible GRUB menu with a ten-second ordinary timeout, retaining the fallback entry and existing recordfail behavior. Only then did we prepare and approve a reboot plan. These commands are separate from automatic package installation.

deploy-cli host reboot plan \
  --profile <administrator> --request-file <private-request> \
  --plan-file <new-reboot-plan>

deploy-cli host reboot request \
  --profile <administrator> --request-file <private-request> \
  --plan-file <reviewed-reboot-plan> --plan-sha256 <reviewed-sha256> \
  --approve-privileges

An accepted request is not a completed boot

The CLI first saved a checkpoint, then scheduled one ordinary request through systemd. It respects inhibitors. Explicit --check-inhibitors=yes also matters for noninteractive invocation, as described in the systemctl documentation. The following combines selected fields from three actual responses, rather than showing a single raw JSON response:

{
  "request": {"action":"dispatch-accepted","write_performed":true},
  "observe": {"action":"boot-verified","write_performed":false},
  "verify": {"action":"boot-verified","write_performed":false}
}

dispatch-accepted means the request was accepted. A new boot ID, the expected kernel and the absence of failed units are checked separately. We also confirmed the changed boot ID through the serial console. We retained the old checkpoint and did not submit another request. If a response is lost, the next action is observation rather than another reboot attempt.

Reading the state after reboot

After boot, we waited until all nine configured services and timers were ready. Both PHP pools returned their own UID/GID, session paths and expected settings. All 20 HTTP checks passed; MySQL, Redis and Elasticsearch control values survived, and requests outside permitted namespaces were denied. We checked Elasticsearch TLS/CA and read cluster health using the separate setup_ops account, obtaining green.

The package-history reader initially rejected the disappearance of reboot-required as drift. We corrected the separate postboot read: a yes → no transition is now allowed only alongside a new boot ID. Dpkg, APT configuration, indexes and keys must remain exact. Original records and approved plans were not rewritten, and packages were not installed again.

deploy-cli host maintenance reconcile \
  --profile <administrator> --request-file <private-request> \
  --plan-file <latest-install-plan> --plan-sha256 <reviewed-sha256>

The repeated read completed without writes. History contains 12 records: the original nine, a refresh, four upgrades and the separate reboot prerequisites. All 92 files captured before reboot matched afterward. This run completes maintenance of the prepared stack; delivering application code and running its migrations require the next separate step.

  1. Operations & Security Updating Debian: verification starts before installation
  2. Operations & Security Recovering VPS access when SSH stops working
  3. Operations & Security Startup and reboot: firewall, ready FPM, then Nginx
  4. Architecture From manual commands to a CLI: planning, approving and verifying server changes
  5. Vendors & Packages Inspecting .deb files before installation: reader limits and ICU data

A project by the author · Weather Solution200

After reading, a look outside.

Temperature, rain and wind in your city. Check the forecast and plan the hours ahead.

Check the forecast
Next article