How to reinstall hass io with previous database?

Hey there, my Raspberry Pi has been running for months now. But recently it got lots of random crashes like Duck Dns stopped working and my samba server is currently down. I wish to hava a fresh install by wiping all data. One big problem is that I want to keep my old database for personal reasons. I don’t consider using a snapshot to reinstall Hass Io as it doesn’t fix any of my problems. If I can get the database file how could I put it in my next installation? Any help is appreciated!

Copy home-assistant_v2.db from old to new:

Not going to be much use to you if your new entity_id’s don’t match though.

Even then it may not work. Usually when restoring snapshots the database has to be deleted.

The database is only for history, it doesn’t contain the configuration.

Yes, I want to have the history kept after reinstalling Hass Io