← back to /blog← powrót do /blog

→ czytaj po polsku

Ubuntu 20.04 on Ubuntu Pro -> 24.04 in place: ISPConfig, mail and Nextcloud in one night

My main server (hekate) is a typical all-in-one box: ISPConfig 3, mail for several domains (Postfix, Dovecot, rspamd), Roundcube, Nextcloud, a few Docker containers (including Pterodactyl with a Minecraft server for the kids), Jenkins, InfluxDB with Grafana, and Falco. All of it on Ubuntu 20.04.

20.04 left standard support in May 2025. Since then the server lived on Ubuntu Pro (esm-infra, esm-apps, livepatch). It works and the patches keep coming, but it only postpones the problem: PHP from a third-party PPA, packages getting older every month, and every new Nextcloud or ISPConfig release starting to want a newer OS.

I could have built a new server and migrated. I chose an in-place upgrade for a simple reason: the same IP address means the same mail reputation, the same DNS records, PTR, SPF and DKIM. On a mail server that is worth more than a clean install.

The safety net: a bootable clone on spare disks

An in-place upgrade is only scary when there is no way back. The server had two disks with a nearly empty RAID1 used for backups. I rebuilt them like this:

  • an EFI system partition (ESP) on each disk,
  • a 400 GB RAID1 for a clone of the whole /,
  • the rest as the existing backup RAID.

The clone is a plain rsync plus a few fixes after every run:

rsync -aHAXx --numeric-ids --delete \
  --exclude=/tmp/ --exclude=/var/tmp/ --exclude=/mnt/ --exclude=/media/ \
  / /mnt/clone/

After each sync a script inside the clone:

  • points fstab at the clone’s UUID and its own ESP,
  • writes its arrays into mdadm.conf,
  • sets debconf grub-efi/install_devices to the clone’s ESP only, so the clone never overwrites the main system’s bootloader,
  • disables Postfix and Dovecot (a clone booted for a test must not accept mail),
  • runs update-initramfs, grub-install --no-nvram and update-grub.

The key detail: the clone’s NVRAM entry is not in the boot order. It is started once:

efibootmgr -n 0000 && reboot

BootNext applies to a single boot. The next normal reboot goes back to the main system. If the upgrade goes badly wrong, one command (or the provider’s KVM console) brings back the pre-upgrade server.

I tested the clone before the upgrade with a real reboot: the system came up from the clone, Nextcloud answered, and mail was down exactly as planned. Going back to the main system worked too.

A reboot before the upgrade surfaces the traps

That test reboot turned out to be the most valuable step of the whole project. The server had not been restarted in a very long time, so the configuration held things that only worked because nothing had reloaded them:

  • Dovecot did not start. Its config had SNI blocks pointing at Let’s Encrypt certificates that had been missing from disk for months. Dovecot had been running for 675 days on a configuration loaded long ago.
  • Postfix had been serving expired certificates since April for two mail hostnames. Nothing was renewing them.
  • Three Docker containers had restart=no and simply stayed down.

If all of that had shown up in the middle of the upgrade, I would have blamed the new release. Lesson: before a big change, do a plain reboot and fix whatever it shakes out.

Preparing the window

Before starting:

  • Nextcloud in maintenance mode, ISPConfig cron jobs commented out,
  • all services stopped, mysqldump --all-databases,
  • tarballs of /etc, /usr/local/ispconfig, /var/vmail, /var/lib/rspamd,
  • a state snapshot to compare against later: postconf -n, doveconf -n, apache2ctl -S, enabled units, listening ports, docker ps, crontabs,
  • a final clone sync with services stopped, which gives a consistent rollback point.

Two hops: 20.04 -> 22.04 -> 24.04

Both hops ran the same way, inside tmux with a log:

do-release-upgrade -f DistUpgradeViewNonInteractive 2>&1 | tee /root/upg/hop.log

Non-interactive mode keeps local versions of config files, which is what you want on a hand-tuned ISPConfig box.

