Upgrading Ubuntu to the next LTS release without breaking the server

To move from one Ubuntu LTS release to the next without reinstalling, you use do-release-upgrade, after updating everything the current release has pending and taking a verified copy of the server. It is a long process that restarts services and can change the versions of PHP, databases and web server beneath your site. On an unmanaged VPS, the decision, the risk and the work are yours. If you have little or nothing installed, reinstalling with the new release is often cleaner (reinstalling your VPS operating system).

Before you start

Prepare Why
A complete, tested copy If it goes wrong, it is the road back. A disk snapshot, if your plan offers them, plus an export of the databases and a copy of the configuration: backing up a VPS.
Free disk space The upgrade downloads and installs thousands of packages: what fills the disk.
A list of what runs PHP, database and web server versions, systemd services, cron jobs, ports. Afterwards you check each one.
A quiet hour The site may be down while services restart. Pick a low-traffic period.
A way in if SSH fails Know how to use the panel console, which gets in without the network: I have lost SSH access.

Step by step

1 Fully update the current release. sudo apt update, sudo apt full-upgrade and sudo apt autoremove. Reboot if the system asks. The details are in updating a Debian or Ubuntu VPS.
2 Check the release and the options. lsb_release -a. The file /etc/update-manager/release-upgrades has a Prompt= line; to move from LTS to LTS it should be lts. Ubuntu only offers the next LTS once it considers it ready for servers; if do-release-upgrade says there is no new release, that is why.
3 Open a session that survives a drop. Run it inside tmux or screen, so a broken connection does not stop the upgrade halfway. The tool itself starts a second SSH server, by default on port 1022, as a fallback; if you have a firewall, allow that port for the duration of the upgrade.
4 Start the upgrade. sudo do-release-upgrade. Read every question. You cannot skip releases: if you are two LTS behind, do one at a time.
5 Questions about configuration files. When it asks whether to keep your version or install the package’s, in general keep yours if you edited it by hand, and compare the differences afterwards.
6 Reboot and check everything. systemctl --failed should list nothing new; check the site, the database, cron, certificates and ports (ss -tulpn). See whether PHP and the database changed version and whether your application accepts them.
PHP, MariaDB or MySQL and Apache or nginx can change version with the upgrade. An application that ran well on the old one may fail on the new one. Check what your application supports first: which PHP version to use. Third-party repositories are disabled by the tool; you will have to re-enable them by hand, for the right release.
Do not interrupt the upgrade. Stopping halfway, with packages half installed, is the easiest way to leave the system unusable. If the connection drops, get back into tmux and see where it is.
A new server is an honest alternative. Installing the new release on a clean VPS, moving the site and switching DNS carries far less risk than touching what is serving customers: migrating a site without downtime. What the upgrade does not solve is keeping the system up to date: keeping your VPS secure.

Did the upgrade leave the server unreachable? Tell us the time and what you saw: the panel console gets in without the network.

Open a support ticket

SEE ALSO

Which operating system to choose for your VPS

Reinstalling or changing your VPS operating system

Backing up a VPS: snapshots or files

Keeping your VPS secure

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from 5.940,00 Kz/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?