How to import old energy data

I’m dealing with an issue for which I can’t seem to find a good solution. Due to some careless actions on my part, I’ve lost the history of my electricity and gas usage. I had data dating back to 2017, but in August 2024, those devices all reset to zero. Unfortunately, I realized this too late, so I no longer have a recent backup of the database. However, I did find a backup from April 2024, which means I have data from 2017 to April 2024. I would really like to import this data into my current HA database. There will still be a gap of a few months, but it is what it is.

If I understand correctly, it should be enough to import the data from the statistics table, right? I think I can manage that, but then I’m left with the question: how do I properly align the sum values? Does anyone have any tips?

Maybe a better way would be to create new sensors which will never change, but you can add the historic to them. That way you dont need to mess with the current working sensors.

Sounds like a good idea but how can i do that?