Let me start by saying that I don’t have a particular problem—rather, I’m planning to migrate my Nextcloud instance to a physical server in a few months and I wanted to ask for general feedback on whether my plan sounds workable, if there are any pitfalls I should watch out for, and if there’s anyway I can modify the sequence of steps to make my plan more robust to failure. I have included a few specific questions at the end, though.
I have never done a server migration before, and am a fairly new user of Nextcloud, but I have used Linux as my primary OS for a few years and am comfortable moving files around, manipulating configs etc on the command line.
I have: A working Nextcloud 24.03 instance running on an Ubuntu Server 22.04 Digital Ocean droplet. Nextcloud is installed as a Snap according to this tutorial from DO. I own the domain
nextcloud.example.com which is pointed to this instance by an A record.
I want: To migrate Nextcloud to a physical server—either a used desktop or a Raspberry Pi—with the file storage mapped to a RAID-1 array. In the process of this, I want to add about 50GB of music files to Nextcloud that don’t fit on the DO Droplet.
I have read through the server migration page in the docs as well as the import/export tutorials linked there. Since I intend to use the Nextcloud snap both before/after migration, not all of these instructions are relevant, and I can do things more simply using
sudo nextcloud.import/export as described here.
I’m the sole user of the Nextcloud, so I can handle a few days of downtime if necessary.
The first few steps don’t involve changing the DO Droplet at all—I will continuing using it while doing the following
Get the physical server: Either a Raspberry Pi or a used desktop.
- In the latter case, the Pi will have its OS installed on an SD card or USB drive, and two USB external SSDs or HDs for the RAID array.
- In the former case, I’ll look for a desktop that has space for one NVMe drive for the boot partition and two internal SSDs or HDs. Or just three internal storage drives.
Install Ubuntu Server 22.04 to the boot drive.
- Or maybe install a lightweight desktop distro like Xubuntu so I can manipulate files with a GUI if I want to. If I do this, what other packages do I need to install to bring it to feature parity with Ubuntu Server?
mdadmto set up the RAID array, with a permanent mount point, say
/media/raid0. Set this to mount automatically on boot. This guide seems OK if a little outdated.
Copy my music files to a temporary directory on the RAID array, say
Set up a static IP address for the new server.
- I plan on doing this from my router settings first, then following this tutorial for Ubuntu.
Get SSH access working with firewall and API keys, test that I can SSH into the server from offsite.
Now go to the new server a run
snap install nextcloud. This might require doing some boilerplate config steps, but it doesn’t matter because we will override these settings in the next step.
Now the Nextcloud migration itself:
Put the DO instance into maintenance mode.
From the DO droplet, run
snap nextcloud.exportfrom here.
.tarthis file and
rsyncit to a USB drive (it shouldn’t be more than about 2GB).
Copy the file from the USB drive to the
/var/snap/nextcloud/current/ directory on the boot partition,
chownto root, run
snap nextcloud.importon this file as explained here (same snap migration link as above).
Now, before taking this instance online, I want to configure it to use the RAID array instead of the boot partition for file storage.
Following this tutorial from the NC snap docs, first I give the NC snap the
Stop the Nextcloud service, move the files currently in
/media/raid0/nextcloud/, change the file storage path in
config.phpaccordingly, restart the Nextcloud service.
Take the new server’s NC out of maintenance mode and type the new server’s IP address in the browser to make sure that all the files, database, etc. were imported properly.
If everything is working, change the A record of
nextcloud.example.comto point to the new server’s IP.
Wait a few hours for the change to propagate across DNS.
Now, if I go to my client devices and trigger a Nextcloud sync, they should sync seamlessly, reporting no file changes, right? ()
funis my NC user account name.
sudo -u www-data php occ files:scan --allto trigger NC to detect these new files.
The purpose of steps 4 and 17 is to avoid having to transfer my music library over the network. I know that dropping files straight into the NC files directory is an anti-pattern because NC expects “sovereignty” over its data directory, but for a one-time operation this should be safe, right?
Finally, if this setup works normally for a week or so, I will shut down the DO droplet.
- Is this plan workable? Is there anything I have overlooked?
- Are there any ways to optimize the sequence of steps above to minimize the amount of time my NC spends in maintenance mode?
- Any advice on whether I should choose the Raspberry Pi or desktop server option?
- Note that if I use the Raspberry Pi, I still intend to use Ubuntu instead of the NextcloudPi image since it’ll let me install NC as a snap and have access to the easy import/export feature.
- Is the statement above () about seamless syncing after migration true?
- “My client devices” includes various desktop/mobile Nextcloud client apps, as well a few third-party apps that I have given access to NC using app passwords, as well as the Android WebDAV for calendar sync.
- Is my proposal for transferring in my music files locally (steps 16–17) safe? Would it be better to stop the Nextcloud service and/or or put it in maintenance mode for these steps?