Nextcloudplus: Broken after adding / initializing HDD

Support intro

Sorry to hear you’re facing problems :slightly_frowning_face:

help.nextcloud.com is for home/non-enterprise users. If you’re running a business, paid support can be accessed via portal.nextcloud.com where we can ensure your business keeps running smoothly.

In order to help you as quickly as possible, before clicking Create Topic please provide as much of the below as you can. Feel free to use a pastebin service for logs, otherwise either indent short log examples with four spaces:

example

Or for longer, use three backticks above and below the code snippet:

longer
example
here

Some or all of the below information will be requested if it isn’t supplied; for fastest response please provide as much as you can :heart:

Nextcloud version (eg, 12.0.2): newest (auto-update)
Operating system and version (eg, Ubuntu 17.04): raspbian, debian, nextcloudplus
Apache or nginx version (eg, Apache 2.4.25): unknown
PHP version (eg, 7.1): 7.1

The issue you are facing:
I attached a NTFS formatted HDD (“HDD2”) to the raspberry with nextcloudplus (debian, nextcloud) installed. NCP was updated to the newest version. A HDD was already added to the device and the data directory is on “HDD1”. HDD2 was supposed to be used as backup solution.

No I can access data via my mobile phone, but the login via webpage is no more possible (not over my domain and not over local IP in network. So access via browser is no more possible. In a tab where I a still logged in via external access, the page looks broken up, so the design is messed. When I want to login via browser over a link in the local network, the login screen appears, but by entering login-Data, nothing happens.

I detached HDD2, but nothing changes.

Update: I restarted NPC, now it works better again, but the design is still partially broken.

What do I have to do to add a 2nd HDD as backup?
I have readthese infos, but this is not helpful, as it seems to break the filesystem (as showed above)

Is this the first time you’ve seen this error? (Y/N): Y

The output of your Nextcloud log in Admin > Logging:
no access possible
nothing unusual under index.php/settings/admin/logging
At the time I added the HDD, nothing happed.
I only have

Fatal webdav OCP\Files\ForbiddenException: Following symlinks is not allowed 2018-07-07T09:11:23+0200
Error core Following symlinks is not allowed (’/media/USBdrive/ncdata/pi/files/Sync_Testrechner_LS/pc-leonardo’ -> ‘/media/64C6366BC6363E1C/ncdata/pi/files/Sync_Testrechner_LS/pc-leonardo/’ not inside ‘/media/myCloudDrive/ncdata/pi/’) 2018-07-07T09:11:23+0200
Fatal webdav OCP\Files\ForbiddenException: Following symlinks is not allowed 2018-07-07T09:10:54+0200
Error core Following symlinks is not allowed (’/media/USBdrive/ncdata/pi/files/Sync_Testrechner_LS/pc-goliath’ -> ‘/media/64C6366BC6363E1C/ncdata/pi/files/Sync_Testrechner_LS/pc-goliath/’ not inside ‘/media/myCloudDrive/ncdata/pi/’) 2018-07-07T09:10:54+0200
Fatal webdav OCP\Files\ForbiddenException: Following symlinks is not allowed 2018-07-07T09:10:53+0200

which is ok, as this is some external storage, which I cannot access now.


The output of your config.php file in `/path/to/nextcloud` (make sure you remove any identifiable information!):

PASTE HERE


The output of your Apache/nginx/system log in `/var/log/____`:

[Sat Jul 07 06:25:03.878815 2018] [ssl:warn] [pid 700:tid 1996333056] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the $
[Sat Jul 07 06:25:04.000301 2018] [mpm_event:notice] [pid 700:tid 1996333056] AH00489: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2l configured – resuming normal$
[Sat Jul 07 06:25:04.000376 2018] [core:notice] [pid 700:tid 1996333056] AH00094: Command line: ‘/usr/sbin/apache2’
[Sat Jul 07 07:25:49.666922 2018] [mpm_event:notice] [pid 700:tid 1996333056] AH00491: caught SIGTERM, shutting down
[Sat Jul 07 07:25:58.742891 2018] [ssl:warn] [pid 473:tid 1995436032] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the $
[Sat Jul 07 07:25:59.105045 2018] [ssl:warn] [pid 690:tid 1995436032] AH01909: localhost:4443:0 server certificate does NOT include an ID which matches the $
[Sat Jul 07 07:26:00.005126 2018] [mpm_event:notice] [pid 690:tid 1995436032] AH00489: Apache/2.4.25 (Raspbian) OpenSSL/1.0.2l configured – resuming normal$
[Sat Jul 07 07:26:00.005386 2018] [core:notice] [pid 690:tid 1995436032] AH00094: Command line: ‘/usr/sbin/apache2’

I can tell the short story of the answer to your only question, how to backup. Well, it’s a complicated answer, so the simple answer is no. It looks like there’s every possible hack for the raspberries, but I don’t see any official way to replicate, backup, or something else goes here. What I do is…I have a virtual machine and an OrangePi running nextcloud, (and I run the ownbackup app, which is somewhat redundant if you choose the database on USB option, although it’s not useless; it still provides a real backup and keeps versions, and stuff. ) and my desktop synchronization client synchronizes all files, and both servers in the sync client point to the same data directory. So when a file changes on a server and is synchronized to the desktop, the synchronization client picks it up as a change that needs to be distributed to all other connected servers.

Your problem is basically outlined in the first paragraph of the link you posted.

It looks like for now, you should remove all USB drives, reboot, insert the nextcloud drive, reboot again, then nextcloud will be working. Then you can log onto the system and determine the unique path with /media. There is probably an easy pi way to do this. Then change your data directory setting to point to the direct name, as outlined in the document you linked.

Make sure you re-read this again

From that documentation

Important note: If you are using only one USB drive, you can leave the default path /media/USBdrive for all configuration options, but if you are going to use more than one you need to reference them by label, or NCP will not be able to know which one is which. For instance, if the label of the drive is mylabel then use the path /media/mylabel for items such as nc-datadir, nc-database and so on.

So it is easy: stop using /media/USBdrive, use HDD labels

I tried to do that the following way:

  1. Logged into the NCP Panel > “data directory”
  2. Changed the path from “/media/USBdrive/ncdata” to “/media/MyCloudDrive/ncdata” (The name of the HDD I found by cd /dev/disk/by-label

No I get the error:

Fehler (Error)

Dein Datenverzeichnis ist ungültig (Data directory not valid)

Stelle sicher, dass eine Datei “.ocdata” im Wurzelverzeichnis des data-Verzeichnisses existiert.
(Make sure file “.ocdata” exists in root of data directory).

I still have the error after changing the directory back to “/media/USBdrive/ncdata”

Logs:

[ nc-datadir ]
Cannot load Zend OPcache - it was already loaded
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:3,“time”:“2018-07-22T16:51:53+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#136”,“userAgent”:“–”,“version”:“13.0.4.0”}
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:2,“time”:“2018-07-22T16:51:53+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“no app in context”,“method”:“–”,“url”:“–”,“message”:“Temporary directory /media/USBdrive/ncdata/tmp is not present or writable”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:3,“time”:“2018-07-22T16:51:54+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“file_get_contents(/media/USBdrive/ncdata/news/config/config.ini): failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#214”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:3,“time”:“2018-07-22T16:51:54+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#136”,“userAgent”:“–”,“version”:“13.0.4.0”}
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:2,“time”:“2018-07-22T16:51:54+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“news”,“method”:“–”,“url”:“–”,“message”:“Configuration invalid. Ignoring values.”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:3,“time”:“2018-07-22T16:51:54+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“mkdir(): Permission denied at /var/www/nextcloud/apps/news/lib/AppInfo/Application.php#143”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:3,“time”:“2018-07-22T16:51:54+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#136”,“userAgent”:“–”,“version”:“13.0.4.0”}
{“reqId”:“AfVKInqTcRxLEFVdeBLz”,“level”:3,“time”:“2018-07-22T16:51:54+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“chmod(): No such file or directory at /var/www/nextcloud/lib/private/Log/File.php#137”,“userAgent”:“–”,“version”:“13.0.4.0”}
Error reading data directory. Is NextCloud running and configured?

[ nc-limits ]
./nc-limits.sh: Zeile 33: [[: 768M: Der Wert ist für die aktuelle Basis zu groß. (Fehlerverursachendes Zeichen ist "768M").
Using 4 PHP threads
./nc-limits.sh: Zeile 63: [[: 3gb: Der Wert ist für die aktuelle Basis zu groß. (Fehlerverursachendes Zeichen ist "3gb").

Give us the output of

sudo ncp-report

<–! Paste this in GitHub report →

NextCloudPi diagnostics

Cannot load Zend OPcache - it was already loaded
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log                                                                      in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":3,"time":"2018-07-22T18:04:04+00:00","re                                                                     moteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileper                                                                     ms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/ne                                                                     xtcloud\/lib\/private\/Log\/File.php#136","userAgent":"--","version":"13.0.4.0"}
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":2,"time":"2018-07-22T18:04:04+00:00","re                                                                     moteAddr":"","user":"--","app":"no app in context","method":"--","url":"--","mes                                                                     sage":"Temporary directory \/media\/USBdrive\/ncdata\/tmp is not present or writ                                                                     able","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log                                                                      in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":3,"time":"2018-07-22T18:04:05+00:00","re                                                                     moteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"file_ge                                                                     t_contents(\/media\/USBdrive\/ncdata\/news\/config\/config.ini): failed to open                                                                      stream: No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Files\                                                                     /Storage\/Local.php#214","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log                                                                      in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":3,"time":"2018-07-22T18:04:05+00:00","re                                                                     moteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileper                                                                     ms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/ne                                                                     xtcloud\/lib\/private\/Log\/File.php#136","userAgent":"--","version":"13.0.4.0"}
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":2,"time":"2018-07-22T18:04:05+00:00","re                                                                     moteAddr":"","user":"--","app":"news","method":"--","url":"--","message":"Config                                                                     uration invalid. Ignoring values.","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log                                                                      in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":3,"time":"2018-07-22T18:04:05+00:00","re                                                                     moteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"mkdir()                                                                     : Permission denied at \/var\/www\/nextcloud\/apps\/news\/lib\/AppInfo\/Applicat                                                                     ion.php#143","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log                                                                      in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":3,"time":"2018-07-22T18:04:05+00:00","re                                                                     moteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileper                                                                     ms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/ne                                                                     xtcloud\/lib\/private\/Log\/File.php#136","userAgent":"--","version":"13.0.4.0"}
{"reqId":"DwNwiZdb7a8bIvZshxQd","level":3,"time":"2018-07-22T18:04:05+00:00","re                                                                     moteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"chmod()                                                                     : No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Log\/File.ph                                                                     p#137","userAgent":"--","version":"13.0.4.0"}
NextCloudPi version  v0.57.20
distribution         Raspbian GNU/Linux 9 \n \l
automount            yes
USB devices          sda
datadir              /media/USBdrive/ncdata
data in SD           no
data filesystem      btrfs
data disk usage      179G/932G
rootfs usage         5,0G/118G
swapfile             /var/swap
dbdir                /var/lib/mysql
Nextcloud check      error
HTTPD service        up
PHP service          up
MariaDB service      up
Redis service        up
Postfix service      up
internet check       ok
port check 80        open
port check 443       open
IP                   192.168.178.29
gateway              192.168.178.1
interface            eth0
certificates         _deleted for privacy reasons_
NAT loopback         no
uptime               1:11

Nextcloud configuration

Cannot load Zend OPcache - it was already loaded
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":3,"time":"2018-07-22T18:04:09+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#136","userAgent":"--","version":"13.0.4.0"}
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":2,"time":"2018-07-22T18:04:09+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"--","url":"--","message":"Temporary directory \/media\/USBdrive\/ncdata\/tmp is not present or writable","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":3,"time":"2018-07-22T18:04:10+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"file_get_contents(\/media\/USBdrive\/ncdata\/news\/config\/config.ini): failed to open stream: No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Files\/Storage\/Local.php#214","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":3,"time":"2018-07-22T18:04:10+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#136","userAgent":"--","version":"13.0.4.0"}
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":2,"time":"2018-07-22T18:04:10+00:00","remoteAddr":"","user":"--","app":"news","method":"--","url":"--","message":"Configuration invalid. Ignoring values.","userAgent":"--","version":"13.0.4.0"}
PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":3,"time":"2018-07-22T18:04:10+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"mkdir(): Permission denied at \/var\/www\/nextcloud\/apps\/news\/lib\/AppInfo\/Application.php#143","userAgent":"--","version":"13.0.4.0"}
Your data directory is invalid
Ensure there is a file called ".ocdata" in the root of the data directory.

Your data directory is not writable
Permissions can usually be fixed by giving the webserver write access to the root directory. See https://docs.nextcloud.com/server/13/go.php?to=admin-dir_permissions.

An unhandled exception has been thrown:
Exception: Environment not properly prepared. in /var/www/nextcloud/lib/private/Console/Application.php:148
Stack trace:
#0 /var/www/nextcloud/console.php(89): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#1 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#2 {main}PHP Warning:  fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":3,"time":"2018-07-22T18:04:10+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"fileperms(): stat failed for \/media\/USBdrive\/ncdata\/nextcloud.log at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#136","userAgent":"--","version":"13.0.4.0"}
{"reqId":"4xW6RZKSjicoGwn7XLkD","level":3,"time":"2018-07-22T18:04:10+00:00","remoteAddr":"","user":"--","app":"PHP","method":"--","url":"--","message":"chmod(): No such file or directory at \/var\/www\/nextcloud\/lib\/private\/Log\/File.php#137","userAgent":"--","version":"13.0.4.0"}

HTTPd logs

[Sun Jul 22 16:52:49.290063 2018] [proxy_fcgi:error] [pid 740:tid 1683780656] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  touch(): Utime failed: Permission denied in /var/www/ncp-web/ncp-output.php on line 81\n'
[Sun Jul 22 16:59:26.445336 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 16:59:46.571732 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 16:59:56.102616 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:02.906586 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:09.718172 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:23.101655 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:27.298216 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:32.546871 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:40.916452 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:47.132143 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:50.336253 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:00:56.137840 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:04.144575 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:12.615835 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:14.753662 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:16.356678 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:27.374783 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:41.990926 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'
[Sun Jul 22 17:01:53.816265 2018] [proxy_fcgi:error] [pid 740:tid 1692177456] [client 192.168.178.20:57675] AH01071: Got error 'PHP message: PHP Warning:  fclose(): supplied resource is not a valid stream resource in /var/www/ncp-web/L10N.php on line 166\n'

Database logs

2018-07-22 16:52:33 1978221376 [Note] /usr/sbin/mysqld: Shutdown complete

2018-07-22 16:52:59 1996378112 [Note] InnoDB: Using mutexes to ref count buffer pool pages
2018-07-22 16:52:59 1996378112 [Note] InnoDB: The InnoDB memory heap is disabled
2018-07-22 16:52:59 1996378112 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2018-07-22 16:52:59 1996378112 [Note] InnoDB: GCC builtin __atomic_thread_fence() is used for memory barrier
2018-07-22 16:52:59 1996378112 [Note] InnoDB: Compressed tables use zlib 1.2.8
2018-07-22 16:52:59 1996378112 [Note] InnoDB: Using Linux native AIO
2018-07-22 16:53:00 1996378112 [Note] InnoDB: Using generic crc32 instructions
2018-07-22 16:53:00 1996378112 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2018-07-22 16:53:00 1996378112 [Note] InnoDB: Completed initialization of buffer pool
2018-07-22 16:53:00 1996378112 [Note] InnoDB: Highest supported file format is Barracuda.
2018-07-22 16:53:01 1996378112 [Note] InnoDB: 128 rollback segment(s) are active.
2018-07-22 16:53:01 1996378112 [Note] InnoDB: Waiting for purge to start
2018-07-22 16:53:01 1996378112 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.35-80.0 started; log sequence number 1090413479
2018-07-22 16:53:01 1447031616 [Note] InnoDB: Dumping buffer pool(s) not yet started
2018-07-22 16:53:01 1996378112 [Note] Plugin 'FEEDBACK' is disabled.
2018-07-22 16:53:01 1996378112 [Note] Server socket created on IP: '127.0.0.1'.
2018-07-22 16:53:01 1996378112 [Note] /usr/sbin/mysqld: ready for connections.
Version: '10.1.23-MariaDB-9+deb9u1'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Raspbian 9.0

Nextcloud logs

tail: '/media/USBdrive/ncdata/nextcloud.log' kann nicht zum Lesen geöffnet werden: Datei oder Verzeichnis nicht gefunden

Make sure that you have a valid datadir in /media/USBDrive/ncdata, and that it has the right permissions

Thank you for your answers.

How do I make sure I have a valid datadir in /media/USBDrive/ncdata? I did not change anything, I just changed the path from “/media/USBdrive/ncdata” to “/media/MyCloudDrive/ncdata and then changed it back.

stat /media/USBdrive/ncdata leads to

Datei: /media/USBdrive/ncdata
Größe: 0 Blöcke: 0 EA Block: 4096 Verzeichnis
Gerät: 28h/40d Inode: 256 Verknüpfungen: 1
Zugriff: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)

How do I change the permissions?

try running nc-fix-permissions from ncp-web or ncp-config

This now leads to: “Unauthorized request. Try reloading the page”
I tried via the Panel in my browser. Is there another chance to start Fix permissions?

type sudo ncp-config from the terminal

Fix permissions via terminal leads to:

PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:3,“time”:“2018-07-23T16:40:04+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#136”,“userAgent”:“–”,“version”:“13.0.4.0”}
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:2,“time”:“2018-07-23T16:40:04+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“no app in context”,“method”:“–”,“url”:“–”,“message”:“Temporary directory /media/USBdrive/ncdata/tmp is not present or writable”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:3,“time”:“2018-07-23T16:40:05+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“file_get_contents(/media/USBdrive/ncdata/news/config/config.ini): failed to open stream: No such file or directory at /var/www/nextcloud/lib/private/Files/Storage/Local.php#214”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:3,“time”:“2018-07-23T16:40:05+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#136”,“userAgent”:“–”,“version”:“13.0.4.0”}
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:2,“time”:“2018-07-23T16:40:05+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“news”,“method”:“–”,“url”:“–”,“message”:“Configuration invalid. Ignoring values.”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:3,“time”:“2018-07-23T16:40:05+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“mkdir(): Permission denied at /var/www/nextcloud/apps/news/lib/AppInfo/Application.php#143”,“userAgent”:“–”,“version”:“13.0.4.0”}
PHP Warning: fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log in /var/www/nextcloud/lib/private/Log/File.php on line 136
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:3,“time”:“2018-07-23T16:40:05+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“fileperms(): stat failed for /media/USBdrive/ncdata/nextcloud.log at /var/www/nextcloud/lib/private/Log/File.php#136”,“userAgent”:“–”,“version”:“13.0.4.0”}
{“reqId”:“sOBeYejkcYSFQZGYlsVg”,“level”:3,“time”:“2018-07-23T16:40:05+00:00”,“remoteAddr”:“”,“user”:“–”,“app”:“PHP”,“method”:“–”,“url”:“–”,“message”:“chmod(): No such file or directory at /var/www/nextcloud/lib/private/Log/File.php#137”,“userAgent”:“–”,“version”:“13.0.4.0”}
data dir not found

Ok, then let’s just do

sudo su
find /media/USBDrive/ncdata -type f -print0 | xargs -0 chmod 0640
find /media/USBDrive/ncdata -type d -print0 | xargs -0 chmod 0750

this leads to

pi@nextcloudplus:~ $ sudo su
root@nextcloudplus:/home/pi# find /media/USBDrive/ncdata -type f -print0 | xargs -0 chmod 0640
find: ‘/media/USBDrive/ncdata’: Datei oder Verzeichnis nicht gefunden
chmod: fehlender Operand nach „0640“
„chmod --help“ liefert weitere Informationen.
root@nextcloudplus:/home/pi# find /media/USBDrive/ncdata -type d -print0 | xargs -0 chmod 0750
find: ‘/media/USBDrive/ncdata’: Datei oder Verzeichnis nicht gefunden
chmod: fehlender Operand nach „0750“
„chmod --help“ liefert weitere Informationen.

But using USBdrive leads to:

root@nextcloudplus:/media/USBdrive# find /media/USBdrive/ncdata -type f -print0 | xargs -0 chmod 0640
chmod: fehlender Operand nach „0640“
„chmod --help“ liefert weitere Informationen.

But I can cd to the directory you mentioned:

root@nextcloudplus:/media/USBdrive/ncdata# ls
root@nextcloudplus:/media/USBdrive/ncdata#

root@nextcloudplus:/media/USBdrive# ls
ncdata ncdata-07-22-18

ok, it’s empty… where are your data files? probably in the other USB drive (/media/USBDrive1 maybe).

In any case, like I said before, let’s try not to use the USBDrive names, but the labels, as found in

ls -l /media

Also, NTFS is not supported so you will have to do hackery with permissions

I have no clue where my data files are. The other USB drive was only connected for some seconds, I detached it, restarted nextcloud and NCP was running for ~2 weeks.

Then I tried to use the label name by changing the data directory as described above.
As it did not work, I changed back. Does the NCP panel delete data on the USB drive when setting new data directories?

And if everything is broken and deleted now, what to do best?

root@nextcloudplus:/home/pi# ls -l /media
insgesamt 16
drwxr-xr-x 1 root root 42 Jul 22 16:51 myCloudDrive
lrwxrwxrwx 1 root root 19 Jul 22 16:52 USBdrive → /media/myCloudDrive

And what about the other folder in the USBdrive:

root@nextcloudplus:/media/myCloudDrive# ls
ncdata ncdata-07-22-18
root@nextcloudplus:/media/myCloudDrive# cd ncdata-07-22-18
root@nextcloudplus:/media/myCloudDrive/ncdata-07-22-18# ls
access.log files_external ncp tmp
AnjaFischer FlorianSchoenl news updater.log
appdata_ocx378o6vm14 index.html nextcloud.log updater-ocx378o6vm14
error.log MariusRadtke pi

Seems like you found your data. Probably there was some problem with the operation, such as permissions, and the operation did not complete. You can delete the empty folder and rename ncdata-07-22-18 to ncdata.

That should fix it for you