backdrop-contrib/bee

Problem exporting and importing Databases caused by MariaDB Dump File Compatibility Change

TheMetMan opened this issue · 5 comments

This is for anyone else who might come across this problem.

I was trying to do an update to all my sites yesterday and came across this error when importing the Production Export to Local:

Importing the Database
ERROR at line 1: Unknown command '\\-'.
gzip: stdout: Broken pipe

Looking at line 1 in the database I had exported I see this:
/*!999999\- enable the sandbox mode */
However on older exports this line is not there.
So from the MariaDB site here you will see the reason for this which is dated 2024-05-17 so very recent.

The solution is to remove this line if it exists from the database dump before importing it.
Here are the MariaDB Versions I am using:
Hosting Server (Ubuntu): mariadb Ver 15.1 Distrib 10.6.18-MariaDB, for Linux (x86_64)
Local Server (Linux Mint): mariadb Ver 15.1 Distrib 10.6.16-MariaDB, for debian-linux-gnu (x86_64)
My PC using Ansible (Gentoo): mariadb Ver 15.1 Distrib 10.6.17-MariaDB, for Linux (x86_64)

My Local Server is up to date on upgrades, but the MariaDB version is not the same as the Hosting Server, hence the problem.

Thanks for sharing this here @TheMetMan . I had an issue a while ago where my host switched from MariaDB to MySQL:8 and I ended up having to drop the local, switch to MySQL then import from host.

I wonder, do you think there is anything bee needs to do better here, or is this just for information?

I don't think bee need to do anything @yorkshire-pudding, but I thought giving a 'Heads Up' might help someone else who hits this problem.

I have had another look at this. It would seem that if you are using MariaDB version 10.6.18 on any server the database will be exported with the header as above. This same version imports it, no problem.
It is when an older version tries to import it that there is a problem.
Fortunately my Local and Remote are now both on 10.6.18 so I no longer have the problem.
I will just have to keep an eye on the versions and make sure they continue to behave.....

I came across this and found another workaround.

Modify the local version of bee in commands/db.bee.inc

The line that says

    $import_command .= "$gunzip_bin -c $filename | ";

modified to:

    $import_command .= "$gunzip_bin -c $filename |  tail +2 | ";

I'll not change this in bee as it will break things where this isn't an issue. However, I'll look at a more sustainable change.

Need to do for unzipped .sql files too.