Migrate Nextcloud(Pi) but keep data on external drive

Hi guys,

I’m currently running NextcloudPi on my Raspberry 3B+. Attached is a 4TB external drive where all the data is located. I used NextcloudPis Wizard to move the data dir to this folder during setup.
Now, I bought a new Raspberry Pi 4 where I want to migrate to. That means I want to migrate everything (Apps, Data, Users, Settings) to this new Raspberry Pi 4.

I’ve read a lot of guides on how to migrate. All of these consider having two different drives and use rsync (or other tools) to migrate the data folder. However, I just want to use the same hard drive and it would be the easiest way, if I could just unplug it from the old RaspberryPi3 and plug it into the RaspberryPi 4.

Is there a way to do so? In which order do I have to do which steps of backup and restoring?

Thanks a lot!

Hi Teddy, yes it’s possible to use the same drive, I’ve done so multiple times when I’ve been building and testing images and recovered from broken installs. Are you comfortable manually configuring your external drive in fstab?

There are a couple ways of doing it but what I found easiest for me was to compress all the data on the drive and move it outside the “data” directory, so the files are located in the root of the external drive in an archive.

Then you can perform the installation as normal (However! Don’t format the drive, or you’ll lose the data) with empty directories for the data and backup and recreate your user.

When that is done you move the files back into your user and unpack them, after that you run the occ/ncc command for scanning externally added files, which takes some time, after that the files should show up as normal for you in your nextcloud on the new raspberry pi 4

Note If you do it this way, you must not format the drive as you are asked during the installation, if you do that you’ll lose your files :wink:

The downside here is if you wanted to switch filesystem or partitioning table it isn’t possible, since you still have files you want to keep on the drive.

Whether this is the best way for you or if using the backup function is better depends on your own skill and what you’re comfortable trying out and risk tolerance with your data.

Here is an article showing you how to backup with ncp-config

1 Like