Looking for help: Unplanned MariaDB transfer to new server

Hi there,

I was forced to make a new installation due to a broken previous server installation. Now, I have a new server and wanted to use my old data and settings from my previous Nextcloud.
My problem: I only could rescue the files from the …/data and the /var/lib/mysql directory. So, how to use the old MariaDB files to be able to setup a new Nextcloud with the old DB?
I read a lot of posts but was not able to solve it.

Here some details about my system:

  • Raspberry Pi 3
  • Debian GNU/Linux 12 (bookworm) aarch64
  • Nextcloud 29
  • MariaDB 10

The main thing I’ve tried: Copying old nextcloud DB into new directory inclusive the old ibdata1 file → possible to see the database via mysql, not possible to use it for an nextcloud installation

Error while trying to initialise the database: An exception occurred while executing a query: SQLSTATE[42S02]: Base table or view not found: 1932 Table 'nextcloud.oc_appconfig' doesn't exist in engine

when doing mysqlcheck it shows for each table

nextcloud.oc_example_table
Error    : Table 'nextcloud.oc_example_table' doesn't exist in engine
status   : Operation failed

I am glad and thankful for any help.

Are you replacing the entire contents of /var/lib/mysql on your target server with the backed up content of /var/lib/mysql from the old server? Or are you trying to do it piecemeal (i.e. just the nextcloud/ folder)?

Ideally you swap out the entire /var/lib/mysql (and have somewhat similar db versions in place).

(Also, hopefully you’re stopping MariaDB while doing these activities.)

Well, ideally, you do neither of these things and restore from a real db backup, but sounds like that’s not an option. :slight_smile:

Dear @jtr,

unfortunately there was no option to do a real backup.

I also thought about to replace the whole directory, but was not sure about that, due to I only could install MariaDB version 10.11 and I suppose the old DB was 10.5 or 10.6…

So I will try this. Please tell me, which command you recommend to stop MariaDB safely.

So here is what I’ve done:

  • used command systemctl stop mariadb
systemctl status mariadb   ○ mariadb.service - MariaDB 10.11.6 database server                    Loaded: loaded (/lib/systemd/system/mariadb.service; enabled>     Active: inactive (dead) since Sun 2024-08-11 10:55:28 CEST; >   Duration: 1d 17h 13min 53.111s                                        Docs: man:mariadbd(8)                                                   https://mariadb.com/kb/en/library/systemd/               Process: 749 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WSRE>    Process: 882 ExecStartPost=/bin/sh -c systemctl unset-environ>    Process: 890 ExecStartPost=/etc/mysql/debian-start (code=exit>   Main PID: 749 (code=exited, status=0/SUCCESS)                       Status: "MariaDB server is down"                                     CPU: 30.961s
  • copied all old files into /var/lib/mysql
  • saved all new files in another directory
  • used command to start MariaDB
systemctl start mariadb    ==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====Legitimierung ist zum Starten von »mariadb.service« notwendig.    Authenticating as: ,,, (user)                                  Password:                                                         ==== AUTHENTICATION COMPLETE ====                                 Job for mariadb.service failed because the control process exited with error code.                                                  See "systemctl status mariadb.service" and "journalctl -xeu mariadb.service" for details.                                           user@raspberrypi3b:/var/lib/mysql $ systemctl status mariadb   × mariadb.service - MariaDB 10.11.6 database server                    Loaded: loaded (/lib/systemd/system/mariadb.service; enabled>     Active: failed (Result: exit-code) since Tue 2024-08-13 17:3>   Duration: 1d 17h 13min 53.111s                                        Docs: man:mariadbd(8)                                                   https://mariadb.com/kb/en/library/systemd/               Process: 25295 ExecStartPre=/usr/bin/install -m 755 -o mysql >    Process: 25296 ExecStartPre=/bin/sh -c systemctl unset-enviro>    Process: 25298 ExecStartPre=/bin/sh -c [ ! -e /usr/bin/galera>    Process: 25357 ExecStart=/usr/sbin/mariadbd $MYSQLD_OPTS $_WS>   Main PID: 25357 (code=exited, status=1/FAILURE)                     Status: "MariaDB server is down"                                     CPU: 542ms

What I’ve noticed: in the old files there was no “sys” directory in mysql dir. So, I used the new one…

Any ideas what I could try next?

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