Moving data directory

I´ve tried to change the data dir from /var/www/html/nextcloud/data to /mnt/HDD1/nextcloud/data by using a link like in Solution 2 of this tutorial: https://help.nextcloud.com/t/howto-change-move-data-directory-after-installation/17170
But if i try to open nextcloud i get the error, that my data dir is invalid.

lrwxrwxrwx  1 www-data www-data    24 Sep  9 17:35 data -> /mnt/HDD1/nextcloud/data
drwxr-xr-x 3 www-data www-data 4096 Sep  9 17:31 nextcloud
 - drwxr-xr-x 5 www-data www-data 4096 Sep  9 17:46 data

So i´ve tried to make /mnt chowned by www-data:www-data and that works but that´s not the way it should be.
Could someone help me, maybe i´m just overlooked something.

Edit: I´m using lighttpd on a Raspberry Pi

Did you copy all files, especially the .ocdata? Such hidden files are sometimes not copied. If not, it would be interesting to know if there are some errors in the server log (permissions etc.).

lighttpd is not officially supported. In theory, it’s only apache but nginx got so much support from the community that it is in the official docs. Some people here used to use lighttpd but I’m not sure if there could be some side effects. Just as a general information, this is probably not related to your problem.

1 Like

I found an issue in the HowTo, that could lead to the above issue, indeed:

  • cp without -r/R/a option it will throw an error and skip the whole data dir.
  • If the target directory already exists, the source dir will be fully placed into the target dir, thus you will have something like /new/path/to/data/data
  • But hidden files are copied at least.

@Max_Zet please check if the above was/is the case.

I fix it in the guide, by pre-creating the target dir and then copying source dir content to target dir content.
Use mkdir -p /new/path/to/data && cp -a /path/to/data/. /new/path/to/data

  • The . (period) assures that hidden files are copied, which is not the case with * (asterisk).
  • -a recursively copies folders, preserves links and permissions, thus no chown needed then as well.

Lighttpd btw. works perfectly. That it is not officially supported is still due to an outdated sabre.io comment, that “not all features are fully supported”. But we have many many examples where it (especially WebDAV) works well and I tested up and down myself :slight_smile:.

1 Like

In that case it could be interesting to have some documented configuration. Or even a test system to add this environment to regular testing procedures.

1 Like

Sorry that it took me so long to answer here.

Still got the problem.
Did that:

Use mkdir -p /new/path/to/data && cp -a /path/to/data/. /new/path/to/data

and the hidden files are in the new path data folder, gave the dir to the www-data user and also made the symlink with www-data permission.

maintenance mode errors with

Your data directory is invalid
Ensure there is a file called “.ocdata” in the root of the data directory.
Cannot create “data” directory
This can usually be fixed by giving the webserver write access to the root directory.

but tbh, i don´t wanna give my whole mount root access to the webserver.

I set up my NC installation with a external data directory. Still in the “internal” (/var/www/nextcloud/data/) data-directory there are three files. .htaccess, index.html and nextcloud.log. The first one contains a bit of data but the other two are empty, maybe they need to remain there because some code checks for the existence of them, even if the data directory is located on another location…

could you give me some more infos about that? Did you set it up with another data dir from the beginning? Did you use the symlink function?
i can´t even end the first setup for the data folder if it´s not in the internal nextcloud folder.

I did set my NC up with the web interface, not the CLI interface one. I Created the folder where the data will be lay before I sent the set request from the web interface. I did not use the symlink function, additionally I did chown the directory for my apache2 user.

i´ve somehow fixed it now by giving www-data a new group and change the group of /mnt/ to that new group.
Don´t know if its save but for now it´s the only way i know it works.

Then mark your answer as completed.

If the nc data folder is in another mounted location, shouldn’t we check after boot that it is actually mounted before used?

In this thread, nc writes files to the wrong location.