.ocdata missing

Hello,

My NC installation suddenly stopped working. I got the following error when opening the webpage:

Your data directory is invalid
Ensure there is a file called “.ocdata” in the root of the data directory.

Upon inspection of my data folder, this file is clearly present + the permissions seem OK to my (i.e. owned & writable by www-data)
My Nextcloud-data folder:

drwxrwx--- 12 www-data www-data 4.0K Dec 27 09:11 .
drwx------  6 wouter   wouter   4.0K Dec 26 17:57 ..
-rw-rw-r--  1 www-data www-data  542 Nov  9 19:14 .htaccess
-rwxr-x---  1 www-data www-data    0 Nov  9 19:14 .ocdata
drwxrwxr-x 17 www-data www-data 4.0K Oct 16 18:51 appdata_ocvmak4d7qdc
-rw-r-----  1 www-data www-data 7.4K Jun 16  2020 audit.log
drwxrws---  2 www-data www-data 4.0K Apr 27  2018 files
drwxrws---  2 www-data www-data 4.0K Nov  9 19:15 files_external
-rw-rw-r--  1 www-data www-data    0 Nov  9 19:14 index.html
drwxrws---  7 www-data www-data 4.0K Jul 25 11:10 user1
drwxrws---  7 www-data www-data 4.0K May 20  2019 user2
drwxrws---  4 www-data www-data 4.0K Apr 29  2018 news
-rw-r-----  1 www-data www-data  28M Dec 26 17:48 nextcloud.log
-rw-r-----  1 www-data www-data 101M Dec 19 12:00 nextcloud.log.1
-rw-r-----  1 www-data www-data 2.4K Nov 15 14:42 nextcloud.log.2
drwxr-s---  3 www-data www-data 4.0K May  4  2018 rainloop-storage
drwxrws---  4 www-data www-data 4.0K Feb  9  2020 updater-ocvmak4d7qdc
-rw-rw----  1 www-data www-data 225K Feb  9  2020 updater.log
drwxrws---  2 www-data www-data 4.0K Nov 24  2018 var
drwxrwsr-x  8 www-data www-data 4.0K Dec 26 15:54 user3

Here are the last lines of my nextcloud.log:

{"reqId":"ZlEHTwArN1ZojDDYLp1o","level":1,"time":"2020-12-26T16:48:31+00:00","remoteAddr":"","user":"--","app":"cli","method":"","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for local cache","userAgent":"--","version":"19.0.4.2"}
{"reqId":"ZlEHTwArN1ZojDDYLp1o","level":1,"time":"2020-12-26T16:48:34+00:00","remoteAddr":"","user":"--","app":"cli","method":"","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for distributed cache","userAgent":"--","version":"19.0.4.2"}

Output of sudo -u www-data php occ status -vvv

