First thing to think about - does it really matter if you lose some data? What difference will it actually make to you? If it is commercial data, OK. But if it is home automation data, so what? Also, how often do you lose your Internet connection?
Connecting to a remote DB every 30 sec is quite fast. To do it with a file upload is going to need a batch file and you are going to need to know how to upload a CSV in batch mode to MySQL. Long time since I did that so I can't tell you how I'm afraid. If doing it that way, personally, I would only use Node-RED to create the files. I would run the batch job from CRON. And I would make the batch job do the following:
- Check for a file in the folder you are using to output from Node-RED.
- If one is present, check for the Internet.
- Connect to the remote db.
- Upload the CSV to MySQL
- If the command succeeds, move the processed file to an archive folder
- loop back to 1 in case there was >1 file waiting.
You could enhance that by making the batch job call out to a Node-RED end point (use http-in/-out for that) so that you can trigger other flows depending on success/failure.
As you can see, doing everything within Node-RED using gate and mysql nodes is likely to be easier to set up. Though once you've done the batch job, you will have a lot of very reusable knowledge beyond just Node-RED.
If you do use a node-red mysql node, I suggest that you look up how to do "prepared statements" in mysql, it will make your updates a lot faster when doing them individually or in small batches.