There are lots of forum posts, blog posts & backup scripts to assist users in backing up data from emoncms, but very little about restoring it after things have gone wrong.
I always presumed that it would done by halting apache & emonhub, and replacing the phpfiwa, phpfina, phptimeseries folders with the backup folders (disregarding mysql for the moment), and then restarting the services.
But that does not seem to work!
I tried this process not through necessity, but to ensure that I could restore if I needed to.
The result I got was that all my historical data was intact as far as I could see, but emoncms seemed to struggle with current data inputs;
- The current inputs are showing being updated in the inputs page, although the 'last updated' time fluctuated randomly - 2s, 4m, 30s, 5s, 3m, despite the input being updated every 7 seconds.
- The current values were not being recorded in a corresponding graph, and checking the graphs at current time showed no datapoints.
The apache error log showed;
[Sun Nov 09 18:58:59 2014] [error] [client 127.0.0.1] PHP Warning: fopen(/var/lib/phpfiwa/1_0.dat): failed to open stream: Permission denied in /var/www/emoncms/Modules/feed/engine/PHPFiwa.php on line 154
so I tried;
sudo chown www-data:root /var/lib/phpfiwa sudo chmod 755 /var/lib/phpfiwa
...for each of the directories, but got exactly the same result.
Paul
Re: Restoring data into emoncms
what are the permissions for the files within the directories ? If you run
are they www-data:root? if not you could try adding a -R (recursive) switch to chown ie
Paul
Re: Restoring data into emoncms
Hi Paul, well spotted!
The file permissions were pi:pi and not www-data:root.
So for future reference, the data folders restore process should be;
1) Stop emonhub & apache
2) Replace the data folders phpfiwa, phpfina, phptimeseries in /var/lib/ with your 'backup' folders.
3) Set the permissions for the data folders
4) Restart emonhub & apache
Paul
Re: Restoring data into emoncms
I guess you could even just pause emonhub from posting to emoncms for the duration of the restore and then allow it to catch up so you have no loss of data.
If you add a setting " pause = out " (pause output only) to [[emoncms]][[[runtimesettings]]] in emonhub.conf it would continue to collect data in the buffer without sending it to emoncms and would therefore not need to stop, when you finished the restore and have restarted apache2, delete, comment out or set it to " pause = off " to post the buffer contents and continue business as usual.
Paul