The ide saves changed file over the old version, when you compile it. So your old version is lost and destroyed, if you have not made a 'save as'.
The IDE should save the file with a temporary name, when you compile it.
For example myfile_run,ino
When you next time open the IDE and load the file, it asks, whether you want the old or last compiled version. Or gives a list of the versions of the file.
@UKHeliBob is right of course, but in general if @mistofeles experienced problems with version tracking of his projects, I recommend looks to Version Control systems, such as git or rcs
Thank you, but I have my own version tracking system, which I have been using for about 40 years with various systems and languages.
I'm a bit lazy to learn new systems.
I keep most of my code in the sketch folder including libraries as they get broken over time. Every so often I compress (ZIP) the folder example: blink(230910_13-21).zip Where 230910 is the date and 13-21 is the time. Works great in Linux and sorts in order. I have a folder labeled Archive in each sketch folder, that is where I save the .ZIP files and also on the server. This allows me to recover back to any given point that I have saved from. Disk space is cheep my time is not. Moving to a different machine is much easier this way for me.