Migrate to new recorder-db

I would really love to see a way to migrate old data to a new recorder db.
I’ve changed the recorder from the sqlite database to an external maria db installation - but this caused the loss of old data.

It would be great, if there’s a way to setup the recorder with a parameter, that could import the existing data to the new database.

How did you move the db to an external location? I would like to move the db to an usb-stick. To save the SDcard. But i don’t know how.
I use pi4 wih a the complete HA image.

You just need to specify the path to the new database, but I believe you have to use a database other than the built in sqlite instance because that one is hardcoded to /config/home-assistant_v2.db

No I don’t think so. You can name and store it whereever you want, that can be specified in the recorder section too.


@CChris for your initial question I don’t think a migration (or to be more precise: a merge of two separate databases) is possible, at least not with A LOT of adjustments regarding IDs, foreign keys etc. This meanwhile became even more complicated due to the outsourcing of e. g. attributes to their own tables.

From what I’ve learned the last months, there’s no interest of any HA developer in such a “feature”. And the arguments are fair: database technology is quite complicated and offering such a feature would need knowledge of every possible/supported database format like MySQL, MariaDB and PostgreSQL (if the workflow would be: SQLite → another one). HA is not into databases - they are just one of many tools needed to power HA.

From a personal point of view I would LOVE to see such feature because it would make migrations to another database format so much easier - or possible at all.

For guides on how to migrate a full database (SQLite to MySQL/MariaDB) you might want to have a look at https://community.home-assistant.io/t/migrating-home-assistant-database-from-sqlite-to-mariadb/96895/91.

1 Like

thanks :slight_smile:
But in the mean time, I have just created a fresh database :slight_smile: