Trying to recover Baikal DB after screwed up update

I tried updating my raspberry, but it seems like a lot went wrong, and after the process it wouldn’t boot anymore. First I tried copying the mysql folder from userdata to my computer, but that kept failing. I didn’t want to risk wiping the SD card so I installed DietPi on another SD and tried copying possible DB files over, but it didn’t do anything so far. So how can I save my contacts/calenders from being lost on that SD?

Generally copying the raw database files does not work reliable. You need to assure that source and destination MySQL/MariaDB version is exactly the same, need to place the files PRIOR to install database server, then install the database to hopefully successfully migrate the existing database files.
Usually one would do a database backup on the source machine via mysqldump and import that SQL syntax file on any other SQL database, regardless of version etc.

But if you haven’t done a backup and now no chance to boot the machine, then of course you cannot do this any more.

What kind of update have you done, APT, dietpi-update or firmware? Usually it should always be able to at least boot, besides an experimental rpi-update has failed. If even with local keyboard+HDMI monitor you cannot boot, then the most usual issue is an SDcard corruption. You could try attach the SDcard to another GNU/Linux system and run fsck. Sometimes it works/boots afterwards, often not according to my experience :roll_eyes:

Generally please give some more details, if possible:

  • Which error messages do you see, when attempting to boot the Pi with HDMI monitor attached? Foto would be helpful.
  • Which error messages do you see, when attempting to copy the raw database files to your your computer? Is it a Linux desktop? On Windows of course it needs to fail already because the ext4 file system is not supported there. A second Linux machine is needed at least, also a LiveOS on USB stick is be possible.
  • If the above does not derive another solution, as last attempt, use a second Linux system/LiveOS to run fsck and retry booting the system or at least backing up database files.

And as another data recover possibility, at best export your calendar/contacts data from the Cal/CardDAV clients, so you are able to import those again to the new server.

And for the feature:

  • Regularly do database updates.
  • When running an OS on SDcard, regularly do full system backups as well (dietpi-backup), as those SDcards break quite often.
  • Try to reduce SDcard writes as much as possible, e.g. by moving the database files (dietpi_userdata) to an external more durable drive.
  • Move swap file to an external drive as well, in case it is actively used (should be not, if only BaiKal runs on the server).
  • Use dietpi-ramlog, if not already the case.

Sorry for the delayed response, I was a bit too frustrated.

I did a dietpi-update for several versions I had missed, and during all of them there were errors. My SD card seems to be corrupted, so that’s probably the reason. I tried doing fsck but it doesn’t boot sadly enough.

The error message booting up was [— end Kernel panic - not syncing
I don’t remember the copying error message and I can’t access it at all now. Stupidly enough I noticed baikal not working because I formatted my phone, so no backup. I guess I just screwed up and learn from it. Atleast it happened before I had important stuff on it.

I already put the dietpi userdata on my external harddrive now, but that’s still not really helpful if the new SD card were to die again, right? Is there a way to make automatic importable backups?

Thanks for the help so far!

Jep, experienced that kernel panic boot error related with file system corruption on SDcard myself more than one time. These SDcards are usually not reliable for long. Important to reduce disk I/O as much as possible, move userdata to external drive, or even the whole rootfs.

I created a Nextcloud/ownCloud backup + auto restore script once, for migration from DietPi pre-v6.0 to post-v6.0: https://github.com/Fourdee/DietPi/blob/dev/.meta/dietpi-cloud-migration

Planned to implement this somewhere into DietPi GUI and add more software titles by times. But did not yet find the time to go on with this.
In many cases the most important data, sometimes whole software installs + config + data is already on /mnt/dietpi_userdata, but in some cases data only, while configs would be lost on system death (without backup).
Issue is that in some cases, e.g. MySQL database must fit the installed software version, e.g. Nextcloud and ownCloud require this, otherwise due to database structure changes a more current version will fail to load the database from an older version, or at least errors with some tables/apps will appear. This is, besides config restoring, the most important reason to have backups done together for install dir, database tables and configs.

Another solution is to store install dirs to /mnt/dietpi_userdata/<software_title> where possible, to have it all together on the external drive (if moved there).

Long story short:

  • Our automated backup possibilities are not yet perfect.
  • The effort to implement for all software titles is huge, so this would be done step-by-step.
  • We need a shared method, e.g. something similar to how those guys do it: https://github.com/htpcBeginner/AtoMiC-ToolKit
  • Alternatively/On top, we could move as much software as possible to /mnt/dietpi_userdata to have it separate from system/SDcard and preserved in case of system death.
  • For now and in general when using system on SDcard it is highly recommended to regularly do a dietpi-backup :slight_smile:.