Restoring data after HDD damage

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:

Server details

Nextcloud version (eg, 20.0.5): 21.0.2
Operating system and version (eg, Ubuntu 20.04): Ubuntu 20.04.02
Apache or nginx version (eg, Apache 2.4.25): nginx/1.18.0
PHP version (eg, 7.4): 7.4.19

The issue you are facing:
My HDD was damaged, I replace it by the new one. Make file .ocdata in data folder, gave permission to user www-data:www-data. Copy all files in data directory from client PC.

After that error: “Make sure that a file “.ocdata” exists in the root directory of the data directory.” has gone. I can see files and folder in the browser, but i when I want to see pdf file for example, I receive error massage:

ERROR

PDF.js v2.5.207 (build: 0974d6052)
Message: Missing PDF “https://nextcloud.mycloudhome.ru/remote.php/dav/files/admin/%D0%94%D0%BE%D0%B3%D0%BE%D0%B2%D0%BE%D1%80%20%D0%B4%D0%BE%D0%BB%D0%B5%D0%B2%D0%BE%D0%B3%D0%BE%20%D1%83%D1%87%D0%B0%D1%81%D1%82%D0%B8%D1%8F_20200325_145500.pdf”.

Please help with this problem.

I

did you just crash the data disk and the system and database is on a different drive? Question is more if you restore an existing setup or if you start with a new one…

Database on MySQL, it’s ok, system on another drive in docker container , so I’ve lost only data folder with users datafiles

In so case you need to tell the database that all your files are gone :slight_smile:

Let the OCC command do its wonder by scanning your data folder; Using the occ command — Nextcloud latest Administration Manual latest documentation

I am not 100% sure but I believe that should take care of those errors - you can run occ files:cleanup. It states;

files:cleanup tidies up the server’s file cache by deleting all file entries that have no matching entries in the storage table.

Maybe also try running occ files:scan --all

I’ve input

docker exec --user abc nextcloud php /config/www/nextcloud/occ files:scan --all

it shows

Home storage for user admin not writable
Make sure you’re running the scan command only as the user the web server runs as

Try running

docker exec -it -u www-data nextcloud php occ files:scan --all

The error is clear :slight_smile: unless you changed the user setting in the dockerfile?

I tried that already(

unable to find user www-data: no matching entries in passwd file

So I just downloaded nextcloud docker as it is as of today.

Try running the command without the user specification; like
docker exec -it nextcloud php occ files:scan --all

Then you should see something like this:

$ docker exec -it nextcloud php occ files:scan --all
Output:

Console has to be executed with the user that owns the file config/config.php
Current user id: 0
Owner id of config.php: 33
Try adding 'sudo -u #33' to the beginning of the command (without the single quotes)
If running with 'docker exec' try adding the option '-u 33' to the docker command (without the single quotes)

So what I did then was:
docker exec -it -u 33 nextcloud php occ files:scan --all

Then, I saw this:

Starting scan for user 1 out of 1 (denNorske)
+---------+-------+--------------+
| Folders | Files | Elapsed time |
+---------+-------+--------------+
| 5       | 29    | 00:00:00     |
+---------+-------+--------------+

Can you try and see if you get the same prompt, and if that will work for you?

For both ways

i had

Could not open input file: occ

(((

1 Like

When I do that:

sa@homesrv:~$ docker exec --user abc nextcloud php /config/www/nextcloud/occ files:scan --all
Starting scan for user 1 out of 3 (admin)
Home storage for user admin not writable
Make sure you’re running the scan command only as the user the web server runs as
Starting scan for user 2 out of 3 (katya)
Home storage for user katya not writable
Make sure you’re running the scan command only as the user the web server runs as
Starting scan for user 3 out of 3 (sasha)
Home storage for user sasha not writable
Make sure you’re running the scan command only as the user the web server runs as
±--------±------±-------------+
| Folders | Files | Elapsed time |
±--------±------±-------------+
| 0 | 0 | 00:00:00 |
±--------±------±-------------+

I get that output

Can you show the ownership information of your nextcloud directory?

sudo docker exec nextcloud ls . -lsaun

It should spit out the info

Can you show the ownership information of your nextcloud directory?

sudo docker exec nextcloud ls . -lsaun

It should spit out the info

output

4 drwxr-xr-x 1 0 0 4096 Jul 12 19:46 .
4 drwxr-xr-x 1 0 0 4096 Jul 12 19:46 …
0 -rwxr-xr-x 1 0 0 0 Jul 12 04:01 .dockerenv
4 drwxr-xr-x 1 1000 999 4096 Jul 12 04:00 app
4 drwxr-xr-x 1 0 0 4096 Jul 12 04:00 bin
4 drwxr-xr-x+ 11 1000 999 4096 Jul 12 04:01 config
4 drwxrwx— 5 1000 999 4096 Jul 8 09:20 data
4 drwxrwxr-x 1 1000 999 4096 Jul 12 04:00 defaults
0 drwxr-xr-x 5 0 0 340 Jul 12 04:01 dev
4 -rwxrwxr-x 1 0 0 3579 Jul 6 06:31 docker-mods
8 drwxrwxr-x 1 0 0 4096 Jul 12 04:00 etc
4 drwxr-xr-x 2 0 0 4096 Jul 12 04:00 home
4 -rwxr-xr-x 1 0 0 389 Feb 15 21:44 init
4 drwxr-xr-x 1 0 0 4096 Jul 12 04:00 lib
4 drwxr-xr-x 2 0 0 4096 Jul 12 04:00 libexec
4 drwxr-xr-x 5 0 0 4096 Jul 12 04:00 media
4 drwxr-xr-x 2 0 0 4096 Jul 12 04:00 mnt
4 drwxr-xr-x 2 0 0 4096 Jul 12 04:00 opt
0 dr-xr-xr-x 483 0 0 0 Jul 12 04:01 proc
4 drwx------ 2 0 0 4096 Jul 12 04:00 root
4 drwxr-xr-x 1 0 0 4096 Jul 12 04:00 run
4 drwxr-xr-x 1 0 0 4096 Jul 12 04:00 sbin
4 drwxrwxrwx+ 2 775 1000 4096 Jul 11 21:02 shared
4 drwxr-xr-x 2 0 0 4096 Jul 12 04:00 srv
0 dr-xr-xr-x 13 0 0 0 Jul 12 04:01 sys
4 drwxrwxrwt 1 0 0 4096 Jul 12 19:45 tmp
8 drwxrwxr-x 1 0 0 4096 Jul 12 04:00 usr
8 drwxr-xr-x 1 0 0 4096 Jul 12 04:00 var

My data folder on another physical drive (new one), may be there is a problem with rights?