Data directory is invalid Please check that the data directory contains a file ".ocdata" in its root. - .ocdata file gets delete every hour

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 _13.0.5:
Operating system and version (CentOS 7.5.1804 ):
Apache or nginx version (nginx/1.12.2):
PHP version (PHP 7.1.20):

The issue you are facing: I’m facing a very weird problem and even after googling and reading the forums for several days, I cannot find the underlying cause.
I have configured nextcloud with nginx,postgreSQL,nfs share data directory with selinux. I have given right permissions to the directory dir.

NFS share :
172.16.xx.x/var/preserve/shared/Users/data /usr/share/nginx/html/nextcloud/data
fstab : mounted with below
nfs nosharecache,context=“system_u:object_r:httpd_sys_rw_content_t:s0” 0 0
SElinux permission:

ls -lZd nextcloud/
drwxr-xr-x. nginx nginx unconfined_u:object_r:httpd_sys_content_t:s0 nextcloud/

[root@nc html]# ls -lZd nextcloud/data/
drwxrwx—. nginx nginx system_u:object_r:httpd_sys_rw_content_t:s0 nextcloud/data/

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

Steps to replicate it:

  1. Access https://nextcloud (works fine when .ocdata is placed in data directory)
  2. but every hour eg. 9:00 , 10:00, 11:00 .ocdata file gets deleted automatically - there is no cron running which is very strange how it gets deleted automatically
  3. Have to mannually touch .ocdata and give permissions but still get delete every hour ( this is NFS share as mentioned above)

The output of your Nextcloud log in Admin > Logging:

Nothing indicating related to data dir or .ocdata in logs

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

<?php
$CONFIG = array (
  'instanceid' => 'oc902pr5zcdc',
  'passwordsalt' => 'X2wTe4LPCU3WExxxxxxxxxx',
  'secret' => 'khBzg2Xel9xBYcF3ad6tCzX/dN2sWQDwxxxxxxxxxxxxxx',
  'trusted_domains' =>
  array (
    0 => 'ab.xyz.com',
  ),
  'datadirectory' => '/usr/share/nginx/html/nextcloud/data',
  'overwrite.cli.url' => 'https:/ab.xyz.com',
  'dbtype' => 'pgsql',
  'version' => '13.0.5.2',
  'dbname' => 'nextcloud_xx',
  'dbhost' => '172.16.x.x:5432',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'dbuser' => 'nc_xxx',
  'dbpassword' => 'xxxx',
  'installed' => true,
);

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

Error LOGS:::
2018/08/23 10:12:46 [error] 2472#0: *1076 access forbidden by rule, client: 172.16.158.xx, server: ab.xyz.com, request: "GET /data/.ocdata?t=1535015565578 HTTP/1.1", host: "ab.xyz.com"
2018/08/23 10:12:51 [error] 2471#0: *1104 access forbidden by rule, client: 172.16.158.xx, server: ab.xyz.com, request: "GET /data/.ocdata?t=1535015570172 HTTP/1.1", host: "ab.xyz.com"
2018/08/23 10:15:35 [error] 2472#0: *1158 access forbidden by rule, client: 172.16.158.57, server: ab.xyz.com, request: "GET /data/.ocdata?t=1535015734058 HTTP/1.1", host: "ab.xyz.com"

Access LOGS::
172.16.158.57 - - [23/Aug/2018:09:58:18 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 547 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:09:58:49 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 547 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:09:59:19 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 547 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:09:59:49 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 547 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:00:14 +0100] "GET / HTTP/1.1" 503 7537 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:00:14 +0100] "GET /?v=4 HTTP/1.1" 503 7537 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:00:14 +0100] "GET /cron.php HTTP/1.1" 503 7537 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:15 +0100] "POST /heartbeat HTTP/1.1" 503 7537 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:31 +0100] "GET / HTTP/1.1" 302 5 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:31 +0100] "GET /apps/files/ HTTP/1.1" 200 37013 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:31 +0100] "GET /css/core/0cac-4eb8-jquery-ui-fixes.css?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:31 +0100] "GET /css/files_trashbin/1980-4eb8-trash.css?v=198068b3-4 HTTP/1.1" 200 161 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:31 +0100] "GET /css/core/0cac-4eb8-jquery.ocdialog.css?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:32 +0100] "GET /css/core/0cac-4eb8-share.css?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:32 +0100] "GET /css/files_texteditor/21f4-4eb8-merged.css?v=21f47a5b-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:32 +0100] "GET /js/core/merged-template-prepend.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:32 +0100] "GET /css/files_sharing/35c3-4eb8-mergedAdditionalStyles.css?v=35c36e89-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:32 +0100] "GET /css/files/4fda-4eb8-merged.css?v=4fda350b-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:32 +0100] "GET /js/core/merged-share-backend.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:33 +0100] "GET /js/files/merged-index.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:33 +0100] "GET /js/notifications/merged.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:33 +0100] "GET /css/core/0cac-4eb8-server.css?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:33 +0100] "GET /js/comments/merged.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:33 +0100] "GET /css/comments/1980-4eb8-autocomplete.css?v=198068b3-4 HTTP/1.1" 200 424 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:34 +0100] "GET /js/files_texteditor/merged.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:34 +0100] "GET /js/files_versions/merged.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:34 +0100] "GET /js/core/merged.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:34 +0100] "GET /js/gallery/scripts-for-file-app.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:34 +0100] "GET /apps/theming/styles?v=4 HTTP/1.1" 200 861 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:34 +0100] "GET /js/systemtags/merged.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:35 +0100] "GET /js/files_sharing/additionalScripts.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:35 +0100] "GET /js/activity/activity-sidebar.js?v=43d615cf-4 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:35 +0100] "GET /css/core/0cac-4eb8-systemtags.css?v=43d615cf-4 HTTP/1.1" 200 385 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:35 +0100] "GET /apps/theming/js/theming?v=4 HTTP/1.1" 200 234 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:35 +0100] "GET /apps/theming/logo?v=4 HTTP/1.1" 200 3351 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:35 +0100] "GET /cron.php HTTP/1.1" 200 31 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:36 +0100] "GET /apps/systemtags/lastused HTTP/1.1" 200 2 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:36 +0100] "GET /ocs/v2.php/apps/notifications/api/v2/notifications HTTP/1.1" 200 547 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:36 +0100] "GET /apps/encryption/ajax/getStatus HTTP/1.1" 200 77 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:36 +0100] "PROPFIND /remote.php/webdav/ HTTP/1.1" 207 3383 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:36 +0100] "GET /apps/gallery/config?extramediatypes=1 HTTP/1.1" 200 102 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:36 +0100] "GET /apps/theming/img/core/filetypes/text.svg?v=4 HTTP/1.1" 200 295 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"
172.16.158.57 - - [23/Aug/2018:10:12:37 +0100] "GET /index.php/apps/files/ajax/getstoragestats.php?dir=%2F HTTP/1.1" 200 262 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0" "-"

resolved the issue - immune the file .ocdata - I don’t think so this is solution to the problem but it fixes my issue.
chattr +i .ocdata ( now it doesnt get delete automaticaly)