How to recover from USB crash?

PROBLEM

For some months, now, I have successfully used Nextcloud as a really stable and reliable solution for file share and collaboration. No more than two people used it on various systems (desktop and mobile devices). Suddenly (two days ago) the NextCloud icon on all Windows desktop computers stay grayed and it says “server replied: Internal Server Error”. Looking on the server via SSH, I see that I can not access the two central folders on my USB drive, anymore:

  • /media/USBdrive/ncdatabase
  • /media/USBdrive/ncdata

trying the command sudo ls /media/USBdrive/ncdata gives an error that could be translated as “the folder NCDATA is being read: input / output error”. Now, reading through the internet makes the impression that this heavily looks like a hardware defect on the USB drive. After disconnecting and reconnecting to different other USB ports, the mounting folder “/media/USBdrive/” disappeared from my NextCloud server. Trying to (re-)mount the USB device using the command:

sudo mkdir /media/USBdrive and
sudo mount /dev/sdb1 /media/USBdrive

results in the error message “mount: wrong fs type, bad option, bad superblock on /dev/sdb1, missing codepage or helper program, or other error”.

MY CONFIGURATION

  • NextCloudPi v0.67.8 on a RaspberryPi v3B
  • NextCloud version ??? quite recent while it struck
  • ncdatabase and ncdata folders reside on 16GB USB drive

QUESTION

As I think that the USB device is broken, I would like to know how to recover my NextCloud server from this error state back to normal operation. As I still have all the documents on the desktop computers, there might be the possibility to just format a new USB device or a SSD, then mount it to the specified folder and let NextCloud synchronize the documents back from the desktop computers into the database / data folders. But I don’t know if it would be that easy, or if there would be other settings and process steps necessary in order to re-synchronize from desktop into databases.

What can I do? And how can I do it?

Thanks.

That’s why you should make backups if your data are valuable.

Thanks for your helpful comment :wink:

I’d rather like to know if there is some kind of recipe which, when followed, has the potential to restore the corrupted database from the connected client computers.

I mean, there must be more than just the files to be restored:

  • the folder structure (might be similar to the client’s structures)
  • the user database (will be difficult once lost)
  • the user’s file and folder permissions (hmmm…)
  • the file and folder’s history (difficult to be restored, eh?)
  • the apps installed (might not be recoverable at all)

Regular backups seem to be the 1st choice, but anyway, I’m looking for a recipt to at least recover some of the things and elements.

About ncp backup strategies

I am using:

  • nc-backup-auto (without data, so this backs-up nc’s database and config files)
  • nc-snapshot-auto (backs-up data)
  • nc-snapshot-sync (syncs backup data to an external drive)

I’ve had good results fixing damaged ext4 fs with

sudo fsck -y /dev/USBdrive

btrfs has it’s own tools, if your usb drive fs was btrfs.

Current is v1.9.1
If you do not enable auto updates for ncp and nc, it is advised to run ncp-update manually at least 2xmonth, or 1xweek.

your drive is toasted, make sure to enable nc-hdd-monitor next time. If you don’t have ncp backups you have lost your database.

If you are using BTRFS you can try

https://ownyourbits.com/2019/03/03/how-to-recover-a-btrfs-partition/