There is some doco about migration at this link:
I will have to leave it to others to vouch for how up-to-date and fool-proof it is, as I’ve never done it, but seems fairly simple.
I have taken Ubuntu up through various upgrades though and besides the php dependencies and various other things to install, it has worked well for myself and others. If you have snapshots and ways to recover etc, then it’s worth a try - for example: Upgrading Ubuntu 20 to Ubuntu 22 and PHP 8.1 - #5 by murrant