Debian 13 Tutorial / Prepare a Debian 12 to 13 Upgrade: Preflight Checks, Backups and Recovery
Before upgrading from Debian 12 to Debian 13, you should stabilize the current system and prepare a restorable backup along with a console that can be accessed even if SSH is disconnected. Do not finish preparing by just saving the package list or creating a VM snapshot; also verify service data restoration and access after reboot.
Define the Upgrade Scope and Stop Conditions
This article covers the preparation steps for an amd64 Debian 12 minimal server. It does not change the repository to trixie or install Debian 13 packages. Older versions like Debian 11 require a separate procedure to first upgrade to Debian 12. Do not upgrade an i386 server in place with this procedure: Debian 13 no longer provides an official i386 kernel or installer. Assess a fresh amd64 installation on compatible hardware or retirement instead.
A separate VM in VirtualBox 7.2 was used for practice. Debian 12.15 was installed with 3 GiB memory, a 30 GiB virtual disk, UEFI, ext4 root, and a separate EFI partition. After updating bookworm, the kernel was 6.1.0-55-amd64. This is the observation environment and does not represent a general guideline for required capacity. According to the Debian 12.15 release, this point release is the last regular update for Debian 12, and future support requires checking the Long Term Support (LTS) architecture and package scope.
| Conditions to proceed | States to stop and resolve first |
|---|---|
| Console login, sudo, and new SSH connections are all working | Relying on only one existing SSH session or having no recovery media |
| Package audit normal, identified reasons for held/external packages | Unconfigured packages, unknown cause holds, mixed repositories |
| Actual restoration of backup and service read verification completed | Only verified file existence or checksums |
| Agreed on service downtime, data write halt, and restoration point | After upgrade, new data will be overwritten by old snapshots |
Record current version, packages, and repository status
Store the result files in a directory that only root can read. The command below is an example of running it for the first time; if the same directory already exists, it will stop without overwriting. In actual operations, distinguish names by task date or revision number.
sudo bash <<'ROOT'
set -euo pipefail
dest=/var/backups/debian13-preflight
test ! -e "$dest"
install -d -m 700 "$dest"
cat /etc/os-release > "$dest/os-release.txt"
uname -a > "$dest/kernel.txt"
dpkg --print-architecture > "$dest/architecture.txt"
dpkg-query -W -f='${binary:Package}\t${Version}\t${db:Status-Abbrev}\n' > "$dest/packages.tsv"
dpkg --get-selections '*' > "$dest/selections.txt"
apt-mark showmanual > "$dest/manual.txt"
apt-mark showhold > "$dest/holds.txt"
apt-cache policy > "$dest/apt-policy.txt"
dpkg --audit > "$dest/dpkg-audit.txt"
test ! -s "$dest/dpkg-audit.txt"
apt-get check
ROOT
dpkg --audit usually outputs nothing if there are no problems. If there are results, read the content, resolve the cause, and then check again. Do not start a distribution upgrade if apt-get check ends with dependency errors. Do not release holds unconditionally; check the reason for the hold and whether the package is supported on Debian 13.
sudo grep -R -nE '^(deb |deb-src |Types:|URIs:|Suites:|Components:|Signed-By:)' /etc/apt/sources.list /etc/apt/sources.list.d
apt list '?narrow(?installed, ?not(?origin(Debian)))'
dpkg --print-foreign-architectures
Grep errors may appear because of a non-existent sources.list. Check all existing .list and .sources, and also verify whether there are backports, third-party repositories, or pin settings in addition to bookworm, bookworm-updates, and bookworm-security. Do not publish results if the URI contains authentication information. External source lookup is based on current APT metadata, so lack of output does not prove the source of all installation files.
Update Debian 12 and Verify Access After Reboot
After confirming that the current repository points to bookworm, update the package list and review the expected changes. Also, check if kernel meta packages are installed. Do not attach the auto-approval option without reviewing the deletion list or configuration questions from the simulation.
sudo apt update
apt -s full-upgrade
apt-cache policy linux-image-amd64 openssh-server
sudo apt full-upgrade
sudo /usr/sbin/sshd -t
sudo reboot
Proceed to reboot only after apt completes successfully and sshd -t succeeds. If either fails, retain the session and use the console to resolve the error before rebooting.
After the reboot is complete, instead of reusing the existing window, create a new SSH connection and check whether you can also log in from the console. In the exercise, the package audit after the update was normal, and the full upgrade simulation of bookworm involved 0 packages to be changed. For remote upgrades, review the OpenSSH conditions in the trixie release notes and known issues; update bookworm before attempting the release transition.
Record Disk, Network and Service Baselines
findmnt --target / -o TARGET,SOURCE,FSTYPE,OPTIONS
findmnt --target /boot -o TARGET,SOURCE,FSTYPE,OPTIONS
findmnt --target /boot/efi -o TARGET,SOURCE,FSTYPE,OPTIONS
findmnt --target /tmp -o TARGET,SOURCE,FSTYPE,OPTIONS
df -hT / /boot /var
df -i / /boot /var
ip -brief address
ip route
readlink -f /etc/resolv.conf
cat /etc/resolv.conf
sudo ss -lntup
systemctl --failed --no-pager
Distinguish whether /boot is a separate file system or part of root, and check both capacity and inodes. On a BIOS system without EFI, you can skip checking /boot/efi. If the disk is small, consider space not only for the download cache but also for the new kernel, initramfs, and temporary space during installation, and do not delete the currently booted kernel or the only working kernel to free up space.
Do not just record the addresses; also include the interface name, default route, the component managing Domain Name System (DNS) resolver files, and the listening addresses and ports of services. For web services, include HTTP status and response content; for databases, include how to pause writes and the commands for logical backup and restoration as part of the baseline. The mere fact that systemctl is-active is active does not mean that the data is normal.
In Debian 13, the default /tmp storage method and the sysctl configuration read path will change. Beforehand, check whether permanent data has not been placed in /tmp and whether the necessary settings are in /etc/sysctl.d/*.conf. Record the current findmnt --target /tmp result and the local sysctl snippets before upgrading, then compare them after reboot. The pre-upgrade record does not prove that an old temporary marker survived or was later hidden; any such test requires a separately recorded marker and controlled observation.
Separate System-State Backups from Restore Tests
Backing up settings/package state and backing up service data serve different purposes. The following command stores the system state in the previously created secure directory. This tar is not a complete disk image, nor is it a consistent backup of a running database. Service-specific dumps or write-stop procedures must be applied separately.
sudo bash <<'ROOT'
set -euo pipefail
dest=/var/backups/debian13-preflight
test -d "$dest"
test ! -e "$dest/system-state.tar"
tar --acls --xattrs --numeric-owner -cpf "$dest/system-state.tar" -C / etc var/lib/dpkg var/lib/apt/extended_states
cd "$dest"
sha256sum system-state.tar > system-state.sha256
sha256sum -c system-state.sha256
ROOT
/etc may contain private keys or authentication information. Restrict read permissions, and apply encryption and access control when storing on separate devices or servers. If the backup path is only on the same root disk, corruption could cause loss of both the original and the backup. Conversely, overwriting only the package state directory with an older version is not a method to downgrade the operating system.
To practice the restoration procedure directly, use the following independent small files instead of operational data. Move the originals to another location, restore them from the archive, and compare content, owners, and permissions. The example uses numeric user ID (UID) 1000 and group ID (GID) 1000. Check both with id and adjust every owner/group value if your lab account differs.
sudo bash <<'ROOT'
set -euo pipefail
dest=/var/backups/debian13-preflight
test -d "$dest"
test ! -e /var/lib/preflight-demo
test ! -e "$dest/demo.tar"
install -d -m 750 -o 1000 -g 1000 /var/lib/preflight-demo
printf 'upgrade backup sample\n' > /var/lib/preflight-demo/message.txt
chown 1000:1000 /var/lib/preflight-demo/message.txt
chmod 640 /var/lib/preflight-demo/message.txt
stat -c '%u:%g:%a' /var/lib/preflight-demo/message.txt > "$dest/demo-mode.txt"
sha256sum /var/lib/preflight-demo/message.txt > "$dest/demo-data.sha256"
tar --acls --xattrs --numeric-owner -cpf "$dest/demo.tar" -C / var/lib/preflight-demo
mv /var/lib/preflight-demo/message.txt "$dest/demo-held.txt"
tar --acls --xattrs --numeric-owner --same-owner -xpf "$dest/demo.tar" -C / var/lib/preflight-demo/message.txt
cmp "$dest/demo-held.txt" /var/lib/preflight-demo/message.txt
test "$(stat -c '%u:%g:%a' /var/lib/preflight-demo/message.txt)" = "$(cat "$dest/demo-mode.txt")"
sha256sum -c "$dest/demo-data.sha256"
ROOT
The expected result is that the comparison command finishes without errors and OK appears in the SHA-256 check.
For actual verification, we transferred the data of the practice HTTP service in this manner, restored it from the backup, and compared the file hashes, UID, GID, permissions, and HTTP responses. Only the three practice files without secrets were separately copied outside the VM to check their hashes and content, while the full system configuration archive was kept inside the VM. Therefore, this practice does not verify a full system backup that can withstand total host loss.
To clean up only the small-file exercise, after confirming that the restoration was successful, run sudo rm -- /var/lib/preflight-demo/message.txt and sudo rmdir -- /var/lib/preflight-demo. Keep the backup until the upgrade results are confirmed and do not confuse it with actual service files.
Confirm Console Access, Cold Boot and Rollback Boundaries
In VirtualBox Manager, select the target VM, open the console, and test login and sudo. You should also be able to check the installation ISO or rescue entry method, root/EFI partition identification information, and backup location outside of SSH. Snapshots of a normally shut-down VM are a quick way to return to the current state, but they depend on the same host and storage.
- Stop writes before starting the upgrade and back up the service data one last time.
- After normally shutting down the guest, save the pre-change state from the VM's snapshot menu. Do not assume that the snapshot itself guarantees the consistency of a running database.
- Turn on the VM and check automatic booting, new SSH connections, service responses, and data hashes.
- If it fails, record who will open the console, which backup will be restored, and how newly created data will be preserved.
In the exercise, we discovered a problem during the last boot check where the bootloader existed in the EFI directory but was not registered in the boot order. We selected EFI/debian/shimx64.efi on the console to boot, verified the actual UEFI entry, corrected the order, and then confirmed automatic booting, new SSH connections, and service responses again after a cold restart. Since boot entry numbers vary by device, do not copy and apply the efibootmgr number from another system.
After resuming writing post-upgrade, if you revert to an old snapshot, the data created in the meantime may be lost. Establish criteria for whether to continue repairs or restore the entire state for package installation failures, boot failures, and service data errors. Read both Debian official upgrade guide and your own service documentation, and start repository switching only when there are no unresolved items.




