Cannot recover after HDD crash

I was running nextcloud on Raspberry Pi and data was on NAS.
Recently my NAS was crashed and I couldn’t rescue the data.

The problem is once I replaced NAS to new one, Nextcloud failed to do anything.
From browser access, it said “internal server error”.
Then OCC said “you data directory is invalid”.
So I copied /var/www/html/nextcloud/data to the new NAS and found that it lacks “.ocdata”, which I cannot find it the original nextcloud data folder.
Is there anyway to recreate ocdata or entire data directory?

Hello Druoh, there are many post about the " .ocdata " file. This is a empty file that resides in the root of your userdata folder.

If /var/www/html/nextcloud/data is your " DATADIRECTORY " in your config.php you can create the file there with

sudo -u www-data touch .ocdata

where www-data is the apache user.

best of luck

Vincent, thank you about your help.
Now I can run occ, and occ check does not return anything.

However, Internal Sever Error persists while accessing from browser.
It looks some connection there through desktop app, and a few folders were created. Server returns 403 forbidden when a new file was added.

I think you should share more.

You NAS crashed ok

What data was on it?
A:) Nextcloud server
B:) Nextcloud USER data a.k.a datadirectory
C:) ALL the above

Where was the NAS mounted?
A:) /mnt/data
B:) /media/data
C:) different …

what is the contents of config.php.

Server is /var/www/html/nextcloud/
and data was on NAS.
As NAS is mounted as /media/pi/nas/

in the /media/pi/nas, I can find:
and some user related folders created once nextcloud somehow started yesterday.

config.php is:
GNU nano 3.2 config.php

<?php $CONFIG = array ( 'instanceid' => 'ocf6796ow8ds', 'passwordsalt' => 'uiNDE2D2tspSucSbulcWTp9GNWcnMV', 'secret' => 'SqSTbqC53W7dLGi4PK0uHTLFbUYVUqfXN7Cj8Vroyb85Y0sS', 'trusted_domains' => array ( 0 => '', ), 'datadirectory' => '/media/pi/nas', 'dbtype' => 'mysql', 'version' => '', 'overwrite.cli.url' => '[](', 'dbname' => 'nextcloud', 'dbhost' => 'localhost', 'dbport' => '', 'dbtableprefix' => 'oc_', 'mysql.utf8mb4' => true, 'dbuser' => 'USER_NAME', 'dbpassword' => 'PASSWORD', 'installed' => true, 'maintenance' => false, ); Thank you for your guidance! 2023年8月5日(土) 21:55 Vincent Stans via Nextcloud community <[](>:

If you have no backup of your crashed NAS you lost all userdata.

no way to recover the files.

you could try occ files:scan to clean the database and start as new with all users intact.

Using the occ command — Nextcloud latest Administration Manual latest documentation

also make sure you have the correct permissions set on your new NAS

Right, I understand that I cannot recover the files. But all users have their own, so it should be fine once nextcloud resumed running.

I run
sudo -u www-data php /var/www/html/nextcloud/occ files:scan
I got
Starting scan for user 1 out of 8 (USER)
Home storage for user USER not writable

Although the data folder is:
drwxrwx— 2 www-data www-data
which I believe www-data has the correct permission.
(I just double-checked www-data is owner of apache)

files:cleanup or maintenance:repair
Didn’t help either.

you may need to create the username folders manually
I’m not in a state to test this but if you create a username folder USER and scan only for that user does it return a error.

are users able to login?

you permissions are correct.

When users connected to Nextcloud with desktop app, the username folders are created with only cache folder exist in it.
With information on other threads, I created files folder in the username folders.
Now at least files:scan works, but internal server error persists and no login page shows up.

While I checked /var/log/apache2/error.log, I found that there is error on finding avatar.

stat: cannot stat ‘/media/pi/nas/appdata_ocf6796ow8ds/avatar/USER/avatar.128.png’: No such file or directory

I created /media/pi/nas/appdata_ocf6796ow8ds/avatar/USER/ and run occ files:scan-app-data.
Then, nextcloud finally start working partially—
(1) browser works and I can login,
(2) files can be synced, if it is newly added. The files supposed to be on the data folder don’t sync.

It sounds like I need to clear what nextcloud think it has on the data folder.