How to upgrade if `/var/discourse` has only `shared` and is not git repo

A new VM means a new virtual server, assuming your instance isn’t on dedicated hardware.

If you have Discourse running but /var/discourse is empty it’s either a very very old installation or an unsupported package.

Either way, you should create a backup, spin up a new virtual server, follow the standard installation guidelines and then restore from backup.