What happens to syslog when network is down?

Those messages are lost.

You can log locally to a USB or sd card or sata drive if device supports it. Don’t use internal flash for that.

I cannot imagine how that script could ensure that no records would be lost. Isn’t better to run local auxiliary syslog server nearby the monitored devices to prevent the communication outages and let the resending on it? Saving logs to usb and mailing the log files from device is much easier than such complicated script.

Get inspired from here…
https://wiki.mikrotik.com/wiki/Send_Backup_email

Just the file will have different name.