Nextcloud DB restoration failed

Hello everyone,

I am getting an error while restoring nextcloud backup from one server to another,

my original server is running MariaDB 10.5 on Rocky Linux 9. Nextcloud is not happy with it, it shows a warning on Administration page

MariaDB version “10.5.29-MariaDB” detected. MariaDB >=10.6 and <=11.4 is suggested for best performance, stability and functionality with this version of Nextcloud.

so I decided to install MariaDB 10.11 (Rocky Linux 9) on another server and test it before updating the live server.

I took backup using this command as provided in the documentation:

mysqldump --single-transaction --default-character-set=utf8mb4 -u root -p nextcloud > nextcloud-sqlbkp_utf8mb4.bak

and restoring the backup on test server using this command:

mysql --default-character-set=utf8mb4 -u root -p test_db < nextcloud-sqlbkp_utf8mb4.bak

It is worth noting here I created the database with UTF8mb4 support using:

CREATE DATABASE test CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci

now the problem is while restoring database I am getting errors:

ERROR 1034 (HY000) at line 2974: Index for table ‘oc_documentserver_changes’ is corrupt; try to repair it

sometimes for oc_documentserver and other time for oc_calendarchanges

ERROR 1034 (HY000) at line 1338: Index for table ‘oc_calendarchanges’ is corrupt; try to repair it

in short it’s not fixed, this can be for any table.

I also added innodb_file_per_table in my.cnf file and restarted the service but nothing fixes the problem

[mysqld]
innodb_file_per_table=1

I have also tried restoring with fresh backup and on different servers, different MariaDB versions i.e 11.4 but same result. I am sure there must be something wrong

  • Nextcloud Server version (e.g., 29.x.x):
    • 30.0.17
  • Operating system and version (e.g., Ubuntu 24.04):
    • Rocky Linux 9.8
  • Web server and version (e.g, Apache 2.4.25):
    • httpd
  • Installation method (e.g. AlO, NCP, Bare Metal/Archive, etc.)
    • VM

Did you try the integrated repair commands in nextcloud:

And if that does not help, check the original database if you can figure out the corrupt index (with db repair tools).

Hi, thanks for the reponse, I just tested it again if I install the same version MariaDB 10.5 on the test server then the backup can be restored without any problem but when I try to restore it on newer versions of MariaDB as recommended by nextcloud it throw errors

I have fixed this problem with the help of ChatGPT ; )

I had to add these lines in mariadb config file

cat /etc/my.cnf

[mysqld]
max_allowed_packet=1G
innodb_buffer_pool_size=2G

my backup file size is 1.6G, now I can restore it without any problem.