{"reqId":"tzKUKtQE2UUDD5buRCUD","level":1,"time":"2020-12-27T08:52:37+00:00","remoteAddr":"","user":"--","app":"cli","method":"","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for local cache","userAgent":"--","version":"19.0.4.2"}
{"reqId":"tzKUKtQE2UUDD5buRCUD","level":1,"time":"2020-12-27T08:52:37+00:00","remoteAddr":"","user":"--","app":"cli","method":"","url":"--","message":"Memcache \\OC\\Memcache\\APCu not available for distributed cache","userAgent":"--","version":"19.0.4.2"}
{"reqId":"tzKUKtQE2UUDD5buRCUD","level":0,"time":"2020-12-27T08:52:38+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCP\\Files::preWrite: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"--","version":"19.0.4.2"}
{"reqId":"tzKUKtQE2UUDD5buRCUD","level":0,"time":"2020-12-27T08:52:38+00:00","remoteAddr":"","user":"--","app":"no app in context","method":"","url":"--","message":"Deprecated event type for \\OCP\\Files::preCreate: Symfony\\Component\\EventDispatcher\\GenericEvent","userAgent":"--","version":"19.0.4.2"}
An unhandled exception has been thrown:
RuntimeException: Could not get appdata folder in /var/www/nextcloud/lib/private/Files/AppData/AppData.php:94
Stack trace:
#0 /var/www/nextcloud/lib/private/Files/AppData/AppData.php(110): OC\Files\AppData\AppData->getAppDataRootFolder()
#1 /var/www/nextcloud/lib/private/Files/AppData/AppData.php(157): OC\Files\AppData\AppData->getAppDataFolder()
#2 /var/www/nextcloud/apps/text/lib/Service/DocumentService.php(114): OC\Files\AppData\AppData->newFolder('documents')
#3 [internal function]: OCA\Text\Service\DocumentService->__construct(Object(OCA\Text\Db\DocumentMapper), Object(OCA\Text\Db\StepMapper), Object(OC\Files\AppData\AppData), NULL, Object(OC\Files\Node\LazyRoot), Object(OC\Memcache\Factory), Object(OC\AppFramework\Logger), Object(OC\Share20\Manager), Object(OC\AppFramework\Http\Request), Object(OC\DirectEditing\Manager), Object(OC\Lock\MemcacheLockingProvider))
#4 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(84): ReflectionClass->newInstanceArgs(Array)
#5 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(101): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#6 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Text\\Servic...')
#7 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(414): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Text\\Servic...')
#8 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(385): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Text\\Servic...')
#9 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(71): OC\AppFramework\DependencyInjection\DIContainer->query('OCA\\Text\\Servic...', true)
#10 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(101): OC\AppFramework\Utility\SimpleContainer->buildClass(Object(ReflectionClass))
#11 /var/www/nextcloud/lib/private/AppFramework/Utility/SimpleContainer.php(116): OC\AppFramework\Utility\SimpleContainer->resolve('OCA\\Text\\Comman...')
#12 /var/www/nextcloud/lib/private/AppFramework/DependencyInjection/DIContainer.php(414): OC\AppFramework\Utility\SimpleContainer->query('OCA\\Text\\Comman...')
#13 /var/www/nextcloud/lib/private/ServerContainer.php(133): OC\AppFramework\DependencyInjection\DIContainer->queryNoFallback('OCA\\Text\\Comman...')
#14 /var/www/nextcloud/lib/private/Console/Application.php(221): OC\ServerContainer->query('OCA\\Text\\Comman...')
#15 /var/www/nextcloud/lib/private/Console/Application.php(136): OC\Console\Application->loadCommandsFromInfoXml(Array)
#16 /var/www/nextcloud/console.php(99): OC\Console\Application->loadCommands(Object(Symfony\Component\Console\Input\ArgvInput), Object(Symfony\Component\Console\Output\ConsoleOutput))
#17 /var/www/nextcloud/occ(11): require_once('/var/www/nextcl...')
#18 {main}{"reqId":"tzKUKtQE2UUDD5buRCUD","level":3,"time":"2020-12-27T08:52:38+00:00","remoteAddr":"","user":"--","app":"PHP","method":"","url":"--","message":"fopen(/srv/95f862b3-d8fc-49b3-9a0a-f3ae832f881f/Nextcloud-data/nextcloud.log): failed to open stream: Permission denied at /var/www/nextcloud/lib/private/Log/File.php#84","userAgent":"--","version":"19.0.4.2"}

(the same error occurs when doing files:scan -all or maintenance:repair or any other occ command)

My installation:

  • Debian 10
  • PHP 7.3
  • Apache 2.4
  • Nextcloud 19.0.4

My config file:

?php
$CONFIG = array (
  'instanceid' => 'xxxxxxxxxxxx',
  'passwordsalt' => 'xxxxxxxxxxxx',
  'secret' => 'xxxxxxxxxxxx',
  'trusted_domains' => 
  array (
    0 => 'xxxxxxxxxxxx',
    1 => 'xxxxxxxxxxxx',
    2 => 'xxxxxxxxxxxx',
  ),
  'datadirectory' => '/srv/95f862b3-d8fc-49b3-9a0a-f3ae832f881f/Nextcloud-data',
  'overwrite.cli.url' => 'xxxxxxxxxxxx',
  'htaccess.RewriteBase' => '/',
  'dbtype' => 'mysql',
  'version' => '19.0.4.2',
  'dbname' => 'nextcloud_db',
  'dbhost' => 'localhost:3306',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'xxxxxxxxxxxx',
  'dbpassword' => 'xxxxxxxxxxxx',
  'installed' => true,
  'mail_from_address' => 'xxxxxxxxxxxx',
  'mail_smtpmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_domain' => 'xxxxxxxxxxxx',
  'mail_smtpauth' => 1,
  'mail_smtphost' => 'xxxxxxxxxxxx',
  'updater.release.channel' => 'stable',
  'maintenance' => false,
  'theme' => '',
  'filelocking.enabled' => true,
  'loglevel' => 0,
  'mail_smtpsecure' => 'ssl',
  'mail_smtpname' => 'xxxxxxxxxxxx',
  'mail_smtppassword' => 'xxxxxxxxxxxx',
  'mail_smtpport' => '465',
  'data-fingerprint' => 'xxxxxxxxxxxx',
  'enable_previews' => true,
  'filesystem_check_changes' => 1,
  'has_rebuilt_cache' => true,
  'mysql.utf8mb4' => true,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'redis' => 
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0,
    'dbindex' => 0,
    'password' => 'xxxxxxxxxxxx',
  ),
  'app_install_overwrite' => 
  array (
    0 => 'files_ebookreader',
    1 => 'radio',
    2 => 'drawio',
    3 => 'passman',
  ),
  'onlyoffice' => 
  array (
    'jwt_header' => 'xxxxxxxxxxxx',
  ),
);

