Migrating MariaDB

HI,

I’m currently running supervised and want to migrate to docker to remain supported. I’ve managed to transfer zigbee2mqtt, aircast and mosquitto mqqt to individual docker images that home assistant can continue to talk to. How di I do this with the mariaDB so I can keep all the history? I’ve tried creating a new docker mariadb and pointed it to a copy of the existing database files, then stopeed the existing mariaDB and started the new one (with the same docker name as the old one) and nothing seems to work.

In case anyone is trying to achieve the same, I did the following:

  1. Log into the current mariadb docker container
    sudo docker exec -i -t addon_core_mariadb bash

  2. Then dumped the mariadb database in sql format. Make sure to save this somewhere you can access it outside of the docker image.

mysqldump -u username -p databasename > data.sql

Replacethe username appropriately (mine was homeassistant) and the databasename (again mine was homeassistant). It will ask you for the root password once you hit enter.This will dump the database to the data.sql file. There isn’t any status of it working but I believe errors appear if there are any.

  1. Exit out of this docker image and login to the other mariadb image:
    sudo docker exec -i -t addon_core_mariadb_duplicate bash

  2. Make sure the previous data.sql can be read by this docker image and upload it into the mariadb

mysql -u username -p newdatabase < data.sql

again replace the username appropriately, as well as the new database name and it should load the data in. There is no status update but errors are reported as it works through the file. Sit tight and hopefully it will copy ok.

Then you can turn off the old mariadb and keep the new one, updating the hassio recorder definition in the config.

Hope that helps someone else.