Debian upgrades have a reputation for being boring. apt full-upgrade, wait, reboot, done. That reputation was earned on servers running nothing but packages from the official archive — and almost no production server looks like that anymore. Add Docker’s repository, the PostgreSQL PGDG archive, NodeSource, a Grafana APT repo, and one vendor agent installed from a .deb, and a Trixie upgrade becomes an exercise in dependency resolution across five independent vendors who did not coordinate their release schedules with Debian’s.

The good news: Trixie is a genuinely well-behaved release. The 64-bit time_t transition is complete, the /usr merge requirement has been enforced for years, and the package set is unusually coherent. The bad news is that the failure modes have moved — they are now almost entirely about third-party repositories and configuration files that changed format, not about the base system itself.

This runbook covers what actually breaks, in the order it breaks, with commands you can run as-is.

TL;DR: Upgrade In Place Unless One of These Applies

In-place apt full-upgrade is the right choice for 90% of servers. Rebuild from scratch when the host carries more than two major-version leaps of accumulated configuration, when it runs a database you cannot afford to have offline for an hour, or when it is a hypervisor you can evacuate.

  • In place: standard application servers, CI runners, monitoring nodes, web frontends.
  • Rebuild: database primaries, hypervisors, anything with hand-edited packages or a decade of /etc archaeology.
  • Never: upgrade a machine you have not backed up, and never skip the third-party repo audit.

Debian 12 vs 13: What Actually Changed

ComponentDebian 12 (Bookworm)Debian 13 (Trixie)Upgrade impact
Kernel6.1 LTS6.12 LTSReboot required; check out-of-tree modules
Python3.113.13python3.11-* packages replaced; venvs must be rebuilt
PHP8.28.4Extensions renamed or dropped; PECL rebuild
PostgreSQL1517Cluster is not auto-upgraded; pg_upgradecluster needed
systemd252257Unit syntax mostly stable; new sandboxing defaults
OpenSSH9.210.0DSA keys rejected; old ciphers removed
GNOME4348Desktop only; irrelevant on servers
APT2.63.0New solver, deb822 sources as default format
OpenSSL3.03.5Legacy provider still available but not default

Two rows deserve emphasis. The PostgreSQL cluster on a Trixie host does not magically become version 17 — the postgresql-15 package remains installable, and upgrading the cluster is a separate, deliberate operation with pg_upgradecluster. And Python 3.13 means every virtualenv on the box is now pointing at a removed interpreter; rebuild them from lockfiles rather than trying to repair them.

Choosing Your Path

SituationPathReasoning
Single app server, config in AnsibleIn-place apt full-upgradeFastest, and config drift is already controlled
Database primary with <1h downtime budgetLogical replica on Trixie, then switchAvoids in-place cluster upgrade risk entirely
Hypervisor with live guestsEvacuate, rebuild, restoreCheapest path to a known-good state
Long-lived pet server with manual editsIn-place, but with etckeeper firstYou need a diff of every config change
Fleet of 50+ identical nodesRebuild from image, rolling replaceDeterministic; no snowflake divergence
Container hostIn-place, then recreate containersContainers isolate most runtime risk

For a fleet, rebuilding is almost always cheaper than debugging 50 unique machines. For one server, in-place is almost always cheaper than rebuilding.

Pre-Flight Checks

Run these before touching sources.list. Each one catches a class of failure that is painful to diagnose mid-upgrade.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
# 1. Snapshot the package state so you can diff afterwards
dpkg --get-selections > /root/pkg-selections-bookworm.txt
apt-mark showmanual > /root/manual-packages-bookworm.txt

# 2. Record every third-party repository
grep -rhE '^\s*deb ' /etc/apt/sources.list /etc/apt/sources.list.d/ > /root/repos-bookworm.txt
ls /etc/apt/sources.list.d/ > /root/repo-files-bookworm.txt

# 3. Verify the filesystem layout is merged (Trixie requires it)
ls -ld /bin /sbin /lib
# /bin and /sbin must be symlinks to /usr/bin and /usr/sbin

# 4. Check for held packages that will silently block the upgrade
apt-mark showhold

# 5. Confirm free space — Trixie needs roughly 2x the download size
df -h /var /usr /

# 6. Install the tools that make the upgrade observable
apt install -y apt-listchanges needrestart etckeeper
etckeeper init && etckeeper commit "pre-trixie baseline"

That etckeeper commit is the single highest-value step in this entire guide. After the upgrade, git -C /etc log -p shows you exactly which configuration files the maintainers rewrote, which turns “why is nginx behaving differently” from an afternoon into a two-minute git diff.

The Upgrade Sequence

Do not combine the source change and the full upgrade into one command. Debian’s release notes are explicit about the two-phase approach, and skipping phase one is how you end up with 400 packages removed.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
# Phase 0: fully update Bookworm first
apt update
apt upgrade -y
apt full-upgrade -y
reboot   # if the kernel changed, boot into the latest Bookworm kernel before proceeding

# Phase 1: switch sources, upgrade without removing packages
sed -i 's/bookworm/trixie/g' /etc/apt/sources.list
# For deb822 files (.sources), edit the Suites: line instead
grep -rl "bookworm" /etc/apt/sources.list.d/ | xargs sed -i 's/bookworm/trixie/g'

