If you're wishing there was a command to make the whole process a bit less tedious, you're in luck! The Nextcloud snap has a built-in utility for performing migrations. The link is to their GitHub wiki, so it may move around. I found it by searching "nextcloud snap data backup."
The short version is: Run sudo nextcloud.export
, which will generate a directory in /var/snap/nextcloud/common/backups/
.
On the new server, run sudo nextcloud.import <backupdir>
and it will replace your existing nextcloud install with the backup.
I did this by plugging my old hard drive in to my server and running nextcloud.import
directly on the backup file, but your approach may be different. There were two caveats for me: First, my nextcloud was set up to put data on a different hard drive, but the script looks for it in the default location (without checking the configs). I used a symbolic link to make the data accessible at /var/snap/nextcloud/current/data
as the script expects. Second, when restoring, data has to be in the snap confinement, so I used a bind mount to make the external hard drive accessible in the snap.
Hope that helps!