Energy management - export data

Hello All.

I have a small question regarding energy management feature which is very cool, by the way.
I need to transfer my HA to different machine (disk space is running out) and I would like to know is there any way to transfer energy data. Can’t find any file related and I don’t want to loose all my history.

Thank you in advance for any suggestions.

All the best
Robert

1 Like

It is stored in the recorder database. So as long as you can back up your database you can transfer the energy data.

Backing up the database is easier said than done though.

It needs to be halted before creating the backup, or there is a high chance it will be corrupt when restoring.

Easy to do with MariaDB (stop the addon). No idea how to do it with the default SQLite DB.

Hi.

Thank you for a reply.
I’m using MariaDB as my database however I’m not sure how to export data with this…
I’m new in HA community and still learning

To transfer everything:

  1. Stop the MariaDB addon.
  2. Create a full backup
  3. Transfer the backup to your new machine.
  4. Restore it.
  5. Start the MariaDB addon.

Or for just the MariaDB addon (this will overwrite any stored recorder data on the new machine):

  1. Stop the MariaDB addon.
  2. Backup the MariaDB addon (partial backup).
  3. Transfer the backup to your new machine.
  4. Restore it.
  5. Start the MariaDB addon.

Ok.
Thank you. I will try and post results when my new machine will be up and running.

Did this work?
I see a lot of issues with moving the energy data to the new installation and didn’t find a comment of someone actually successfully migrating.

Hi.

I have toss Maria Db as it was problematic to restore. As of now I have changed machine with bigger disk and using build in database. Recommed rgis option as I have moved receantly twice to different machine and full backup kept everything.

I would like to describe my positive experience.
Recently, I performed an upgrade of my system from version 2022.11 to 2023.8.4, with a transition to a different PC (RPi3). I did not create a backup, preferring to reinstall all services anew, while retaining only automations and scripts. The most important concern for me was preserving the Energy Dashboard data, I didn’t care about any other data. On the old system, Recorder saved data to a MariaDB instance running on another computer, where I have set up Nextcloud.
During the initial shutdown, I left Recorder using the default storage location (~/.homeassistent/home-assistant_v2.db). After completing the initial setup, including the installation and configuration of the power meter and inverter, I switched Recorder to MariaDB, where the data from the old system was stored. As a precaution, I also backed up the HA data from MariaDB.
After restarting HA, there were numerous error messages in the log related to missing fields and data. Subsequently, the HA service initiated a database upgrade process, progressing from version 36 to version 41. During this process, indexes were optimized by adding new ones and removing outdated ones.
As a result of these actions, all the previous Energy Dashboard data, including consumption and solar energy production, were successfully preserved and appeared in the new HA instance.