Migration nextcloud on new server

Good afternoon, please tell me, when transferring the nextcloud service to another server, the /var/lib/nextcloud/data directory is transferred to a pre-prepared server with a php config, data and users are transferred, is it possible to somehow transfer the shared links of users, this is sharing in occ. In this case, the database is prepared with its own credentials, everything connects and starts, but user links are not transferred. How can I transfer published user links along with /data/users*?

Hi @mean2701

You should not only transfer the data directory but you should transfer the database as well. All shares are stored inside of the database.
So that would be a “transplantation” of the cloud.

If you do not want to transfer the complete database, you must reconstruct the shares from the old database and create them new on the new instance.

You can create a lists of all created shares on the old instance with the → nc-shares script ← and then you can re-create all those shares (or all important shares) with exactly the same tokens by the means of the “Configurable Share Links” app:

App-Id cfg_share_links
App-Name Configurable Share Links
Summary App adding the ability to specify share tokens
Categories files, tools
Repository GitHub - jimmyl0l3c/cfg_share_links: App for Nextcloud that adds the ability to specify share tokens
Issue-Tracker Issues · jimmyl0l3c/cfg_share_links · GitHub
Not-shipped (not included) App available in appstore
Appstore https://apps.nextcloud.com/apps/cfg_share_links

Much and good luck,
ernolf

What would you do if your Nextcloud broke down? In the end, backup and restore is exactly what you would do then and what you should do now. And this always includes the database.

For very small Nextcloud installations (one user, a few thousand files), you can also use SQLite as the database. The database is a file that is stored in the file system. This saves you the regular database dump and backing up the database. However, SQLite is generally not recommended. It would also make maximum sense for you if you set up everything from scratch anyway or create a test system.

Thanks for the answer, but a counter question arose, the database for the new nextcloud was restored from a backup only with a different name, that is, all the indexes in it are saved, when transferring /data and php settings to a new directory with data, is it necessary to do anything else? or from the occ commands: to have custom published links appear in the new nextcloud with the old data?

Good afternoon! To transfer shared links, you need to migrate the database along with the /data/users* directory. The shared links are stored in the database, so ensure the entire database is properly transferred to the new server. This should retain all shared links and user data.

https://docs.nextcloud.com/server/latest/admin_manual/maintenance/migrating.html