The server hung up, how to get the lost data.

  mongodb, question

I wrote a script, the function of which is to go to a data source every morning to get the data of that day.

If one day my server hangs up and it takes two days to restart the server, then my script will lose two days of data load.
Excuse me, is there any good solution to the situation where the server hangs up, causing scripts to fail to run and eventually causing data loss?

Why don’t you write down some databases? mysql oracel postgresql redis mogodb ?