[Solved]Owncloud doesn't found .ocdata file after have change the drive

Hi everybody again.
I tried to change the drive where I started to play a little bit with owncloud (I saved just a couple of files to test the functionalities, so nothing important).
The problem is that after I mounted another drive on the same directory used for the old one, when I try to connect to owncloud from the browser it opens an Owncloud page with this kind of error:
“Your data folder is not valid. Check if the folder has a “.ocdata” in its root.”
This is, more or less, the translation from Italian.
I tried to follow this guide: https://www.avoiderrors.com/set-up-raspberry-pi-owncloud-server/ , but it doesn’t work.
Can you help me also with this?

Did you copied the files from old to new drive? Or did you just plugged the new drive in without migrating the files?

The second one!
But, since i formatted the new drive with dietpi-drive_manager, i’m not sure how to copy and past them there.
Keep also in mind I have to mount the new one on the same directory of the old; this means before mounting the new one I have to unmount the old…
Anyway, I’m quite sure the problem is the missing files in the new but, how can I copy them?
And also: when I mounted the old, I did not create or copy from elsewhere, any files to past there…

ok first, remove the new drive and plugin the old one. Ensure all is running fine afterwards.

Now, connect the new drive in addition to a temporary place like /mnt/temp

stop all services

dietpi-services stop

copy all files

