Help with data directory permissions

Nextcloud version: Nextcloud Hub 4 (26.0.0)
Operating system and version: Raspberry Pi OS: Bullseye
Apache or nginx version: Apache/2.4.56 (Debian)
PHP version: PHP 8.1.17

Hello, this is my first time downloading and using Nextcloud.

I have a fresh installation of Nextcloud on my Raspberry Pi. I shifted the data directory to /mnt/MAGI, where my originally exFAT hard drive was. I shifted the contents elsewhere, unmounted it and formatted it to btrfs. I moved the contents back in and remounted, only to find that there’s errors.

Nextcloud tells me that

  • It was not possible to execute the cron job via CLI. The following technical errors have appeared:
    • 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 web server write access to the root directory.
  • Last background job execution ran 4 hours ago. Something seems wrong.

Background jobs is set to cron, 4 hours ago it was working(before I formatted my hard drive). My guess is that everything is linked to Apache not having the right permissions to the data directory. However, that’s not the case.

config.php contents:

exuberantWitness@Genesis:~ $ sudo cat /var/www/html/nextcloud/config/config.php
$CONFIG = array (
  'instanceid' => '(instanceid)',
  'passwordsalt' => '(passwordsalt)',
  'secret' => '(secret)',
  'trusted_domains' =>
  array (
    0 => '(ip)',
  'datadirectory' => '/mnt/MAGI/nextcloud/data',
  'dbtype' => 'mysql',
  'version' => '',
  'overwrite.cli.url' => 'http://(ip)/nextcloud',
  'dbname' => 'nextclouddb',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'nextclouduser',
  'dbpassword' => '(pass)',
  'installed' => true,
  'maintenance' => false,

Directory permissions:

exuberantWitness@Genesis:~ $ sudo ls -l /mnt
total 16
drwxrwxrwx 1 www-data www-data 18 Apr  1 07:04 MAGI
exuberantWitness@Genesis:~ $ sudo ls -l /mnt/MAGI/
total 0
drwxrwxrwx 1 www-data www-data 8 Apr  1 06:28 nextcloud
exuberantWitness@Genesis:~ $ sudo ls -l /mnt/MAGI/nextcloud/
total 0
drwxrwx--- 1 www-data www-data 164 Apr  1 03:43 data
exuberantWitness@Genesis:~ $ sudo ls -al /mnt/MAGI/nextcloud/data
total 20
drwxrwx--- 1 www-data www-data   164 Apr  1 03:43 .
drwxrwxrwx 1 www-data www-data     8 Apr  1 06:28 ..
drwxr-xr-x 1 www-data www-data    80 Apr  1 03:43 appdata_oc9lamxyzdzz
drwxr-xr-x 1 www-data www-data    26 Apr  1 03:43 files_external
-rwxr-xr-x 1 www-data www-data   542 Mar 31 14:26 .htaccess
-rwxr-xr-x 1 www-data www-data     0 Mar 31 14:26 index.html
-rw-r----- 1 www-data www-data 15718 Apr  1 07:45 nextcloud.log
-rwxr-xr-x 1 www-data www-data     0 Mar 31 14:26 .ocdata

I’ve tried sudo chown -R www-data:www-data /mnt/MAGI/nextcloud/data, but the errors are still there. The hard drive is working, I can create files in it(via sudo) and I can upload files to it(via nextcloud). It might be related to how Nextcloud’s docs says stop Apache before moving the data directory, but I didn’t. How do I fix this?

Hi - I’m sorry to see your query got overlooked. Are you still having this issue? Let us know and we’ll do our best to assist.

To clarify:

  • Are you saying that you have this error and yet everything in Nextcloud is actually functioning?
  • Are there any other errors in your nextcloud.log?
  • Where was your datadirectory previously?
  • How, precisely, did you transfer the data around?
  • I’m a bit confused because you call this a fresh install, but than refer to need to move the datadirectory. Was it not actually a new installation?