Remote PostgreSQL DB with local buffer ... how could it look like
I think installing Postgres on the RPi is overkill.
Buffering the sensor data in a plain text file should be good enough. The process could look something like:

send the sensor data to a text file (append mode)
Have a cron job that runs every x minutes. This will rename the text file as a first step. This makes 1. create a new text file while you process the &quot;old&quot; one
Send the contents of the text file to your Postgres server using copy ... from stdin inside a transaction. If this fails (connection problem), retry until successful.
Remove the file that was just sent to the server. Alternatively keep it as an archive/backup - which would require creating a filename in 2. that is unique, e.g. by appending a timestamp.

Using copy .. from stdin is way more efficient than running multiple single-row INSERT statement. And still more efficient than running a single multi-row INSERT statement. Additionally the file then also acts as the buffer you want.