Critical data logging backup / fail safe?

Hi, i am trying to build a logger that counts pulses on Arduino YUN.
I think i am gona use REST to save the puls with a timestamp to my server. And use socket.IO to send commands to it.

The problem i don not know how to solv is how i can on a safe way save my data to the server without loosing loggs. If the server times out or lost connection i want to save it to the SD card. If i get connection it will send the saved data loggs to the server.

How do i solv this problem? Can it be done? Is there a lib already build for this typ of applications?

I don't know of a specific library and don't have specific coding advice, but I do have a suggestion to turn your logic around. You said you would send to a server, but then write to SD card if there was a server problem. To increase reliability, I would always write to the SD card, and then write to the server when it's available.

The general structure is that as data is collected, it gets written directly to the SD card with a time stamp. A separate asynchronous process is attempting to connect to the server, and tracks the time when the last successful update was made. When a connection is made, it reads the data from the SD card, sends everything that has a time stamp that is later than the time of the last connection, and then updates the time of the last connection. In that way, short server delays don't cause the data collection process to be held up, and long server outages don't cause a loss of data.

Taking it one step further, rather than simply tracking the time of the last successful update, once a connection is made, ask the server what was the last valid data it received, and then send any data that was collected since then. This adds an extra level of reliability, in that if a server failure caused a loss of data after it was sent from the Yun, but before it was committed to storage, that data would be re-transmitted on the next update.