How to setup a master-slave connection with an invisible master? [closed]

The PI has a MariaDB (or MySQL) Primary (aka "Master"), correct? And you are thinking about having a Replica in the "public network.

As already mentioned, the Replica "pulls" from the Primary, which is not easy because of the network setup. But it is possible if you are on Linux -- Have the PI set up an "ssh tunnel".

You imply that the connection is flaky? The PI would have to be able to notice the failure and reestablish the connection when necessary.

Another approach avoids multiple issues -- Skip the replication concept. After all, what use do you have on the PI other than holding the data for transfer to the real database.

It should not be a problem for the PI to send an HTTP request to a 'public' webserver. It would be a small amount of PHP (or other) code to store one minute's worth of readings in the database. (One request/minute is trivial; no problem.)

1-5 minutes' delay? I don't see that happening in any of the plans. Even if it did, simply lose the data. Weather-like data (including, perhaps, swimming pool depth) does not change rapidly enough to warrant even one-per-minute.

On another topic -- check out how much data there will ultimately be. In a year there will be 0.5M temperatures. Try sending that much to a graphing program; it may choke. I suggest you summarize the data, either as it comes in, or on, say, an hourly basis -- min, max, last. For average, keep the sum and count; then compute the average as sum-of-sums / sum-of-counts.