Achtung: Diese Anleitung gilt NICHT für ein Upgrade der Datenbank!
Um ein Upgrade Ihrer Mongo DB durchzuführen befolgen Sie zwingend erst die Anleitung in unserer Dokumentation, bevor Sie das folgende Skript auch für die Datenbank anwenden!
Ab Debian 12 wird Predictable Network Interface Naming (PNIN) auch auf den Xen-Hypervisor angewendet, wodurch sich die Netzwerkschnittstellennamen ändern können. Wir empfehlen, die neuen Namen in der Netzwerkkonfiguration zu übernehmen, da das Deaktivieren von PNIN bei zukünftigen Updates zu Problemen führen kann.
Für das Update von Debian 11 auf 12 können Sie folgendes Skript nutzen:
#!/bin/bash
# Debian bullseye -> bookworm upgrade script
# (C) 2024
#
# # # Enginsight GmbH
# # # # Geschäftsführer: Mario Jandeck, Eric Range
# # # Hans-Knöll-Straße 6, 07745 Jena
#
function restore_backup() {
find /etc/apt/ -type f -name '*.list.backup' -exec bash -c 'mv $0 ${0%.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 \;
# 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?:\/\/.*debian\.org\/debian\/?\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
Eine ausführliche Anleitung zum Upgrade Ihrer Mongo DB finden Sie hier.