Broken drive on home RasperryPi server

Hi all,

The 2TB external drive that I connected to my RaspberryPi on which I run my Nextcloud server appears to have died. This is where all the data was stored: I mounted the drive to /var/www/nextcloud at start-up. I have three laptops/PCs connected to this (two accounts, multiple shared folders between these accounts).

I’m a bit at a loss about what to do. I’ve spent a couple of hours trying to repair the drive, but think I’m out of my depths there (Basically, it doesn’t mount). What is my best course of action?

E.g. If I buy and connect a new drive, and mount it to /var/www/nextcloud, will my PC/laptops re-upload all the data appropriately? Are the accounts and shared folders lost? Will I have to reinstall Nextcloud?

best,
Stein

If I buy and connect a new drive, and mount it to /var/www/nextcloud, will my PC/laptops re-upload all the data appropriately?

Not by default. Server is deemed the master for sync purposes in this case, but it can be overridden.

It’s not meant to be used in place of a data backup strategy though. It’s basically for dire situations and may not get all your files back.

Are you asking this because you don’t have any backups of your server / data currently?

The situation you’re in is a fairly typical situation to plan for while self-hosting. Once you get things sorted out, if you don’t already have a formal data backups strategy in place, I strongly urge you to take this as an opportunity do so.

Are the accounts and shared folders lost?

Technically those bits of information are stored in the database, rather than with the files themselves.

So it depends on what database you’re using and where your database is storing data. Is it also stored on that drive? (Hint: If using sqlite, “yes” while MySQL or postgresql generally means “no” since they usually store their database files elsewhere).

Will I have to reinstall Nextcloud?

If your data directory is what’s lost, technically, no. The database would still be intact.

Thanks for the quick response!

I (maybe naively) considered the Nextcloud server to be my backup, now I recognize that I should have had a backup of that backup. I’ll take your advice and do this properly in the future.

What do you think of:

  • Having 2 drives attached to the Pi, with a ‘main’ drive mounted to /var/www/nextcloud.
  • Scheduling a daily rsync between the main drive and the secondary drive.
    (I know a 3-2-1 solution would be optimal, but its just a home situation, so I’m balancing security & reliability against cost & maintenance)

I’ve managed to log into the MariaDB, and upon SHOW tables; it shows a large overview of oc_*** tables. Does that mean the database was not stored in the /var/www/nextcloud directory?
What would then be my best course of action. (I was close to deciding to reinstall the server, but maybe this gives me more options?)

Edit: Here is the output of first 10 size-sorted tables in MariaDB:

+--------------------+---------------------------+-----------+
| DB                 | Table                     | Size (MB) |
+--------------------+---------------------------+-----------+
| NEXTCLOUD_DATABASE | oc_filecache              |    119.04 |
| NEXTCLOUD_DATABASE | oc_activity               |     96.95 |
| NEXTCLOUD_DATABASE | oc_file_locks             |     36.14 |
| NEXTCLOUD_DATABASE | oc_jobs                   |      6.02 |
| NEXTCLOUD_DATABASE | oc_filecache_extended     |      5.09 |
| NEXTCLOUD_DATABASE | oc_authtoken              |      0.80 |
| NEXTCLOUD_DATABASE | oc_login_address          |      0.76 |
| NEXTCLOUD_DATABASE | oc_suspicious_login       |      0.76 |
| mysql              | help_topic                |      0.41 |
| NEXTCLOUD_DATABASE | oc_files_trash            |      0.29 |

I’m still hoping someone can help me with this…