Replace hard drive where data folder is on

Hi guys,

I have been successfully running Nextcloud 12.0.3 on Arch Linux with Apache 2.4.29 and PHP 7.1.12.

I have my data directory on a separate drive and this drive has been getting full. So I bought a new bigger hard drive and mirrored the content from the old drive to the new drive using rsync. Before I did that, I stopped the Apache web server. When all this was done, I shut down the server, replaced the old hard drive with the new one and mounted it at the exact same place. To me it looks all identical, but Nextcloud is not happy. When I try to reach my login page, I get:

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. See https://docs.nextcloud.com/server/12/go.php?to=admin-dir_permissions

As far as I can tell right now, all the permissions are the same. The data directory is owned by the Apache user and there is read and write access. I also see that .ocdata file in the root data folder. I do not see what seems to be the problem. I did not change the configuration or anything in the webapp folder.

I thought, maybe it helps, if I scan for new files, so I ran:
sudo -u http /usr/share/webapps/nextcloud/occ files:scan --all
On Arch Linux, http is the Apache user. Doing this, I get the following message:

PHP Warning:  fileperms(): stat failed for /mountpoint/nextcloud/data/nextcloud.log in /usr/share/webapps/nextcloud/lib/private/Log/File.php on line 133
{"reqId":"removed","level":3,"time":"2018-01-14T10:13:54+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"Narrowing occurred during type inference. Please file a bug report on bugs.php.net at \/usr\/share\/webapps\/nextcloud\/lib\/composer\/composer\/ClassLoader.php#444","userAgent":"--","version":"12.0.3.3"}
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. See https://docs.nextcloud.com/server/12/go.php?to=admin-dir_permissions

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /usr/share/webapps/nextcloud/lib/private/Console/Application.php:145
Stack trace:
#0 /usr/share/webapps/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /usr/share/webapps/nextcloud/occ(11): require_once('/usr/share/weba...')
#2 {main}PHP Warning:  fileperms(): stat failed for /mountpoint/nextcloud/data/nextcloud.log in /usr/share/webapps/nextcloud/lib/private/Log/File.php on line 133
{"reqId":"removed","level":3,"time":"2018-01-14T10:13:55+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileperms(): stat failed for \/mountpoint\/nextcloud\/data\/nextcloud.log at \/usr\/share\/webapps\/nextcloud\/lib\/private\/Log\/File.php#133","userAgent":"--","version":"12.0.3.3"}
{"reqId":"removed","level":3,"time":"2018-01-14T10:13:55+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"chmod(): Permission denied at \/usr\/share\/webapps\/nextcloud\/lib\/private\/Log\/File.php#134","userAgent":"--","version":"12.0.3.3"}

It seems like a permission issue, but I really do not see why. Do you have any ideas?

Thanks a lot,

Hell-G

Can you show us the output of ls -lsia /mountpoint/nextcloud?
Often the folder itself is set correctly but the permissions on the parent folders are too strict.

Thank you for looking into this!
Here is the output:

# ls -lsia /mountpoint/nextcloud
total 12
42401793 4 drwxr-x---  3 http   http   4096 Jan 16  2017 .
       2 4 drwxrwx--- 14 hell-g hell-g 4096 Sep  5 12:34 ..
82968616 4 drwxr-x--- 11 http   http   4096 Aug 27 12:45 data

You are right, that was it! I forgot to check the permissions of the root folder of the old hard drive. By using rsync, I must have given the new hard drive the permissions for my regular user and no access rights for other users. That must have been different on the old hard drive.
I changed the permissions of /mountpoint to 755 and now it seems to be working again.

Thanks a lot!