cp -p /mnt/old-drive/* /mnt/temp/

hopefully all files are now copied to the new drive. If yes, remove both drives and remount the new one to the original mount point and start all services

dietpi-services start

I followed step by step the suggestion you gave. I’m not sure the files were copied because when I try to open owncloud it gives me the same error.
this is the output after the copy command:

root@DietPi:~# cp -p /mnt/ownclouddrive/* /mnt/temp/
cp: -r not specified; omitting directory '/mnt/ownclouddrive/admin'
cp: -r not specified; omitting directory '/mnt/ownclouddrive/avatars'
cp: -r not specified; omitting directory '/mnt/ownclouddrive/files_external'
cp: -r not specified; omitting directory '/mnt/ownclouddrive/lost+found'

Of course, re-mounting the old drive everything works again well.

ah try cp -p -r to copy all folders

mmm also in this way it doesn’t work…
now the strange thing is that when I gave the copy command nothing is happening:

root@DietPi:~# cp -p -r /mnt/ownclouddrive/* /mnt/temp/
root@DietPi:

From here I continue anyway through the following steps but still, the famous “.ocdata” file is not found…
It’s strange, isn’t it?

The copy command did not show any output usually. It might just hang for a while during data copy takes place.

Can you share the content of the new drive?

how can I see the content?

ls -la /mnt/new-drive

here it is the content of the new drive:

root@DietPi:~# ls -la /mnt/temp
total 340
drwxr-xr-x 6 root     root       4096 Dec 14 13:40 .
drwxr-xr-x 8 root     root       4096 Dec 14 16:52 ..
drwxr-xr-x 5 www-data www-data   4096 Dec  8 20:35 admin
drwxr-xr-x 2 www-data www-data   4096 Dec  7 22:25 avatars
drwxr-xr-x 2 www-data www-data   4096 Dec  7 22:30 files_external
-rw-r--r-- 1 www-data www-data      0 Dec  7 22:21 index.html
drwxrwxr-x 2 www-data www-data  16384 Dec  7 20:27 lost+found
-rw-r----- 1 www-data www-data 310559 Dec 14 13:45 owncloud.log

And this is the content of the old one:

root@DietPi:~# ls -la /mnt/ownclouddrive
total 344
drwxrwx--- 6 www-data www-data   4096 Dec  7 22:30 .
drwxr-xr-x 8 root     root       4096 Dec 14 16:52 ..
-rw-r--r-- 1 www-data www-data    323 Dec  7 22:21 .htaccess
-rw-r--r-- 1 www-data www-data      0 Dec  7 22:21 .ocdata
drwxr-xr-x 5 www-data www-data   4096 Dec  8 20:35 admin
drwxr-xr-x 2 www-data www-data   4096 Dec  7 22:25 avatars
drwxr-xr-x 2 www-data www-data   4096 Dec  7 22:30 files_external
-rw-r--r-- 1 www-data www-data      0 Dec  7 22:21 index.html
drwxrwxr-x 2 www-data www-data  16384 Dec  7 20:27 lost+found
-rw-r----- 1 www-data www-data 309988 Dec  9 21:58 owncloud.log

Looks like the only missing file is “.ocdata” one…
Can I copy it in some way?

I just realize there is also a “.htaccess” missing file…

let’s try again

cp -p -r /mnt/ownclouddrive/{.,}* /mnt/temp

this is the output:

root@DietPi:~# cp -p -r /mnt/ownclouddrive/{.,}* /mnt/temp
cp: will not create hard link '/mnt/temp/ownclouddrive' to directory '/mnt/temp/.'
cp: cannot copy a directory, '/mnt/ownclouddrive/..', into itself, '/mnt/temp'
root@DietPi:~#

I tried anyway to restart all the services and connect through the browser and something change:
now the owncloud page tells me: Your Data directory is not writable by ownCloud
Is it something due to permissions, but where? in the database?

can you share the content of the drive used for owncloud now?

Here it is

root@DietPi:~# ls -la /mnt/ownclouddrive
total 364
drwxr-xr-x 11 root     root       4096 Dec 14 16:52 .
drwxr-xr-x  7 root     root       4096 Dec 15 10:44 ..
-rw-r--r--  1 www-data www-data    323 Dec  7 22:21 .htaccess
-rw-r--r--  1 www-data www-data      0 Dec  7 22:21 .ocdata
drwxr-xr-x  5 www-data www-data   4096 Dec  8 20:35 admin
drwxr-xr-x  2 www-data www-data   4096 Dec  7 22:25 avatars
drwxrwxr-x  9 dietpi   dietpi     4096 Dec  6 17:23 dietpi_userdata
drwxr-xr-x  2 www-data www-data   4096 Dec  7 22:30 files_external
drwxrwxr-x  2 dietpi   dietpi     4096 Aug  8 12:23 ftp_client
-rw-r--r--  1 www-data www-data      0 Dec  7 22:21 index.html
drwxrwxr-x  2 www-data www-data  16384 Dec  7 20:27 lost+found
drwxrwxr-x  2 dietpi   dietpi     4096 Aug  8 12:24 nfs_client
-rw-r-----  1 www-data www-data 311130 Dec 15 11:15 owncloud.log
drwxrwxr-x  2 dietpi   dietpi     4096 Aug  8 12:24 samba
drwxrwx---  4 www-data www-data   4096 Dec 15 10:41 temp

hmm there are way more folders as before. did you copied something in addition? Looks like you copied the content of the entire /mnt/ directory? can you share ls -la /mnt/. Is this the old or the new drive?

root@DietPi:~# ls -la /mnt/
total 28
drwxr-xr-x  7 root   root   4096 Dec 15 15:53 .
drwxr-xr-x 18 root   root   4096 Dec 13 16:18 ..
drwxrwxr-x  9 dietpi dietpi 4096 Dec  6 17:23 dietpi_userdata
drwxrwxr-x  2 dietpi dietpi 4096 Aug  8 12:23 ftp_client
drwxrwxr-x  2 dietpi dietpi 4096 Aug  8 12:24 nfs_client
drwxr-xr-x 11 root   root   4096 Dec 14 16:52 ownclouddrive
drwxrwxr-x  2 dietpi dietpi 4096 Aug  8 12:24 samba

This was the new drive… should I re-format it before coping the file from the old one?

Since I had nothing to lose I tried to format again the new drive and repeated the steps suggested before.
The result is still the same:

Your Data directory is not writable by ownCloud
The permissions can be usually changed <a href="https://doc.owncloud.com/server/10.8/go.php?to=admin-dir_permissions" target="_blank" rel="noreferrer">giving to web server writable access to the root folder</a>.

can you share following

cat /var/www/owncloud/config/config.php | grep datadirectory