Upgrading Ubuntu to a new release on a VPS without losing the server

The short answer: updating packages (apt upgrade) and upgrading to a new release (for example, from one LTS version to the next) are different things. The second touches the whole system, PHP and the database included, and can go wrong. Do it with a backup made, in a session that does not drop and with time to test afterwards.

Before you start

Check Why
Backup or snapshot It is your only way back: Backing up a VPS.
Up-to-date system Do the normal updates first and reboot.
Disk space The upgrade downloads a lot. You need plenty of free space.
LTS to the next LTS Do not skip releases. The tool offers the next one.
What runs on the server Note the PHP, database and web server versions, and what is scheduled (cron).

Step by step

1 Make the backup and confirm you can restore it.
2 Update the current system: sudo apt update && sudo apt upgrade, and reboot. See: Updating your VPS.
3 Open a session that survives a dropped connection: tmux and screen.
4 Run the upgrade tool: sudo do-release-upgrade. Read each question. If you changed a configuration file, keep your version unless you know what the new one changes.
5 Reboot and check: the system, the web server, PHP, the database, the services (systemctl --failed), the firewall and scheduled tasks. Only then close the old session.
6 Test each site and each application. PHP and the database may have changed version.
If the VPS has a control panel installed (cPanel or another), do not upgrade the system this way: the panel only works on certain systems and has its own process. Read its documentation first. And do not upgrade a production server without rehearsing on a copy.
The cleaner alternative is to create a new VPS with the new system and move the sites there. More work and much less risk: Reinstalling or changing your VPS operating system.

The upgrade stopped halfway or you lost access? See I have lost SSH access to my server and open a ticket.

Open a support ticket

SEE ALSO

Backing up a VPS: snapshots or files

Keeping a command running after you close SSH: tmux and screen

How to update a Debian or Ubuntu VPS, and turn on automatic security updates

Which operating system to choose for your VPS or server

Reinstalling or changing your VPS operating system

A service will not start on my VPS: reading systemctl status

RECOMMENDED PRODUCT

VPS server with root access

Resources of your own, the OS you choose, reinstall whenever you like. from $7.61/mo (3-year plan, with coupon)

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