So today I did something both brilliant and borderline reckless: I asked ChatGPT to whip up a Bash script that upgrades a Debian 12 system to the fresh new Debian 13.
Yes, I know, trusting an AI with my beloved Linux distro is basically the sysadmin equivalent of β€œhold my beer.” 🍺


The Setup

I played it safe (well, safe-ish). First, I spun up a VM, made a backup (because… duh), and then unleashed the script. To my mild surprise and great relief, it actually worked. The thing ran in interactive mode, threw a couple of β€œAre you sure, human?” type questions my way (I think two or three), then rebooted the machine.

And after the smoke cleared: Debian 13 booted up like a champ. πŸŽ‰


Sharing is Caring (and Potentially Dangerous)

Because I’m a generous nerd, I want to share this magical little script with you all. But let me just put this here in BOLD FLASHING DISCLAIMERS:

  • If this script nukes your server, eats your homework, or accidentally summons Skynet β€” not my fault.
  • Use it on a VM first. Backup like your digital life depends on it (because it does).
  • If it works: awesome. If it doesn’t: I told you so. πŸ˜‰

The Script: upgrade-to-trixie.sh

Here’s the full Bash script I used, saved as upgrade-to-trixie.sh:


#!/bin/bash
# upgrade-to-trixie.sh
# Upgrade Debian 12 (Bookworm) -> Debian 13 (Trixie)
# USE AT YOUR OWN RISK ⚑

set -euo pipefail

LOGFILE="/var/log/debian-upgrade.log"

echo "=== Debian Upgrade Script: Bookworm -> Trixie ==="
echo "Logging to $LOGFILE"
echo

# Root check
if [[ $EUID -ne 0 ]]; then
   echo "This script must be run as root! Try: sudo $0"
   exit 1
fi

# Log helper
log() {
    echo "[*] $1" | tee -a "$LOGFILE"
}

log "Starting upgrade process at $(date)"

# Backup APT sources
log "Backing up /etc/apt/sources.list..."
cp /etc/apt/sources.list /etc/apt/sources.list.bak.$(date +%F-%H%M%S)

# Update release name
log "Switching sources from 'bookworm' to 'trixie'..."
sed -i 's/bookworm/trixie/g' /etc/apt/sources.list

# Update package lists
log "Updating package lists..."
apt update | tee -a "$LOGFILE"

# Minimal upgrade
log "Running safe upgrade..."
apt upgrade -y | tee -a "$LOGFILE"

# Full upgrade
log "Running full distribution upgrade (this may take a while)..."
apt full-upgrade -y | tee -a "$LOGFILE"

# Remove obsolete packages
log "Cleaning up old packages..."
apt autoremove -y | tee -a "$LOGFILE"
apt clean

log "Upgrade finished at $(date)"
echo
echo "=== Upgrade complete! Please reboot your system. ==="

Final Thoughts

I honestly expected more fire and chaos. Instead, the process was smoother than a fresh apt install neofetch.
So if you’re feeling adventurous (and have a good backup), give it a shot. Worst case, you get a great excuse to reinstall Debian and brag about it on Mastodon.

Stay nerdy ✌️

By raphael

Leave a Reply