Moving Nextcloud Data to external USB drive

Hello all - I am a newie with Nextcloud on a Banana Pi SBC with Ubuntu 20.04 - I’ve installed Nextcloud using Snap. Now to the problem …

I was wanting to migrate the Nextcloud data from the internal drive on the the Banana Pi to an external 8 TB USB storage drive. The drive currently has one NTFS partition, and I was looking for some admin tools (Nextcloud?) that I could utilize to relocate the Netcloud data.

Been looking at the docs as well as the Snap - no joy.

Can someone direct me to the documentation and tools for doing this?

Thanks in advance for any guidance or help.



I am no expert but from my personal experience, I see Linux doesn’t play well with NTFS with advance apps due to permission errors. Better to use ext4.

How to Change Snap NextCloud user Data Directory?

Step 1 →

Connect the Disk and ensure it is detected and readable by Ubuntu by running command, sudo lsblk. This command should show an output with sdb or sdc (depending on number of drive installed) with your drive total capacity.

Step 2 →

Formatting the drive and mounting it under /media or /mnt (warning → Formatting the drive will erase all present data)

sudo mkdir /media/datadisk

sudo mkfs.ext4 -j -L DataDisk /dev/sdb


sudo blkid /dev/sdb → It will generate the disk UUID. Copy it and keep it for the next step.

sudo nano /etc/fstab → It will open up a configuration file under text edititor, don’t change anything just add below line at the end of the file → /dev/disk/by-uuid/4006fe68-879a-41ed-b4da-cc0e6bc6b4bb /media/datadisk auto nosuid,nodev,nofail,x-gvfs-show,x-gvfs-name=NewHDD 0 0 (replace the UUID of this command with your own) Now save and exit the file (CTRL+X → SHIFT+Y → ENTER)

sudo mount -a

Step 3 →

Changeing the nextcloud to the new location

sudo snap connect nextcloud:removable-media → This is to allow snap nextcloud access out of the confinement to external file system.

sudo snap stop nextcloud

sudo mv /var/snap/nextcloud/common/nextcloud/data /media/datadisk/ncdata

sudo nano /var/snap/nextcloud/current/nextcloud/config/config.php → Find the line with entry for DataDirectory and change the location to /media/datadisk/ncdata. Save and exit

sudo chown -R root:root /media/datadisk/ncdata & then sudo chmod 0770 /media/datadisk/ncdata

sudo snap start nextcloud

Last Step →

You may now need to reboot the server.

Your installation will now save all user data out to that external or second disk.


1 Like

NaXal - thank-you so much for your guidance - your directions were perfect!


1 Like

That is an excellent write up. However, I did not install the SNAP version of NextCloud. Instead I installed each NextCloud component individually in what I call the manual installation approach. Additionally, I am trying to move my NextCloud Data folder located on my boot drive over to a secondary internal drive I have setup only for the storage of my personal data. In other words, I do not want to store any of my personal data onto my boot drive which is running Ubuntu Server 22.04.

Have you by chance seen any online documentation that nicely shows in a sequential manner like you do the steps involved in moving a Nextcloud data folder? I need to move my Nextcloud Data folder from the boot drive path shown below:


Over to the new path shown below which is setup on my new secondary 8TB drive:


I am having a hard time finding detailed documentation for this task I need to perform. Everything seems to be written for the SNAP version of Nextcloud and for adding new hard drives. But none for moving a Nextcloud data folder from the boot drive over to a secondary data storage drive. If you can provide a link to such documentation it will be much appreciated. Thank you for your time.

1 Like

@slipstream Have you tried editing the line 'datadirectory' => '/var/www/nextcloud/data' in your configuration file (/var/www/nextcloud/config/config.php I assume)?
Remember to shutdown apache server and disable cron (if you have) before starting your migration. Also you need to move everything to the new folder, set up fstab to mount the new filesystem on system boot, and make sure your new data directory has the correct permission (refer to the old /var/www/nextcloud/data one)


Apologies but my knowledge is very limited. I, myself use snap so things that I wrote are the stuff I had to learn and implement for my setup.

Correct me if I am wrong, but in case of your setup, you are not actually moving nextcloud storage, rather you are moving the location of public (web root) folder of Apache or nginx or whatever web server you are using.

Nextcloud stays or gets installed in that location.

Here is an example, → How To Move an Apache Web Root to a New Location on Ubuntu 20.04 | DigitalOcean

This will not move your database though, only nextcloud core files and user data !!