apt update
apt upgrade --without-new-pkgs

# Phase 2: the actual release upgrade
apt full-upgrade

# Phase 3: cleanup and reboot
apt autoremove --purge
reboot

--without-new-pkgs exists to make the failure surface small. If phase one fails, you are still on a Bookworm userland with Trixie package lists, and the fix is a normal dependency problem. If you jump straight to full-upgrade, a single unsatisfiable dependency can cascade into removing your bootloader.

After the reboot, verify before you celebrate:

1
2
3
4
5
6
cat /etc/debian_version          # should report 13.x
uname -r                         # should be 6.12.x
systemctl --failed               # must be empty or explained
journalctl -p 3 -b               # errors from this boot only
apt list --upgradable            # should be empty
needrestart -r l                 # confirms every service runs the new libs

needrestart is the step people skip. A service still running against pre-upgrade shared libraries will behave unpredictably for days, and systemctl --failed will not tell you about it.

Third-Party Repositories: The Real Failure Mode

Every external repository must publish a Trixie suite before you run phase two. If it does not, you have three options, in order of preference: pin the old suite, disable the repo for the duration of the upgrade, or remove the package and reinstall after.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
# Example: check which suites a vendor repo actually publishes
curl -s https://apt.postgresql.org/pub/repos/apt/dists/ | grep -o 'trixie-pgdg' | head -1

# Pin a repo to its old suite when the vendor has not shipped Trixie yet
cat > /etc/apt/preferences.d/pin-vendor <<'EOF'
Package: *
Pin: origin packages.example-vendor.com
Pin-Priority: 1001
EOF

# Safer for the upgrade window: disable entirely
mv /etc/apt/sources.list.d/vendor.list /root/vendor.list.disabled
apt update

The repositories that most often lag: Docker (usually fine, publishes trixie quickly), NodeSource (frequently one suite behind), Microsoft’s packages.microsoft.com (mixed), and small vendor agents distributed as .list files with a hardcoded codename. Audit every file in /etc/apt/sources.list.d/ against the list you captured in pre-flight.

One more trap: a repo that accepts trixie in its URL but serves Bookworm-built binaries. The upgrade succeeds, the package installs, and you spend the next week debugging a segfault. Check apt-cache policy <package> after the upgrade — if the installed version’s origin is a repository that has not published a Trixie suite, treat it as suspect.

Rollback and Recovery

There is no supported downgrade path. apt will let you pin versions and reinstall Bookworm packages, but a half-downgraded system is worse than a broken Trixie system. Plan for one of these instead:

  • Snapshot or image the disk before starting. LVM thin snapshots, ZFS snapshots, or a hypervisor-level snapshot. This is the only true rollback.
  • Keep the old kernel installed. If the new kernel fails to boot, GRUB still lists the Bookworm kernel, and you can boot it to diagnose.
  • Keep a rescue shell open. A second SSH session, or a console session via the hypervisor, not a tmux pane on the machine you are upgrading.
  • Do not reboot until phase two completes. A reboot mid-full-upgrade is how machines become unbootable.

If the upgrade fails at phase one, the fix is dependency resolution: read the apt output, identify the package with the unsatisfiable constraint, and either remove it or pin its Bookworm version. If it fails at phase two, restore the snapshot. The intermediate states are not worth rescuing.

For distribution-level context on how Debian’s upgrade compares with Leap, Elevate, and do-release-upgrade, our in-place Linux upgrade comparison covers the tradeoffs. If the machine you are upgrading is a Proxmox node, use the PVE 9 runbook instead — the ordering and the repository set are different. And if you mirror Debian packages internally, the Debian repository mirroring guide explains how to stage Trixie alongside Bookworm during the transition.

FAQ

Is Debian 13 stable enough for production in 2026?

Yes. Trixie was released in August 2025 and has had over a year of point releases and security updates. The base system is stable; the risk is concentrated in third-party repositories and in packages that changed major version, such as PHP and PostgreSQL.

Does the upgrade automatically migrate my PostgreSQL cluster to version 17?

No. The postgresql-15 package remains available in Trixie, and your existing cluster keeps running until you explicitly create a 17 cluster and run pg_upgradecluster 15 main. Plan that as a separate maintenance window with a verified pg_dump fallback.

What happens to my Python virtualenvs after upgrading?

They break. Debian 12 ships Python 3.11 and Trixie ships 3.13, so the interpreter path inside every virtualenv no longer exists. Rebuild each environment from its lockfile with uv sync or pip install -r requirements.txt rather than trying to patch the pyvenv.cfg path.

Can I downgrade if the upgrade goes badly?

Not cleanly. There is no supported downgrade path, and partially downgraded systems are less reliable than the broken upgrade. Use a disk snapshot, VM snapshot, or full image backup before starting; that snapshot is your rollback.

Do I need to remove third-party repositories before upgrading?

You need to either confirm they publish a Trixie suite or disable them for the duration. Leaving a Bookworm-only repository enabled during apt full-upgrade is the most common cause of dependency conflicts and accidental package removals.

How long does a Debian 12 to 13 upgrade take?

For a typical application server, 30 to 60 minutes including download, install, and reboot. Machines with large package sets, databases, or slow mirrors can take two hours. The reboot and post-upgrade verification usually take longer than the upgrade itself.


💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com