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.
Migration goals
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.
Planned migration steps
Setting up the hardware
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?
-
Use
mdadm
to 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
/media/raid0/music
-
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.
Migrating the NC instance
Now the Nextcloud migration itself:
-
Put the DO instance into maintenance mode.
-
From the DO droplet, run
snap nextcloud.export
from here..tar
this file andrsync
it 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,
chown
to root, runsnap nextcloud.import
on 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
removable-media
permission. -
Stop the Nextcloud service, move the files currently in
/var/snap/nextcloud/common/nextcloud/
to/media/raid0/nextcloud/
, change the file storage path inconfig.php
accordingly, restart the Nextcloud service.
Verifying that the migration worked, migrate URL
-
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.com
to 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? ()
Adding the music files
-
Move the
/media/raid0/music
directory to/media/raid0/nextcloud/files/fun/
, wherefun
is my NC user account name. -
Use
sudo -u www-data php occ files:scan --all
to 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.
Questions
- 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?