0

I need to migrate nextcloud, which is running as a snap, from one server to another. Aside from changing CNAME and stuff like that, is there a simple process to make this transfer happen seamlessly?

Both servers have a snap of nextcloud running at the same version. One server is running Ubuntu 20.04, the other Ubuntu 22.04.1

Hiro
  • 113

2 Answers2

4

If what you really want is to migrate user accounts and their data from one instance of Nextcloud to another instance, then see https://docs.nextcloud.com/server/22/admin_manual/maintenance/migrating.html for the Nextcloud instructions on how to:

  1. Put your servers into maintenance mode.
  2. Dump the database from system #1.
  3. Import the dump into system #2.
  4. Copy data files from system #1 to system #2.

Trying to migrate the snap package is generally wasted effort. The snap is read-only. The snap contains no user accounts nor user data. Moving the snap to a different system will give you an empty Nextcloud install, with no users nor data.

  • All user accounts and data are in the database and the data files. THAT's what needs to be migrated.
user535733
  • 62,253
0

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!