What surprised me:

  1. The first attempt died at apt update. The upgrader disables third-party repositories, but only those with the release name (focal) in the line. Repos without one (stable, Jenkins’ binary/, InfluxData, Falco) stay enabled, and their expired GPG keys abort the whole upgrade. Fix: move every third-party .list file aside before you start.
  2. tmux upgrades itself mid-run. The new client cannot talk to the old tmux server (“server version is too old”), so tmux attach stops working while the upgrade keeps going. I followed progress through the log and pgrep.
  3. During the hop to 24.04, SSH vanished for about 12 minutes. OpenSSH moves to socket activation (ssh.socket). The custom port survived and the connection came back on its own. Good to know in advance so you do not panic.

PHP, Roundcube and ISPConfig

On 20.04, PHP came from a PPA (ondrej/sury). Those packages carry higher version numbers than PHP 8.3 in noble, so apt will not replace them. A pin on the Ubuntu archive with priority above 1000 plus one dist-upgrade --allow-downgrades did it:

Package: <list of packages with a ~sury version>
Pin: release o=Ubuntu
Pin-Priority: 1001

After that every PHP module comes from noble. The old PHP 7.4 and 8.4 were removed and Apache moved to mod_php8.3.

Roundcube added its own twist: its postinst ran the update script on PHP 7.4 without mbstring, and after that was fixed, dbconfig tried to apply an already-applied schema migration a second time. What helped: switching the php alternative to 8.3 before packages get configured, setting dbc_upgrade='false' in /etc/dbconfig-common/roundcube.conf, then dpkg --configure -a.

ISPConfig went from 3.3.0p3 to 3.3.3p2 through update.php --autoinstall with reconfigure_services=yes. That rewrites service configs from its templates and drops hand-made changes:

  • the Postfix RBL went back to the default,
  • inet_protocols = ipv4 disappeared,
  • the order of sender restrictions changed,
  • rspamd got a config file with permissions it could not read after the upgrade (rspamd 3.8 runs as _rspamd).

This is where the pre-upgrade snapshot paid off: a diff of postconf -n before and after showed exactly what to restore.

Smaller things along the way: a corrupted ClamAV database (freshclam fixed it) and mdmonitor, which on noble reads /etc/mdadm.conf first. That file was a leftover from the provider’s installer, without MAILADDR.

The day after

The night ended with an empty systemctl --failed, working mail (TLS on every port for every hostname, a test message in the inbox) and Nextcloud returning 200. The next day turned up a few more things:

  • The Nextcloud updater refused to run because of an unknown directory, stats/, inside the installation. That is the statistics directory ISPConfig creates in every site. I move it aside for the update and put it back after.
  • Falco had been restarting in a loop since the first reboot, almost 3000 times. The new release parses YAML more strictly and rejected the local exceptions file. The trap: a unit stuck in a restart loop does not show up in systemctl --failed. systemctl show -p NRestarts does.
  • A certificate for one subdomain expired, because ProxyPass / was swallowing /.well-known/acme-challenge/. A fix made by hand in the vhost file long ago disappeared when ISPConfig regenerated it. It now lives in the panel’s “Apache Directives” field, where ISPConfig will not overwrite it.
  • Jenkins was listening on every interface. Now it only listens on localhost.

The result

  • Window: from 22:50 to about 01:55. Mail was not accepted for roughly an hour and a half. Sending servers retry anyway, so nothing was lost.
  • Ubuntu 24.04.5, kernel 6.8, PHP 8.3 from the official archive, ISPConfig 3.3.3p2, MariaDB 10.11, Nextcloud 32.0.15.
  • No more Ubuntu Pro on this machine and no more PHP from a third-party PPA.
  • The 20.04 clone stays on the disks for a while, just in case.

What I would repeat on the next server:

  1. A bootable clone with a one-shot BootNext instead of only a backup. Restoring a backup takes hours, the clone takes one reboot.
  2. A reboot before the upgrade. It surfaces traps that would otherwise go off at the worst possible moment.
  3. All third-party repositories moved aside before do-release-upgrade.
  4. A config snapshot and a diff after every tool that “reconfigures services”.
  5. Checking restart counts, not just systemctl --failed.

← back to /blog← powrót do /blog

→ czytaj po polsku