Migration from owncloud to nextcloud

Hello,

I have ownCloud 9.1.6 (stable) server on one physical server. The server is Ubuntu 16.
I want to migrate ownCloud to Nextcloud 12.0.4, the Nextcloud is installed on second physical server.
My question is how to migrate data files, shared files and database from owncloud to nextcloud?

The migration to Nextcloud is a bit like a major update in ownCloud. The steps are quite similar, so I would first move your setup to the new server (still on OC 9.1) and then run the official migration on the new server: https://nextcloud.com/migration/

This way you keep all data and meta information (app data, sharing info, contacts, โ€ฆ).