Data directory/.ocdata error after migration

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, 29.0.5): 27
Operating system and version (eg, Ubuntu 29.04): Debian Stable
Apache or nginx version (eg, Apache 2.4.25): 2.4.59
PHP version (eg, 8.3): 8.2

The issue you are facing:

After following the documentaiton for migrating from one instance to another I am running into an error with the .ocdata file that seems to be a permission 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 web server write access to the root directory. See Introduction — Nextcloud latest Administration Manual latest documentation "

my data directory is located in /home/user/data
my nextcloud directory is located in /var/www/html/nextcloud

This was the same config as my previous install. In fact, to do the migration i put nextcloud in maintenance mode, copied the entire nextcloud and data directories, dumped the database, and moved everything over to the new install.

The .ocdata file is present in /data, I granted ownership to both the /nextcloud and /data folders to www-data and I did chmod 770 to the /data folder

However when i do
“sudo -u www-data touch /home/user/data/.ocdata”
I get a permission denied error still.

I tried chmod 777 just in case and had the same effect.

I assume I just forgot a step somewhere. Any help is appreciated.

Searching this error on the forums seems to indicate this is mostly a problem with people using remote storage. But my issue is occurring on a vanilla install on the same local hard drive as the OS.

Please provide the output of:

ls -ld /home/user/data/.ocdata
ls -ld /home/user/data
ls -ld /home/user

Also, any symbolic links involved?

1 Like

no symbolic links

whats weird is www-data can touch anything in the /var/www/html/nextcloud folder but not in the /home/user/data folder.

-rw-r----- 1 www-data www-data 0 Aug 11 2023 /home/user/data/.ocdata
drw-rws— 1 www-data www-data 378 Jun 1 15:03 /home/user/data
drwx------ 1 user user 438 Jun 1 15:01 /home/user

to change ownership I had done this:
chown -R www-data:www-data /home/user/data
find /home/user/data/ -type d -exec chmod 750 {} ;
find /home/user/data/ -type f -exec chmod 640 {} ;

I had to edit the previous post because I accidentally polled a test folder I was in. I updated the previous post to the actual folder I am trying to get to work

The parent directory permissions must at least allow x for all.

So /home/ and /home/user need to be something like 711 (bare minimum) or 755.

Also data/ is missing x as well. Similar fix needed.

1 Like

ah, yes it works now thanks. I didn’t think the whole folder hierarchy needed more permissions if i gave ownership of a folder to www-data.

1 Like

lol I am still getting this error in the nextcloud admin page

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. See Introduction — Nextcloud latest Administration Manual latest documentation<

never mind it went away like magic, still solved

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.