Posting to 2 emoncms servers from iotawatt

Is it possible to post data to 2 different emoncms servers from iotawatt?

I am running an emoncms server locally, but would like to keep my data on an external server aswell. I’ve looked at using emoncms sync module, but it doesnt seem there is a way to keep 2 servers in sync. I’ve also looked at using mqtt and it works ok, but it seems like if there is a break in my internet connection, I’d end up with gaps on the remote server. I am also not able to duplicate my node and input numbers as I have it on the local server, so I’d need to maintain 2 configurations.

If it’s not possible to post to 2 emoncms servers, is there any way to keep 2 emoncms servers in sync?

Any advise appreciated.

Thanks

Sorry, no. You can run Emoncms and influx but not two Emoncms.

Sort of, but it gets into that different configuration issue. Once you’ve configured and send data to an Emoncms node, whenever the IoTaWatt subsequently connects to that server/node it will forst query to see where it left off, and begin uploading history from that time to present.

So if you pick one of the two instances to be your “regular” connection, and let IoTaWatt upload to it, you can periodically reconfigure your Emoncms to the other and start it up. It will upload all of the data from where it left off. When it’s current, simply stop Emoncms and reconfigure the other. When you start it again, it will do the same for the other. Depending on how often you would want to update the alternate Emoncms, that could be a solution. It will work, just a pain to do.

There are a ton of people who have Pi’s and an account on Emoncms, I thought there was a way to have the Pi update Emoncms.

Thanks for the idea. I can look into doing something like that? Is it possible to update the server settings via API? I’d like to automate the process, as it’ll be a pain to do manually, as you mentioned.

I’m not sure if the Pi’s got any additional module that will allow it to update a remote server like emoncms.org, but I configured emoncms in a docker container. Another way I was thinking was to stop the container once or twice a day and rsync the data across to the remote server. It will work to keep a second copy of the data remotely.

Was hoping for a more ‘real time’ option, as I’d like to connect to the external server to monitor.

I’ll check on the openenergymonitor forum if anyone has any other options / ideas.

I’ll update this thread if I find more info.

Thanks,

I just had to do a bit more digging. I found a viable solution - usefulscripts/backup at master · emoncms/usefulscripts · GitHub

I’ve configured this on my remote emoncms server, opened my local firewall for my remote server’s IP address and I’m busy syncing my data. Seems to be working.

I can run this in a cron every x minutes / hours to update my remote server. Still not ‘real time’, but close enough.

2 Likes

One other thought; have you looked at MySQL database replication?
E,g, https://dev.mysql.com/doc/refman/5.7/en/replication.html
I’m not sure how the secondary emonCMS will react to having the database updated (via replication) underneath it! I’d probably leave it down until it’s needed.
So if the primary server dies, I guess the process would be to reverse the replication direction, bring up emonCMS on the backup machine, then reconfigure your IotaWatt to upload to it.
(This would only be available if both the servers are “yours” - no emoncms.org)

The backup script from useful scripts only work for the first time. All the inputs and feeds are created, with the correct values. As part of the backup, the inputs & feeds are registered in the database as well as the data from /var/lib/phpfina, /var/lib/phpfiwa, /var/lib/phptimeseries & /var/lib/timestore copied over (I only have phpfina).

The problem is, it only works the first time I execute the backup. Any following execution of the backup.php script gets executed, but nothing is updated further.

I also had the idea of running database replication, but the actual data is stored in the directories mentioned above as <feed_nr>.dat and <feed_nr>.meta. So I will need to keep the replication going as well as an rsync of the data files.

I’ve only done an initial transfer of data, which worked, but not tried updating it again, so I dont know if it will update every time I copy / update the data.

I am still playing around with this. I’ll keep this thread updated as I make progress.