HowTo: Change / Move data directory after installation


Is it safe to remove old entries in oc_storage table that refer to old, unused local storages? I seem to still have an old storage back from owncloud, and very old one from nextlcoud (changed mountpoints years back).


Should work fine, did this on my machine as well some time ago. However do a mysqldump first, just to be sure.


I followed solution 2 and it works fine. But, subsequently I’ve tried to install ElasticSearch full text search in my NC accordingly to this manual. But this ends up not in a working full text search but in:

pi@raspberrypi:~ $ sudo service elasticsearch start

pi@raspberrypi:~ $ sudo service elasticsearch status

● elasticsearch.service – LSB: Starts elasticsearch

Loaded: loaded (/etc/init.d/elasticsearch; generated; vendor preset: enabled)

Active: active (exited) since Wed 2019-04-24 13:07:26 BST; 40s ago

Docs: man:systemd-sysv-generator(8)

Process: 556 ExecStart=/etc/init.d/elasticsearch start (code=exited, status=0/SUCCESS)

CGroup: /system.slice/elasticsearch.service

Apr 24 13:07:26 raspberrypi systemd[1]: Starting LSB: Starts elasticsearch…

Apr 24 13:07:26 raspberrypi systemd[1]: Started LSB: Starts elasticsearch.

pi@raspberrypi:~ $ sudo -u www-data php /home/pi/usbdrive/html/occ fulltextsearch:index

In Index.php line 380:

failed platform test.

fulltextsearch:index [–output [OUTPUT]] [-r|–no-readline] [–] []

What am I wrong?


Please verify if elasticsearch follows symlinks by default or not. Just a guess in the blue, since this is the basic change that comes with solution 2 :wink:.


Hi, in the next days I will need to add a new disk to my server and with this will change my filesystem. After this my nextcloud_data folder (only this since the nextcloud system files are on a different drive) will have a new path. I read that changing the path is not recommended. Since all files in my nextcloud instance are synced to clients and I don’t need the previous version etc. I wonder if there is a way to reset (empty) the nextcloud data folder without the need to reinstall nextcloud? Meaning that for all users the folder is empty and filled with the data from the clients at the first sync. Similar to the first sync after a new installation.


You don’t run it on DietPi, do you? In case moving the dietpi_userdata with nextcloud_data inside can be done without any changes to Nextcloud.

However otherwise changing/moving your Nextcloud data dir via solution 1 (of this HowTo) requires an adjustment of the database in every case, with or without clearing the data. In fact clearing the data just means additional steps and risk. So no benefit/point in doing this IMO, only the risk that clients pull file removals instead of pushing them to server.

Whatever you do, do a full backup of your Nextcloud install dir and database. And cp -a/rsync the data (preserving timestamps) instead of moving them, so you have a backup in case any issue, corruption I/O error or such happens. And block/disconnect the server from clients access until you verified (e.g. accessing to web UI locally) that everything went well, before re-opening for client access.

1 Like

Isn’t it a better solution to mount the new storage in your nextcloud folder directly?

I have nextcloud/data as one mount and /nextcloud/data/appdata_oc56k88881p0f/preview as another. Works great and it makes it easier to backup nc and user data.


The whole idea of having it outside the Nextcloud install dir is the security aspect to have it outside of the webserver document root. And the effort for moving/backing up is nearly the same. I mean if you copy/sync one or two directories does not really make a difference, does not?

But generally moving data by mounting it to the old location is actually a “solution 3” as alternative to the symlink method. However I personally prefer to have the least amount of links/mounts/redirects possible to keep things simple and avoid unexpected surprises and such. So I always go with “solution 1” and tell Nextcloud directly where the final location is, in case of a mount inside /mnt. But that’s as well about personal taste and needs.


Ok, thanks. Then I will try solution 1. A backup of my data is available. Worst case means at the end reinstall nextcloud on the server.

How can I check afterwards that everything went fine. Is it sufficient to simple open some files in the WebUI or is there any better check/test?


If you can see your files and can write to them (or create new ones) then this should be sufficient as check.

A reinstall should never be required as long as you have your e.g. /var/www/nextcloud (or where you installed it) and the database dump (as mentioned/created through the HowTos steps) you can always revert to the previous stage. PHP, webserver, Redis server (in case you use it) and all this are not affected.