Updates removed nextcloud and cannot restore it

Hi everyone ! :slightly_smiling_face:
I’m having a problem with nextcloud, and to be honest I worry quite a bit ! Sorry for bothering, the problem may be obvious and simple but i’m slowly learning,YUNOHOST is my first administration experience !

My YunoHost server

Version: 3.6.5.3
Hardware: Raspberry Pi at home
I have access to my server : Through SSH through the webadmin direct access via keyboard / screen
Are you in a special context or did you perform some particular tweaking on your YunoHost instance ? : no

Description of my issue

My problem seems close to this topic : Updates REMOVED all apps and can't restore but it wasn’t solved, and isn’t exactly the same situation.

When updating my system last month (after quite a long time no doing it tbh…) i could not access nextcloud anymore : the update probably failed. I tried to restore it but it failed, with error messages not explicit enough for me to really get what’s up. Here are the logs : https://paste.yunohost.org/cazekunice.hs
Quick glance at the final error messages here :

2019-10-25 19:22:01,902: ERROR - Unable to restore the app 'nextcloud'
Traceback (most recent call last):
  File "/usr/lib/moulinette/yunohost/backup.py", line 1325, in _restore_app
    env=env_dict)[0]
  File "/usr/lib/moulinette/yunohost/hook.py", line 397, in hook_exec
    raise YunohostError('hook_exec_failed', path=path)
YunohostError: Script execution failed: /tmp/restore8zQjUM/restore

Thank you very much for your help :smile:

Hmokay, there’s link a hundred messages like :

cannot access '/some/file': Structure needs cleaning

The internets says :

That is strongly indicative of file-system corruption. You should unmount, make a sector-level backup of your disk, and then run e2fsck to see what is up. If there is major corruption, you may later be happy that you did a sector-level backup before letting e2fsck tamper with the data.

So ideally you should poweroff your server, do a hard copy of your sd card as a backup, then (ideally using a Linux) run fsck on the corresponding sd card :confused:

That’s a bit technical though :confused:

Wow thank you a lot !

I only have my system on the sd card, since data is stored on a usb hard drive. So the question is : if I juste format and reinstall yunohost on my sd card, and reinstall nextcloud, will my users be able to keep their files ?

Thank you for your help aleks, you are truly my hero here !

Ah, I guess you can do this yea, you just have to re-mount the USB drive properly in nextcloud after doing that (I guess that’s what you already did in the past to mount it the first time ?)

Well I’m just not 100% sure about if it will keep or not the corresponding file ownership ?

In doubt, the safest way may be to backup the HD content ? Is there any way to get data back from it ? Is it as simple as pluging it in another computer and getting the files ? Or is ther a method through ssh to transfert the file to a compteur on the local network (is it possible with something like ftp ?) ?

As far as I experienced, files of all nextcloud-users are owned by nextcloud. After reinstallation the user ID of nextcloud will probably be different IF you do a total new install of yunohost.
What I am not sure about again, is what data nextcloud stores in MySQL, and whether it can be rebuild. I think of metadata, which files are shared and which not, comments, those things)

Two first options that come to mind:

  1. If that still works, make backups of your Yunohost-system and all apps to the USB disk. Those backups can later be used during yunohost-postinstall. User ID’s should stay stable then (@Aleks, can you confirm that?)
  2. Not all is lost if you are not able to use Yunohost to make backups, and are forced to reinstall from scratch: change the ownership of those files to nextcloud. It will return the data, but not the metadata.

Option one is the easiest, option two also works, it just takes some more headaches. Are you so far in your ‘slowly learning’ that you can navigate the filesystem via SSH? Take a look at
sudo ls -has /home/yunohost.app/nextcloud/data
You’ll see all nextcloud users, and two columns ‘nextcloud’ (user and group).
Now if you do
sudo ls -hans /home/yunohost.app/nextcloud/data
(notice the n in -hans), you’ll see the ID of nextcloud’s user and group.
After reinstalling, the username of nextcloud often has another ID, so you’ll have to change the ownership of the files back to nextcloud:
chown -R nextcloud:nextcloud /home/yunohost.app/nextcloud/data

The point is, that the ‘-R’ above will change all ownership’s numerical ID to the new nextcloud user. I can not confirm that all data in that directory needs to be owned by nextcloud, but on quick glance on a system here it does look like that.

If it were my system and my users, I would continue with either option because I am sure enough that no data will be lost (only inaccessible until I find out how to make it accessible) and few files are shared between users or to the internet.
If I had an extra harddisk laying around, I would first make a copy of all data on the USB disk and a dd copy of the SD card.

If all else fails, you might still re-upload the data to the new installation (losing metadata such as original upload date and comments and conversations about files in the same way as option 2, and with more manual work).

Sorry for the long post, I hope it helps!

1 Like

I gave up on trying to get this back. Contacted my users and they seem to be very carefull and and a backup of their data. Thank both of you for your help. I’m doing a fresh install and will get everything back from the ground up !

Thank you again, hope this problem won’t pop again !

Good night !

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