Upgrading/Migrating Debian 12 to 13

Debian 13 (Trixie) upgrades APT with .sources files, replacing older .list entries. .sources offer structured configs, per-repo signing keys, and better tooling. With modernize-sources, upgrades from Debian 12 are safer, cleaner, and future-proof.

Upgrading/Migrating Debian 12 to 13
Photo by Lukas / Unsplash

One of the major upgrades with the new OS is moving apt sources from .lists to .source which comes with a few benefits using the deb822-style format

  • .list: Just plain text lines like:deb http://deb.debian.org/debian bookworm main contrib non-free
  • .sources: Key/value YAML-like syntax:
Types: deb
URIs: http://deb.debian.org/debian
Suites: bookworm
Components: main contrib non-free

Supports Multiple Suites / URIs / Components

  • .list: One line = one suite + one URI. If you want multiple, you repeat lines.
  • .sources: Can define multiple suites, URIs, and components in one entry, making management cleaner.

Per-Repository Signing Keys

  • .list: Signing is global — you either trust a GPG key for all repos or add messy signed-by overrides in the line.
  • .sources: Has a dedicated Signed-By: field, letting you pin a repo to its own trusted key.
    • Improves security by preventing accidental trust of unrelated repos.
    • Example:Signed-By: /etc/apt/trusted.gpg.d/postgresql.gpg

1. Preparation

  1. Backup your system (databases, configs, important files).
  2. Ensure you’re fully updated on Debian 12:sudo apt update && sudo apt dist-upgrade -y
  3. Install tools you may need during the upgrade: sudo apt install screen -y
    (use screen or tmux so you don’t lose your session if SSH drops)

2. Update APT Sources

Replace old sources

sudo sed -i 's/bookworm/trixie/g' /etc/apt/sources.list
sudo sed -i 's/bookworm/trixie/g' /etc/apt/sources.list.d/*.list

Use modernize-sources

Debian now recommends using modernize-sources to handle source upgrades cleanly:

sudo modernize-sources

This will replace bookworm entries with trixie in /etc/apt/sources.list and /etc/apt/sources.list.d/.


3. Handle External Repositories

Some third-party repos don’t automatically follow Debian’s codename upgrades.

PostgreSQL

If you use the PostgreSQL Global Development Group (PGDG) repo, you may need to adjust its .sources file to include the signing key reference:

sudo sed -i 's|Signed-By:|& /etc/apt/trusted.gpg.d/postgresql.gpg|' /etc/apt/sources.list.d/pgdg.sources

After this, verify the repo lines in /etc/apt/sources.list.d/pgdg.sources point to trixie-pgdg.

Node.js

If you’re using NodeSource or similar, you’ll need to re-add the updated repo. For example, for Node 20:

curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

Re-adding ensures you get a repo entry that matches trixie.


4. Upgrade Process

  1. Update package lists:sudo apt update
  2. Start minimal upgrade (safest first step):sudo apt upgrade --without-new-pkgs
  3. Perform the full distribution upgrade:sudo apt full-upgrade -y
    (or apt dist-upgrade -y if you prefer the old syntax)

5. Reboot & Verify

  1. Reboot into the new kernel:sudo reboot
  2. Check your version:lsb_release -a
    You should now see Debian GNU/Linux 13 (trixie).

6. Post-Upgrade Checks

  • Re-enable or fix any third-party services (PostgreSQL, Node.js, Docker, etc.).
  • Run:sudo apt autoremove --purge -y
  • Review /var/log/apt/history.log for packages that were held back or removed.