I have successfully configured nextcloud so that my data-folder is located on a external USB HDD.
Personally, I reinstalled nextcloud because moving the data-folder after installation is not officially supported.
I formatted my HDD as NTFS so the data would be accessible from other OSs and pasted the following last in /etc/fstab (remember to insert correct UUID):
UUID="[INSERT UUID]" /mnt/ekstern ntfs-3g defaults,auto,uid=33,gid=33,umask=077 0 0
I posted this on another thread a while back, but thought it could assist you.
Though it may not be supported as others have pointed out in many threads, I have yet to have an issues changing data directorys; I have changed the data directory many times on many different OwnCloud & NextCloud hosts just fine without any issues. These are the steps I take to move the data directory: (This only works if you have no data to move, as if this is a fresh install)
Run the following command in the Linux shell:
o sudo service apache2 stop
o sudo mkdir /media/user/your_hard_drive/nextcloud_data âor whatever you want to call it?â Remember the /media is your mount point or external hard drive.
o sudo chown -R www-data:www-data /media/user/your_hard_drive/nextcloud_data/
o sudo chmod -R 777 /media/user/your_hard_drive/nextcloud_data/
o sudo chown âR www-data:www-data /media
o sudo nano /var/www/html/nextcloud/config/config.php
o Once you are in the config.php you need to change your data directory. Save file and exit.
I have moved my data folder using the steps described by @wclang and at first sight everything seemed to be fine. However after a restart of my system I received an Internal Server Error right after the login, see âhttps://help.nextcloud.com/t/13256â
One step that is missing but mentioned by the previous posts is to update the database table oc_storages. Also you should activate the maintenance mode inside config.php before you apply the changes.
One additional thing I had to do was to delete all the contents from the table oc_filecache. Afterwards I simply restarted Apache, deactivated maintenance mode and when I logged in to nextcloud, everything was working fine again.
For future reference folks, you can also just symlink from /var/www/data (or wherever you set it up initially) to your new location after moving everything. Iâm personally a fan of sudo rsync -avP as it preserves all files, permissions, ownership and shows progress as it goes, then deleting the original when Iâve confirmed everything (including hidden files) has been copied over.
That way thereâs no need to update the DB and you wonât be told thatâs unsupported.
I should of stated in my post that my process is for fresh builds only without any data in it, if you have data then following âsireaâ additional steps will be required. Thanks for pointing that out âsireaâ
note th[quote=âJasonBayton, post:4, topic:3642â]
Make sure no cron jobs are running
Stop apache
Move /data to the new location
Create a symlink from the original location to the new location
Ensure permissions are still correct
Restart apache
[/quote]
Note that you have to configure your webserver to respect that symlink, I believe not all do
Now for the data move to fresh disk:
sudo systemctl stop apache2
sudo rsync -avP /var/www/nextcloud-data /mnt/data/
sudo nano /var/www/nextcloud/config/config.php
âdatadirectoryâ => â/mnt/data/nextcloud-data/â,
sudo shutdown -r now
Thanks JaysonBayton. You are correct, I missed the database edit.
Fooled myself because everything continued to work, but of course the new data location wasnât being used. Probably would have been a long time until I realized it. Thanks again.
Edit database nextcloud
Database: nextcloud
Table: OC_STORAGES
Row: change row data from local::/var/www/nextcloud-data/ to local::/mnt/data/nextcloud-data/
sudo systemctl stop MySQL
sudo su
mv /var/www/nextcloud-data/ /var/www/nextcloud-data-old/
sudo shutdown -r now
A bit off topic: I used HeidiSQL with plink SSH Tunnel to manage MariaDB and do the nextcloud database edit as Iâm connecting from Windows - a few things to know to connect to MariaDB, Iâll share if anyone is interested
Maybe we can move this to howto, as still questions about that appear. Or ah, I will collect all information here and write some howto the next hour. About symlink, which seems to be an easy alternative solution: How the enable symlink support for webservers or be sure that theyâre supported?
âŹ: Okay for apache itâs simply: