Each LTS version of Ubuntu receives standard updates for five years, but waiting until the last month makes the upgrade more complicated. Upgrading the same server with do-release-upgrade saves you from having to perform a complete migration if you prepare it properly, because it’s an operation that cannot be undone.
Update on-site or migrate?
Update the same server if it runs few services and almost everything comes from the official repositories. If it depends on many PPAs, older versions of PHP, or hand-compiled software, it’s usually safer to set up a new VPS with the new version and migrate the data.
The day before: preparation
Check the current version and available space; the download is several hundred MB:
lsb_release -adf -h /Make a full backup or a snapshot and verify that you can restore it. It's the only way you'll be able to go back.
Make a note of the third-party repositories, because the wizard disables them during the process:
ls /etc/apt/sources.list.d/Update to the latest version and restart if prompted:
sudo apt update && sudo apt full-upgrade -y[ -f /var/run/reboot-required ] && sudo reboot
During the update
Open a
tmuxsession. If the SSH connection is lost, the process continues, and you can return to it withtmux attach -t upgrade:tmux new -s upgradeIf you're using UFW or another firewall, temporarily open port 1022, where the wizard launches a second rescue SSH session:
sudo ufw allow 1022/tcpVerify that the configured channel is
lts, and run the update:grep Prompt /etc/update-manager/release-upgradessudo do-release-upgrade
If it tells you that there is no new version, that's to be expected for a while: between LTS releases, the upgrade is only offered when the first point release (.1) of the new version comes out. Don't use -d in production, because that option installs development versions.
The wizard will ask you about any configuration files you've modified, such as sshd_config or php.ini. If you don't know what you changed, keep your version (option N) and compare it later with the .dpkg-dist or .ucf-dist file next to it.
After the restart
cat /etc/os-releasesystemctl --failedsudo ufw delete allow 1022/tcp- Check
/etc/apt/sources.list.d/: Third-party repositories are still disabled. Enable them only when your provider releases packages for the new version. - Check the versions of PHP, Python, and the database: a change in LTS versions usually brings new major versions, and you may need to adjust your sites' configurations.
- Test the website, services, and cron jobs before closing the maintenance window.
ext step
Would you rather not make changes to the production server? Deploy a new Cloud VPS, migrate at your own pace, and shut down the old one once everything is working.