Is there a safe and reliable way to move data directory out of web root?

Can you also please create an issue on GitHub: github.com/nextcloud/server/issues

Created issue: Github #6145

Created simple PHP file in
/var/www/nextcloud/pi.php
Containig:
require('/opt/data/test.php');

It also doesnā€™t work

require(/opt/data/pi.php): failed to open stream: Permission denied in /var/www/html/nextcloud/pi.php

So problem is not in the NextCloud itself, but in my config somewhere somehowā€¦
Keep on digging :slight_smile:

Thnx comunity for support :+1:

Problem was in SELinuxā€¦

1 Like

Thank you for your response:

Actually I have no data to move as I have not done anything with Nextcloud itself other than install it. I have not placed any files anywhere other than the install files. I installed with apt-get per Installation on Linux ā€” Nextcloud 12 Server Administration Manual 12 documentation since I use Linux Mint.

How about /nextcloud/data off the root then? And why would /home/share cause problems?

Iā€™m really confused and didnā€™t find/understand the help on what is going on in Linux by referencing the admin manual. I am guessing that MySQL is going to put the database for Nextcloud where I designate the datapath during the initial setup of Nextcloud. But I am not sure about that. Also, I do not understand what happens if say I load a file into Nextcloud to share as far as the Linux file system goes. Does Nextcloud copy the file and share the copy? If so, where does it copy the file to ā€“ the Nextcloud datapath? Thanks.

As it happens I havenā€™t tried the apt install method but I think @jospoortvliet knows who maintains it and can answer those specific questions around how it installs and to where - much like Windows I guess the dev can decide if everything is in Program Files or %AppData%, etc.

So all the web interface is in practice for file management (and Iā€™m simplifying this horribly, no lynching please) is a front-end to the hidden data folder on the linux system. Therefore when you upload a file youā€™re uploading it directly to the folder on linux. Nextcloud also registers the file in the database and can associate shares and other bits and pieces to it that way.

The database normally will be setup in mysql which in itself has a directory (/var/lib/mysql/ā€¦ in ubuntu), but you donā€™t normally need to mess with directories for the database, instead something like phpmysql will offer a graphical interface for database management if you wish to install it.

1 Like

That helps straighten things out for me, plus I had a chance this morning to checkout the howto Tutorial: How to migrate mass data to a new NextCloud server so between your response and that article I think I have it squared away in my head and I am pleased to see the files are being stored on the server and maintained in a directory structure that the authorized linux users and especially the administrators can get to the raw user files. For me this was important in case I botch up my Nextcloud install. Thanks a ton Jason!

My bad on recollecting how the install on linux documentation goes. As it turns out the installation instructions are apt-get for much of the dependencies but you install pretty much by unpacking and recursively copying the Nextcloud files.

I should have clicked the link, oops. That then is the standard install (though I believe an apt install exists, community-supported) and one Iā€™m quite familiar with.

In which case your installation will likely reside in /var/www(/html)/nextcloud where /html is optional, if youā€™re happy working with your own Apache vhost files (assume that would be a no for you) you could omit /html

data is set by you, so can go basically anywhere. Linux has some rules around mounting things in home folders, which can lead to issues with permissions and other non-niceties; better to use a directory out of /home/user/.., and while root / could be used, it isnā€™t very often.

I wish I had read both the wonderful guide by @MichaIng found here as well as this thread before changing the data directory; it would have been an easy fix to manually update the database along with making the change to config.php.

Alas, here I am with a Nextcloud install that, in light of the information in the guide/thread, seems broken under the hood in some ways. Iā€™ve been poking around in the database, and I do indeed see duplicate entries in the oc_filecache table pertaining - in a large part - to image previews, but I guess there could be other duplicate entries as well. Iā€™ve also been experimenting a bit with occ files:scan --all in a Nextcloud install on a VM, but I donā€™t think it picks up all the preview files either. Which would probably also be strange, since the fileid of a previewable file corresponds to the name of the preview folder both in file system and database, and hence, with new fileid's generated by scanning, the old preview folders would be invalid.

For a manual cleanup Iā€™ve been considering removing the outdated entries from the oc_filecache table, and also manually removing the generated preview folders by using find and filtering by mtime/ctime.

But is there a more correct and/or more comprehensive way to do it?

Iā€™d suggest you create a new topic describing this as well as your environment and anything youā€™ve done so far not mentioned above.

Yeah, previews have to be regenerated as you say: https://github.com/nextcloud/server/issues/5264
You can force this by using the preview generator app. But depending on the amount of data, this can take days.

The oc_filescache should be cleaned up automatically for obsolete entries. The previews were just removed, if you remove the related file from inside nextcloud (instead of manually). So if you want to get rid of the obsolete preview files (which are by the way also stored in the oc_filescache and can make a major part there), you need to clear the whole appdata_<instance_id>/previews folder, which would of course also remove in between recreated previews :confused:.

Something might have changed there or will change soon, but until 12.0.1 I cannot see any different behaviour about obsolete previews:

I guess I should have created a new topic JasonBayton mentions, but, yeah, Iā€™ll keep that in mind for next time. Iā€™ll just leave a reply here and let it be the last of it.

And thanks for your input. I do think I can find all the outdated preview folders by using the find command in Linux. I played around with it a bit on my VM sandbox install of Nextcloud and found that if I deleted some preview folders followed by a manually triggered cron.php, the database was actually cleaned up as expected. I guess that will save some time on my production system as opposed to just deleting all preview folders.

Ah yes, going for creation date e.g. is of course an easy solution to clean up previews folder :laughing:.

Cron.php runs occ files:cleanup, which cleans oc_filecache.

1 Like

A post was split to a new topic: Blank page on login