> For the complete documentation index, see [llms.txt](https://docs.enginsight.com/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.enginsight.com/docs/knowledge-base/english/updates/how-do-i-update-my-enginsight-servers-from-debian-11-to-debian-12.md).

# How do I update my Enginsight servers from Debian 11 to Debian 12?

To update your Enginsight Application Server, Database Server, and Component Server(s) from Debian 11 to Debian 12, you can use the update script provided below.

***

## Important Notes

* To **update the Enginsight Database Server**, you need to follow the instructions in the following Knowledge Base article before applying the script to the database: [How do I update the Enginsight database from MongoDB 5.0 to MongoDB 8.0?](/docs/knowledge-base/english/database/how-do-i-update-the-enginsight-database-from-mongodb-5.0-to-mongodb-8.0.md)
* To **update the Enginsight Application Server and Component Server(s)**, we strongly recommend that you create a snapshot of the corresponding virtual machines before running the script.
* Please note that if you use a **Xen hypervisor**, Predictable Network Interface Naming (PNIN) is also applied there as of Debian 12. This may cause the names of the network interfaces to change. We recommend that you use the new names in the network configuration, as disabling PNIN may cause issues with future updates.

***

## Script for Updating from Debian 11 to Debian 12

```
#!/bin/bash

# Debian bullseye -> bookworm upgrade script V2
# (C) 2025
    #     Enginsight GmbH
#   # #   Lars Meyer
# # # #   Geschäftsführer: Mario Jandeck, Eric Range
# #   #   Leutragraben 1, 07743 Jena
  #

function restore_backup() {
    find /etc/apt/ -type f -name '*.list.backup' -exec bash -c 'mv $0 ${0%.backup}' {} \;
    apt-key add /etc/apt/mongodb-server-5.0.asc.backup
    echo "Upgrade failed. Restored backup files"
}

logFileName=/var/log/$(date +%Y%m%d%H%M%S)_upgrade.log
echo "Log will be written to $logFileName"
{
    set -e -u

    export DEBIAN_FRONTEND=noninteractive

    echo "Checking whether apt-get update currently runs successfully"
    apt-get -y update

    echo "Checking whether any packages are held or broken"
    audit=$(dpkg --audit)
    if [[ $audit ]]
    then
        echo "Cannot upgrade: you have held or broken packages. Please fix this situation manually and attempt the upgrade again"
        echo $audit
        exit 1
    fi

    echo "Backing up sources.list files"
    find /etc/apt/ -type f -name '*.list' -exec cp {} {}.backup \;

    echo "Backing up MongoDB 5 signing key"
    apt-key export "F5679A222C647C87527C2F8CB00A0BD1E2C63C11" > /etc/apt/mongodb-server-5.0.asc.backup

    # Install GnuPG if necessary
    if ! dpkg -l | grep -q gnupg
    then
        apt-get install -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef -y gnupg
    fi

    echo "Replacing bullseye with bookworm in all sources.list files"
    find /etc/apt/ -type f -name '*.list' -exec sed -E -i 's/(deb.*?https?:\/\/[a-z0-9.-]+\/debian[^[:space:]]*\/?\s+)bullseye(.*)/\1bookworm\2/g' {} \;

    if [[ -f /etc/apt/sources.list.d/microsoft-prod.list ]] && [[ -f /etc/apt/trusted.gpg.d/microsoft.asc.gpg ]]
    then
        rm /etc/apt/sources.list.d/microsoft-prod.list
        curl -L "https://packages.microsoft.com/config/debian/12/prod.list" -o /etc/apt/sources.list.d/microsoft-prod.list
        cp /etc/apt/trusted.gpg.d/microsoft.asc.gpg /usr/share/keyrings/microsoft-prod.gpg
    fi

    if dpkg -l | grep -q docker-ce
    then
        find /etc/apt/ -type f -name '*.list' -exec sed -E -i 's/(deb.*?https?:\/\/.*docker\.com[^\s]+\s+)bullseye(.*)/\1bookworm\2/g' {} \;
    fi

    # Check if MongoDB key is present and update repo information accordingly
    if apt-key finger | grep -qE 'F567\s*9A22\s*2C64\s*7C87\s*527C\s*2F8C\s*B00A\s*0BD1\s*E2C6\s*3C11'
    then
        # Delete old key
        apt-key del "F5679A222C647C87527C2F8CB00A0BD1E2C63C11"
        # Add new key
        curl -fsSL https://www.mongodb.org/static/pgp/server-8.0.asc | apt-key add -
        # Upgrade repo
        find /etc/apt/ -type f -name '*.list' -exec sed -i 's/bullseye\/mongodb-org\/5.0/bookworm\/mongodb-org\/8.0/g' {} \;
    fi

    echo "Disabling backports repositories"
    find /etc/apt/ -type f -name '*.list' -exec sed -E -i 's/(.*backports.*)/#\1/g' {} \;

    # https://www.debian.org/releases/bullseye/amd64/release-notes/ch-upgrading.en.html#clean-up-leftover-configuration-files
    echo "Cleaning up leftover configuration files"
    find /etc -name '*.dpkg-*' -o -name '*.ucf-*' -o -name '*.merge-error' -exec rm {} \;

    echo "Running apt update"
    apt-get -y update --allow-releaseinfo-change

    echo "Performing minimal upgrade"
    apt-get --without-new-pkgs -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef -y upgrade

    echo "Performing remaining upgrade steps"
    apt-get -o Dpkg::Options::=--force-confold -o Dpkg::Options::=--force-confdef -y full-upgrade

    echo "Removing unnecessary packages"
    apt-get -y autoremove --purge

    removed=$(dpkg -l | awk '/^rc/ { print $2 }')
    if [[ $removed ]]
    then
        echo "Purging removed packages"
        apt purge -y $removed
    fi

    echo "Upgrade completed. Please reboot the system"
} |& tee $logFileName

ret=${PIPESTATUS[0]}
if [ $ret -ne 0 ]; then restore_backup; fi
exit $ret
```

***