Could anyone help me as I have no clue what’s going on here.
thanx!

1 Like

Hello @wouterve ,

minutes ago I answered another question regarding this issue and kindly ask you to use the search function of this forum.

Did you do any changes to your installation before the message appears?

Please check your setup.

HI @rakekniven

I already tried to change backgroud job from cron to ajax (as refered to this solution) but it throws the same error

Regarding your question: upon the error I did not make any changes that I can remember of. Could restoring from a previos installation solve this (not a real solution…)

Edit:

I think I’ve found the solution: my Nextcloud-data folder is not accessible by the www-data user as this command proves:

$ sudo -u www-data ls /srv/7e5e6032-1f1c-4efc-a74d-f3fe95fe606f/Nextcloud-data/
ls: cannot access '/srv/7e5e6032-1f1c-4efc-a74d-f3fe95fe606f/Nextcloud-data/': Permission denied

Before I mess up permissions, how can I restore this? See my first post, all my files & directories are owned by www-data. The folder itsself is also owned by www-data:

drwxrwx--- 12 www-data www-data 4096 Dec 27 09:11 Nextcloud-data

FYI:
I did encounter a hard drive crash with my Nextcloud-data folder on it. I managed to restore the disk completely on another one and attached the disk to my Odroid. It’s an UNIONFS filesystem so the mount point of my Nextcloud-data remains the same. I did encounter a permission error initially; the folder itself was owned by root:root but I changed it to www-data:www-data whereafter NC did work again until I received above message.

OK the problem has been solved. It turned out the mount point from my UNIONFS system did receive other permissions:

drwx------ 6 user user 4096 Dec 26 17:57 7e5e6032-1f1c-4efc-a74d-f3fe95fe606f

So obviously the folder /srv/7e5e6032-1f1c-4efc-a74d-f3fe95fe606f/Nextcloud-data/ is not accesible by user www-data as the mount point is only accesible by the user owner.

So I changed permission of the mount folder with:

chmod 755 7e5e6032-1f1c-4efc-a74d-f3fe95fe606f/

And after restarting apache all is working again!

Took me a while to figure it out since I was following the wrong path :slight_smile:

To summarize:

When getting an .ocdata not found error whilst it is present, execute the following command to see wether missing permissions is not te cause:

sudo -u www-data ls /path/to/nextcloud-data

If you receive a Permission denied error, you should look further upon the folder permissions.

1 Like

I too get this message constantly:

Your data directory is invalid Ensure there is a file called “.ocdata” in the root of the data directory.

my mount point is /home/user/data ( my account is called user )
i tried chmod 755 -R /home/user/data
and chmod 755 -R /dev/sdb1 for mount point

The .ocdata is in the folder

What am i missing?

First of, you shouldn’t change the permissions of /dev/sdX as this is rhe disk device, not the mount point (I think you received an error)

Can you show the output of this command:

ls -alh /home/user/data

This wil show the current owner of the folder. This should be www-data in order to work.

Hi All,

I’m facing the same issue too.
Mine is in docker setup and whenever I restart the container, I’m now getting “Your data directory is invalid. Ensure there is a file called “.ocdata” in the root of the data directory.”

when I use this command → sudo -u www-data ls /Data/nextcloud/data
I’m getting this → ls: cannot open directory ‘/Data/nextcloud/data’: Permission denied

as soon as I use chmod 755 on the path, it fixed the issue.
But it then broke again whenever I restart the container.
Not sure why this is…any idea? Thanks

1 Like

Difficult to tell at first sight. I assume you are using docker compose for your installation? If so, please provide the docker-compose.yml file (omitting sensitive data).

Also, could you provide the output of the following commands:

docker exec -it <container id> bash

and then

ls -alh /Data/nextcloud/data