Data directory invalid after installing 2nd USB SDD for backup

Nextcloud version 13.0.1
Operating system and version: NextCloudPi v0.53.27, Debian 9.4 on a Raspberry Pi 3b
Apache or nginx version: Apache 2.4.25 (Raspbian)
PHP version: 7.0.27-0+deb9u1

Hello all,

I have installed a 2nd drive (HDD) to backup onto. I made the following steps so far:

1.) putting NC into maintenance mode
2.) unmounting /dev/sda1 (mounted at /media/myCloudDrive), RAID 1 hardware controlled
3.) unplugging the RAID
4.) plugging in the backup HDD
5.) using nc-format-USB to properly format the backup HDD (RAID was unplugged, of course)
6.) plugging the RAID back in
7.) setting up nc-automount
8.) did a reboot
9.) $lsblk showed that my NC RAID was now /dev/sdb1, but properly mounted to /media/myCloudDrive. Backup drive is /dev/sda1 now mounted under /media/myCloudBACKUP
10.) $sudo -u www-data /var/www/nextcloud/occ maintenance:mode --off returned the following error:

 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/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}<

A $sudo ls -la /media/myCloudDrive/ncdata returns
-rw-r--r-- 1 www-data www-data 0 Mar 18 22:48 .ocdata

What went wrong here? Any help is appreciated!

Is this the first time you’ve seen this error? Yes

EDIT: That’s funny. As soon as I umount /dev/sdb1 (which is the backup drive), everything goes back to normal operation! As soon as I re-mount it, the above error occurs. I have now tried to mount the cloud drive to /dev/sda and the backup drive to /dev/sdb by rebooting and then hotplugging the backup drive. Succeeded. But here’s what happens when I run nc-backup:

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”:“7B1BeZ0aEVZ9oMnnO8fT”,“level”:3,“time”:“2018-04-14T14:39:34+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.1.1”}
{“reqId”:“7B1BeZ0aEVZ9oMnnO8fT”,“level”:3,“time”:“2018-04-14T14:39:34+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.1.1”}

Fixed it! I had to manually edit the config.php in /var/www/nextcloud/config/config.php, as it still was set to “myUSBDrive” - I guess changing when the ncdatadir via ncp-config is returning an error, nothing is touched (see above). Maybe in the future it will be possible to make changing the datadir (for whatever reason) less painful on an already - configured system. nachoparker led me in the right direction here: https://www.reddit.com/r/NextCloud/comments/8c7b21/data_directory_invalid_after_installing_2nd_usb/dxctrca/

Hi, kannst du mir sagen wie du 2 Platten als raid in NCpi angebunden hast ?
ICh kann nur eine Platte mounten und nutzen. Sobald ich eine 2 Platte per USB anstecke … werden mir keine PLatten mehr angezeigt.

thx
Gordon