Can lost database somehow be recovered from files in /data?

Environment: Debian 10 / mariadb-server 10.3.23 / owncloud-files 10.5.0

Hi all,

For some reason, mariadb-backup package got uninstalled without me noticing it
(i.e. the error raised by my nightly backup script).
Unfortunately, because of subsequent filesystem corruption on my master RAID,
I completely lost my owncloud database.
(My mariadb-backup based script produced empty backups on my backup RAID).

Now, can the database somehow (partly) be recovered from the files in /data?
I know I could lose a lot of information like versions, access rights, link shares etc.
Anyway, I would like to recover as much as possible automatically …

Thanks, Christian

P.S.
Would the below be a solution?

sudo -u www-data php occ maintenance:singleuser --on
sudo -u www-data php occ files:scan --all --repair
sudo -u www-data php occ maintenance:singleuser --off

That’s IMHO completely useless. I might be wrong, but if you don’t have a backup of your db (sqldump), you have to reinstall. This will perform scanning of your existing files anyway.

1 Like

That would be fantastic – are you sure about that?

Yes, at least for the initial (admin) user. For additional users it might fail, as their accounts do not exist yet. But here would manual scanning help, I guess.

1 Like

You convinced me – I’ll give it a try … just backed up /var/lib/mysql* and did
sudo apt install --reinstall mariadb-server-10.3
sudo apt install --reinstall mariadb-server-core-10.3
– both successful, mysql services now start again … :slight_smile:

Now backing up /var/www/owncloud (this will take some time), then will do
sudo apt install --reinstall owncloud-files
– fingers crossed … :crossed_fingers:

Serious trouble – was able to recreate MySQL database and MySQL user; however, no tables, no indexes, …

cfocke
Can lost database somehow be recovered from files in /data?

No. When you don’t have got a database backup you cannot recover your instance.

I’d suggest to

  • create a completely new instance.
  • after setup create the very same users as in your prior instance.
  • only then copy the user files to their new data directories.
  • after copying run
    sudo -u www-data php occ files:scan --all

Note that you’ll loose

  • all user passwords
  • all user and application settings
  • all shares
  • status of enabled/disabled apps

Maybe now is a good time to plan your future db backups :wink:

1 Like

Hi,
That’s exactly what I considered as last option, will do so.
Yes, and I will setup a monitoring for the database backup.
Thanks

Works – just had to rename /config/config.php to successfully run

sudo -u www-data php occ maintenance:install

Then created a user for my girlfriend and scanned her files for a test,
now doing the same for my own user and files (this will take some time …)

P.S.
Could leave all files in /data in place, were not affected by re-installation.

1 Like