I need to migrate from Core 2024.3.3 to latest Supervisor version. I want all integrations, scripts, sensors configuration to be migrated. Also, I need sensors history data to be migrated as well.
Is it possible? Can I make backup on Core and then restore it on new Supervisor installation, will it work?
You can try. I suspect it may fail. You are a long way behind.
I would suggest you upgrade to the last monthly release for each month since the March release. Noting any backward incompatible changes you have to make before proceeding to the next month’s version. So that is eight updates in total.
There have been database migrations too. If you want to retain your data history you will have to go through these updates.
Ok, so you mean preffered way is to install Supervisor 2024.3.3, restore backup from my Core installation (it should work?), then apply each monthly update, so all required database migrations will be applied. Is this correct?
I have 6 months archive data from sensors, I don’t want to lose it.
You didn’t mention what version of Core you’re at, just Supervisor. I’ve found Supervisor updates to be far less intrusive than Core updates. I just let them auto-update and haven’t had a problem yet, in over 5 years.
That said, if I had to jump a bunch of Supervisor versions, I’d just make a good backup, save it somewhere I can easily grab it, and do one Supervisor update to the current version. Hopefully there would be no need to restore anything, but if something goes wrong the backup is available.
If you’re behind on Core, too, then @tom_l has explained the process pretty well. He rightly mentions the couple of significant database changes which have happened since March. If your database is large, these may take quite a while. Don’t get impatient and reboot in the middle of them. Better still, do some database clean-up beforehand. Or just delete it and start over.
Hmm that will not be possible, becasue hardware running Core 2024.3.3 can’t run updated Core. Any attempt to upate could break eveyrything, so I really don’t want to touch it. There’s some problem with Python version there.
Also, please correct me if I’m wrong, there’s no any specific auto update for Core? I need to login via ssh, bump Python version in my env, then bump HA version from ssh. That will most likely fail in my case.
To your first question, yes, you can back up the database file just by copying it somewhere safe. If you’re using the default SQLite database, the file name is home-assistant_v2.db.
For the second question, I’ve never heard of any standalone database migration scripts. The migration is done as part of the update, presumably checking the current database version and updating as needed. You could also just copy the old database somewhere, then delete the original. The next time HA started it would create a new database in the proper format for that version.
If you really needed the old data in HA, you could review the DB changes, then do an off-load / re-load of the data from your backup to the new database. In between you’d probably need to change some field and/or table names and verify any relationships still work. At that point I’d be questioning the need for retaining historical data in HA. There are better tools for analyzing historical data. That’s not what HA was really designed for.
There’s also some apps to compare database schemas and generate migration script, but it may fail in some cases when databases are complicated and some data need to be migrated from one table to other.
I guess default database is sqlite, so I can use any sqlite client to open that file.