Desired outcome: I'd like to extract my historic data (Temperature, CO2, etc) from a month old backup file (~about 18 months of data), and insert it into my current version of HA, so that I can view temperature trends over the last 12+ months.
What happened: ~a month ago (On 17th of May) I noticed that all of my historic data had disappeared.
I backed up (Noticed this backup was 33MB instead of the ~1GB from the 16th of May). I tried restoring backups from previous day(s) and months, attempting to restore just history, and attempting to restore everything. HA was hanging during this restore step, so it was necessary to hold the power button down to reboot the system. It successfully rebooted - but with no history. This was the case for every restore attempt.
I've not had time to tackle this since, and now have another month of data. I'd like to recover my 18 months of historic data, ideally without losing the new data from the last month.
Hardware: Lenovo mini pc, Intel core i5, 16GB RAM.
Installation method Home Assistant OS
Core 2026.6.2
Supervisor 2026.06.1
Operating System 17.3
Frontend 20260527.5
(This is today's OS - In May I was probably running 2026.05 - I normally update within a few days)
I'm the one whose post you referenced. I have had to manipulate stale/bad/old sensor in several situations. One was an EV charger that had a period of 100x overcounting.
Another was manually inserting stats for a solar gateway that was offline for 3 months, but kept generating.
Another was the smartplug i used this january with a space heater when my furnace died. I removed them when the heat pump was installed.
In all cases, i can attest that it was possible to achieve the desired result. There are tools that can help. One is the "import statistics" integration. Another is the SQLite web add-on.
I could not write a recipe for you as I'm typing this in my hot tub. I know that i spent many hours with various chatbots to deal with just these 3 cases.
One direction i would take in your situation is to try the HA MCP server add on. Make sure to backup everything. Do the work on an alternate HA instance, preferably a VM on which you can restore backups from various dates. Eventually, you should be able to generate CSVs that can be imported in your latest prod instance with all the data you need.
I see a lot of SQL queries and CSV imports in your near future.
Keep copies of everything until you are fully satisfied you haven't lost anything is my strongest suggestion. Let these backups survive six weeks of updates and upgrades before you feel comfortable to archive them.
If you’re able to spin up an alternate HA instance (in a VM or other method) and get your historical data restored into that alternate instance, I recommend taking a look at homeassistant-statistics to copy your historical data into your production HA.
I recently used it to get a year of historical data for a bunch of home-assistant-rivian entities from my old HA instance into my new one. The integration’s readme is very thorough and incredibly detailed. FWIW I chose the default CSV format for my data and it worked flawlessly.
Here’s the basic premise: Install homeassistant-statistics on both your old and new HA instances. On the old one, export the entities you want (you can also export an inventory that lists all the available entity statistics if you're not sure which you need) and then download the export. On the new instance, upload your exported data and then import it.