A painful lesson.
Yeah there's the backup setting you could turn on, if it's not already.
I personally don't use that because it would interrupt what you're doing in order to save.
So I've just developed a habit of saving a new file every hour or so, when I get up for a break.