syncloud / platform

Run popular services on your device with one click
https://syncloud.org
GNU General Public License v3.0
400 stars 40 forks source link

[nextcloud] automatic recover of appdata dir after a crash #419

Closed cyberb closed 5 years ago

cyberb commented 5 years ago

We should implement an automatic recover of appdata dir in case it is corrupted. Recovery command is this:

snap run nextcloud.occ config:system:delete instanceid

Need to find oit how to detect corruption state, probably occ has some options for that.

To reproduce remove js dir from appdata, for example:

/opt/disk/external/nextcloud/appdata_oc4gxcge6xq4/js

See this issue for more details: https://github.com/syncloud/platform/issues/418

klmhsb42 commented 5 years ago

Is it normal, that I can't access my files in nextcloud anymore after this? Also, I can't create new files. For PDF it says

PDF.js v1.9.426 (build: 2558a58d)
Message: Unexpected server response (503) while retrieving PDF "https://nextcloud.name.syncloud.it/remote.php/webdav/Nextcloud%20Manual.pdf".
cyberb commented 5 years ago

Could you send logs to support?

klmhsb42 commented 5 years ago

done

cyberb commented 5 years ago

Cannot see any nextcloud exception in the log.

Could you post the output for this command:

ls -la /opt/disk/external/nextcloud/
klmhsb42 commented 5 years ago
total 96
drwxrwx--- 8 nextcloud nextcloud  4096 Sep 13 06:18 .
drwxr-xr-x 9 root      root       4096 Sep 11 19:53 ..
-rw-r--r-- 1 nextcloud nextcloud   324 Aug 30 14:51 .htaccess
-rw-r--r-- 1 nextcloud nextcloud     0 Sep 11 19:48 .ocdata
drwxr-xr-x 7 nextcloud nextcloud  4096 Sep 13 06:18 appdata_oc2nqnjcpo05
drwxr-xr-x 7 nextcloud nextcloud  4096 Aug 30 15:30 appdata_oczo0ea8c1k9
drwxr-xr-x 2 nextcloud nextcloud  4096 Sep 12 15:45 files_external
-rw-r--r-- 1 nextcloud nextcloud     0 Aug 30 14:51 index.html
drwxr-xr-x 3 nextcloud nextcloud  4096 Sep 11 19:43 username2
drwxr-xr-x 3 nextcloud nextcloud  4096 Sep  9 14:55 username1
drwxr-xr-x 2 nextcloud nextcloud 61440 Sep 14 07:13 tmp
cyberb commented 5 years ago

Permissions are fine, could you run this:

snap run nextcloud.occ files:scan --all
klmhsb42 commented 5 years ago
Starting scan for user 1 out of 4 (username3)
Home storage for user username3 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 4 (username2)
Home storage for user username2 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 4 (username1.2)
Starting scan for user 4 out of 4 (username1)
Home storage for user username1 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     |
+---------+-------+--------------+
klmhsb42 commented 5 years ago

I created users in nextcloud, which are not all in LDAP

cyberb commented 5 years ago

Should be fine as Nextcloud supporta both ldap and non ldap users. It is strange that scan reported permission problems, could you run more verbose mode:

snap run nextcloud.occ files:scan --all -vvv

Also do you actually have any files in one of your user dirs?

ls -la /data/nextcloud/[user]/files
klmhsb42 commented 5 years ago

First command says same as before (no permission). Second shows there is only /[user]/cache folder which is empty.

cyberb commented 5 years ago

Did you have files before the crash? Is this the same list of users on the filesystem? What this command shows:

ls -la /data

What do you see on internal storage:

ls -la /opt/disk/internal/nextcloud/

Did you activate/deactivate external disk?

klmhsb42 commented 5 years ago
cyberb commented 5 years ago

I see, can you run disk check on your external disk as file system may have been corrupted by the restart/shutdown, you need to find a disk device name:

mount | grep disk
/dev/sdb1 on /opt/disk/external type ext4 (rw,nosuid,relatime,data=ordered)

In my case it is /dev/sdb1, the check disk command is then:

fsck /dev/sdb1
klmhsb42 commented 5 years ago

It says:

mount | grep disk
/dev/sda1 on /opt/disk/external type ext4 (rw,nosuid,relatime,stripe=8191,data=ordered)
fsck /dev/sda1
fsck from util-linux 2.25.2
e2fsck 1.42.12 (29-Aug-2014)
/dev/sda1 is mounted.
e2fsck: Cannot continue, aborting.
cyberb commented 5 years ago

Right, could you deactivate it settings?

klmhsb42 commented 5 years ago

Yes, but still can't create new files. I could also re-install nextcloud, I don't have any important data on it. I'm just trying to help to find the bug to allow a complete recovering.

klmhsb42 commented 5 years ago

Could it have also changed the rights? As suggested here https://docs.nextcloud.com/server/13/admin_manual/maintenance/manual_upgrade.html?highlight=manual%20upgrade With

chown -R www-data:www-data nextcloud
find nextcloud/ -type d -exec chmod 750 {} \;
find nextcloud/ -type f -exec chmod 640 {} \;

Anyway, by running this, I crashed it and just re-installed nextcloud. So I will not be able to make further tests...

cyberb commented 5 years ago

Syncloud uses nextcloud user instead of www-data, let's close this for now and reopen if happens again.