Git Product home page Git Product logo

backup's Introduction

Emoncms

Emoncms is an open-source web application for processing, logging and visualising energy, temperature and other environmental data and is part of the OpenEnergyMonitor project.

Emoncms

Requirements

  • PHP (tested with 8.1.12)
  • MySQL or MariaDB (tested with 10.5.15)
  • Apache (tested with 2.4.54)
  • Redis* (tested with 6.0.16)

*Redis is recommended because it reduces the number of disk writes and therefore prolongs disk life (noticeably on SD cards e.g. Raspberry Pi). Some input-processors also require Redis and fail silently if Redis is not installed. Some environments such as shared hosting or as far as we have tried Windows servers don't support Redis hence why Emoncms has a fall back mode that allows core operation without Redis.

Documentation

View the Emoncms documentation at: https://docs.openenergymonitor.org/emoncms

Design

Emoncms timeseries database design (feed storage)

Other

Emoncms Terminology

  • Input: An incoming datasource. Each input has an associated "node" identifier and a "key" sub-identifier. Inputs are entry points, only the last value and time of the input is recorded. To record historic data a feed needs to be created from an input.
  • Input: Node: A grouping identifier for an input or feed.
  • Input: Key: A sub-identifier for items within each Node.
  • Input process list (or input processing): A list of processes* performed sequentially on each input value as it is received on that input.
  • Process: A function that can be attached to the process list of an input to change the value or to save the value to a feed*.
  • Feed: A place where data is recorded, a time-series of datapoints. The standard time-series databases used by Emoncms are PHPFina and PHPTimeSeries and were written as part of the Emoncms project.
  • For a description of what each input process does in Emoncms, see the helper note within the Emoncms input processing configuration interface.

Emoncms.org API Reference

Install

Emoncms is designed and tested to run on either Ubuntu Linux (Local, Dedicated machine or VPS) or RaspberryPi OS. It should work on other Debian Linux systems though we dont test or provide documentation for installation on these.

We do not recommend and are unable to support installation on shared hosting or XAMPP servers, shared hosting in particular has no or limited capabilities for running some of the scripts used by emoncms. There is now a large choice of low cost miniature Linux VPS hosting solutions that provide a much better installation environment at similar cost.

Recommended:

docker standalone container

An easy way to start with emoncms is to use the all-in-one docker container

A pipeline using github actions is producing builds with latest emoncms stable version for different architectures : amd64, arm64, arm/v7

These docker images, based on the alpine linux distribution, are designed for iot. Images are tagged using alpine and emoncms versions, for example alpine3.19_emoncms11.4.11.

The images have onboard :

  • the mariadb and redis databases,
  • the mosquitto mqtt broker,
  • the main modules : graph, sync, backup, dashboard and app,
  • the workers : emoncms_mqtt, service-runner and feedwriter.

You can easily :

  • deactivate the low-write
  • use an external broker.

To pull the latest image for testing :

sudo docker pull alexjunk/emoncms

More on https://emoncms-docker.github.io

Experimental

not currently up to date

Multi-platform using Docker Container

Modules

Modules can be installed by downloading or git cloning into the emoncms/Modules folder. Be sure to check for database updates in Administration menu after installing new modules. The following core modules are included on the emonSD image:

There are many other available modules such as the event module and openbem (open source building energy modelling module): check out the Emoncms repo list.

Branches

  • master - The latest and greatest developments. Potential bugs, use at your own risk! All pull-requests should be made to the master branch.

  • stable - emonPi/emonBase release branch, regularly merged from master. Slightly more tried and tested. See release change log.

Tools

  • PHPFina data file viewer - Easily explore phpfina timeseries feed engine data files directly without a full Emoncms installation. Useful for checking backups and archived data.

Android App

Google Play

GitHub Repo

Development Forum

More information

backup's People

Contributors

alexandrecuer avatar borpin avatar emrysr avatar glynhudson avatar jsiobj avatar neilw avatar pb66 avatar reedy avatar trystanlea avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

backup's Issues

Hardcoded backup location

The location of the files etc are hardcoded to assume /home/pi/backup.

This location is not feasible for me. I have changed what I can find but the backup module still does not work for me.

Apache error logs

The following errors are seen in the Apache logs when the backup page is selected.

cat: /var/log/emoncms/exportbackup.log: No such file or directory
cat: /var/log/emoncms/exportbackup.log: No such file or directory
cat: /var/log/emoncms/usbimport.log: No such file or directory

Export fails on appending phpfina files

Testing on home system consistently fails when appending 111mb of phpfina files. Partition becomes unresponsive and requires a reboot to get the pi working again.

Possible unwanted code and scripts

I'm working on some pull requests for minor tweaks on the import and export shell scripts and noticed the following code which I cannot find being used anywhere:

backup/emoncms-import.sh

Lines 42 to 50 in 9cfc5b8

# Very old images (the ones shipped with kickstarter campaign) have "emonpi-28May2015"
if [[ -z $image_version ]] || [[ "$image_date" == "emonSD-17Jun2015" ]]
then
image="old"
echo "$image image"
else
image="new"
echo "$image image"
fi

It used to work here and was commented out some time ago:

backup/emoncms-import.sh

Lines 156 to 166 in 9cfc5b8

# Start with blank emonhub.conf
# if [[ $image == "old" ]]
# then # Legacy image use emonhub.conf without MQTT authenitication
# echo "Start with fresh config: copy LEGACY default.emonhub.conf:"
# echo "cp $emonhub_specimen_config/old.default.emonhub.conf $emonhub_config_path/emonhub.conf"
# cp $emonhub_specimen_config/old.default.emonhub.conf $emonhub_config_path/emonhub.conf
# else # Newer Feb15+ image use latest emonhub.conf with MQTT node variable topic structure and MQTT authentication enabled
# echo "Start with fresh config: copy NEW default emonpi.emonhub.conf:"
# echo "cp $emonhub_specimen_config/emonpi.default.emonhub.conf $emonhub_config_path/emonhub.conf"
# cp $emonhub_specimen_config/emonpi.default.emonhub.conf $emonhub_config_path/emonhub.conf
# fi

And similar for export it has this code which isn't referenced anywhere:

backup/emoncms-export.sh

Lines 53 to 59 in 9cfc5b8

# Very old images (the ones shipped with kickstarter campaign) have "emonpi-28May2015"
if [[ -z $image_version ]] || [[ "$image_date" == "emonSD-17Jun2015" ]]
then
image="old"
else
image="new"
fi

I propose that these code segments are no longer of use and should be removed to tidy up the scripts a little.

I'm happy to work on pull requests and some testing and wanted to get your thoughts before spending time on it. What do you think?

Moving backup export and uploads location to /var/opt/emoncms/backup

@borpin I've started the process of implementing this.

First of all, the locations are changed in the master branch of the EmonScripts install scripts
openenergymonitor/EmonScripts@dc44ca2

Then the backup module install.sh script creates the folders in the right locations:
https://github.com/emoncms/backup/blob/master/install.sh

I've tested both import and export here and it works great.

So far this will only work for people building a new system using EmonScripts master branch and master branch of backup module, next step is to work out the update process...

can't run backup from UI, only from command line

I can't run backup from user interface

backup button does nothing
also the black screen shows no text
I can run backup from the script emoncms-export and the resulting achive can be seen and downloaded in backup module

image

image

Backup not working because of a service-runner redis issue.

So just upgraded from v9.8 to v10.3.2 via a more or less manual reinstall of emoncms on a debian system which was reasonably painless considering emoncms is built for PIs

I did this to be able to backup my system from the webgui. However it didn't work. Pressing the backup button, absolutely nothing happened.

The problem. The backup_controller.php uses this line to push to redis:
$redis->rpush("service-runner","$export_script $export_flag>$export_logfile")

But the service-runner.py was doing nothing. A little bit of python monitoring thus:

import redis
server = redis.Redis()
with server.monitor() as m:
   for command in m.listen():
      print (command)

...revealed that when pressing the Create backup button backup_controller.php was sending this to redis: (shortened a bit..)

u'command': u'RPUSH emoncmsservice-runner /opt/emoncms/modules/backup/emoncms-export.sh

But this code in service-runner.py:

      if server.exists('service-runner'):
        flag = server.lpop('service-runner')
      elif server.exists('emoncms:service-runner'):
        flag = server.lpop('emoncms:service-runner')

checks for 'service-runner' or 'emoncms:service-runner and not the 'emoncmsservice-runner' which is being posted by the .php

Note the discrepancy over the colon after 'emoncms' and before 'service-runner'
I've not discovered yet where this is set in emoncms so for now I modifed the service-runner.py file and removed the colon from there. Once this was done the service-runner picked up the script and the backups sprang into life.

For the record my settings.ini file has this relating to redis:

; Redis Database (used as a cache for improved performance)
[redis]
enabled = true
host = 'localhost'
port = 6379
auth = ''
dbnum = ''

So it looks like a bug and not a configuration problem. Or at least a very nasty gotcha!
I thought this would be useful to know.

Posted in backup as that's what was being affected for me although it could be a service-runner issue or and emoncms (config but where?) issue.

Thanks.
Andy.

Edit: code formatting barf...

Import login re-direct

Status, flashed Oct18 SD, let update run.

On importing data I get this error
image

And it seems to have logged me out as I get an error if I try to access the administration screen

usb-import fails if just 2 partitions

if [ "$partprobe" == "/dev/$diskname: msdos partitions 1 2 3" ]; then

As per discussion (and solution) here the import fails if there are only 2 partitions i.e. the data is on the root partition.

The script recovers from this later when looking for the mysql database, but not for the data files in /var/lib.

Suggest an extra check is made to find the data folders (including phpfiwa).

Restoring large file fails without usable error message

https://community.openenergymonitor.org/t/backup-v2-1-7-error-restoring-an-local-emonbase-backed-up-today-image-emonsd-17oct19-stable/12522

A large backup file restore failed with an error that did not make sense to the user. It seems it failed because the backup file was too large.

Should the size of file that can be backed up match the size of a file that can be restored?

If a data partition of 10Gb is being created, it should be possible to backup and restore larger data sets.

backup module no longer backs up old emonpi images

=== Emoncms export start ===
Tue Jan 2 14:47:27 UTC 2018
EUID: 1000
Reading /home/pi/backup/config.cfg....
Location of mysql database: /home/pi/data
Location of emonhub.conf: /home/pi/data
Location of emoncms.conf: /home/pi/data
Location of Emoncms: /var/www/emoncms
Backup destination: /home/pi/data
old image
Log is turned off
Stopping feedwriter: stopped
Emoncms MYSQL database dump complete, adding files to archive ..
tar: Removing leading '/' from member names
tar: /home/pi/data/node-red/flows_emonpi.json: Cannot stat: No such file or directory
tar: /home/pi/data/node-red/flows_emonpi_cred.json: Cannot stat: No such file or directory
tar: /home/pi/data/node-red/settings.js: Cannot stat: No such file or directory
tar: Exiting with failure status due to previous errors
Error: failed to tar config data
emoncms export failed

non-default backup destination not working

the problem is that the ~/data directory is getting full of daily backup files.

It'd be tidy if the default backup location for the backup was another directory within ~/backup

for example I have ~/backup/backups made

but when I set it in config.cfg I get this error:

Screen Shot 2019-07-20 at 11 19 26

Import script needs to logout user session

When import script successful imports an old backup for best user experience it should auto log out the current user session landing the user back at the login page where they can log in with the newly import account credentials.

Check if a config file already exists

A check needs to be done to not overwrite an existing config file.

backup/install.sh

Lines 39 to 42 in ad179f8

# Creating backup module config.cfg file
echo "- Copying default.config.cfg to config.cfg"
cp default.config.cfg config.cfg
echo "- Setting config.cfg settings"

hash symbols in config.cfg causing an error

ref https://community.openenergymonitor.org/t/permanent-raspberry-pi-booting-after-failed-emonpi-update/10963/22?u=pb66 and https://www.php.net/manual/en/function.parse-ini-file.php

Originally I submitted PR #37 to swap out the hashes for semi-colons but that caused and issue for the bash script so I closed it again.

Note that reading the parse_ini_file() changelog the use of hashes should effect php7.0 users, but as it turns out, the linked case is a php5.6 setup ????

Emonhub.conf is not always imported correctly

backup/usb-import.sh

Lines 217 to 227 in 9cfc5b8

# Copy emonhub conf
# ---------------------------------------------------------------
# New structure
if [ -f /media/old_sd_root/etc/emonhub/emonhub.conf ]; then
sudo cp -fv /media/old_sd_root/etc/emonhub/emonhub.conf $emonhub_config_path/emonhub.conf
fi
# Old structure
if [ -f /media/old_sd_data/emonhub.conf ]; then
sudo cp -fv /media/old_sd_data/emonhub.conf $emonhub_config_path/emonhub.conf
fi
# ---------------------------------------------------------------

From a number of queries in the community, I suspect that emonhub.conf i not always imported correctly.

Because there are 2 ifs it is possible that the one in use, could be overwritten by a very old version.

Compress to a single if and save the default version. Bias towards the new structure configuration

file with a size of 3G not anymore accepted by PHP82

post_max_size = 3G

PHP Warning:  Invalid "upload_max_filesize" setting. Invalid quantity "3G": value is out of range, using overflow result for backwards compatibility in Unknown on line 0
PHP Warning:  Invalid "post_max_size" setting. Invalid quantity "3G": value is out of range, using overflow result for backwards compatibility in Unknown on line 0

same pb with 2G, only 1G seems to be OK

Still refers to php5

The install instructions (and possibly the module) have not been updated to Stretch.

User permissions are hardcoded

These scripts rely too heavily on hardcoded paths and assume the 'pi' user.

When installed on a different system (such as ubuntu) with a different username, the various scripts fail (import for instance) because of this.

Use hostname as part of backup filename

For people that have multiple emonPi / emonCMS installations it would be better for the backup filename to include the machine hostname.

e.g.
myemonpi-emoncms-backup-2020-04-28.tar

Username does not exist

Doing a restore on a non-pi emoncms Ubuntu install. Import database seems fine, but can't login or register.

Sidebar compatiablity

The Backup module needs sidebar compatible menu added. The backup module has it's own sidebar menu to switch between Export / Import pages.

Backup not possible

When I try to create a backup via GUI, it shows me the following error: Segmentation fault.
Is there a way to fix this?

Server Information

Server Information

Services

  • emonhub :- Active Running
  • emoncms_mqtt :- Active Running
  • feedwriter :- Active Running - sleep 60s 49 feed points pending write
  • service-runner :- Active Running
  • emonPiLCD :- Active Exited
  • redis-server :- Active Running
  • mosquitto :- Active Running

Emoncms

  • Version :- low-write 10.1.5
  • Modules :- Administration | App v2.0.3 | Backup v2.1.1 | EmonHub Config v2.0.3 | Dashboard v2.0.4 | Device v2.0.1 | EventProcesses | Feed | Graph v2.0.3 | Input | Postprocess v2.1.0 | CoreProcess | Schedule | Network Setup v1.0.0 | sync | Time | User | Visualisation | WiFi v2.0.1
  • Git :-

Server

  • OS :- Linux 4.14.71-v7+
  • Host :- emonpi | emonpi | (10.11.120.190)
  • Date :- 2019-11-03 22:37:00 UTC
  • Uptime :- 22:37:00 up 70 days, 10:47, 0 users, load average: 0.14, 0.15, 0.10

Memory

  • RAM :- Used: 27.22%
    • Total :- 976.74 MB
    • Used :- 265.9 MB
    • Free :- 710.84 MB
  • Swap :- Used: 0.25%
    • Total :- 100 MB
    • Used :- 256 KB
    • Free :- 99.75 MB

Disk

  • / :- Used: 44.51%
    • Total :- 3.81 GB
    • Used :- 1.7 GB
    • Free :- 1.94 GB
  • /boot :- Used: 51.69%
    • Total :- 42.52 MB
    • Used :- 21.98 MB
    • Free :- 20.54 MB
  • /home/pi/data :- Used: 1.33%
    • Total :- 10.35 GB
    • Used :- 140.92 MB
    • Free :- 9.69 GB

HTTP

  • Server :- Apache/2.4.25 (Raspbian) HTTP/1.1 CGI/1.1 80

MySQL

  • Version :- 5.5.5-10.1.23-MariaDB-9+deb9u1
  • Host :- localhost:6379 (127.0.0.1)
  • Date :- 2019-11-03 22:37:00 (UTC 00:00‌​)
  • Stats :- Uptime: 6167142 Threads: 2 Questions: 60860 Slow queries: 0 Opens: 64 Flush tables: 1 Open tables: 40 Queries per second avg: 0.009

Redis

  • Version :- 3.2.6
  • Host :- localhost:6379
  • Size :- 463 keys (800.06K)
  • Uptime :- 71 days

MQTT Server

  • Version :- Mosquitto 1.4.10
  • Host :- localhost:1883 (127.0.0.1)

PHP

  • Version :- 7.0.30-0+deb9u1 (Zend Version 3.0.0)
  • Modules :- apache2handler | calendar v7.0.30-0+deb9u1 | Core v7.0.30-0+deb9u1 | ctype v7.0.30-0+deb9u1 | curl v7.0.30-0+deb9u1 | date v7.0.30-0+deb9u1 | dom v20031129 | exif v7.0.30-0+deb9u1 | fileinfo v1.0.5 | filter v7.0.30-0+deb9u1 | ftp v7.0.30-0+deb9u1 | gd v7.0.30-0+deb9u1 | gettext v7.0.30-0+deb9u1 | hash v1.0 | iconv v7.0.30-0+deb9u1 | igbinary v2.0.1 | json v1.4.0 | libxml v7.0.30-0+deb9u1 | mbstring v7.0.30-0+deb9u1 | mcrypt v7.0.30-0+deb9u1 | mosquitto v0.4.0 | mysqli v7.0.30-0+deb9u1 | mysqlnd vmysqlnd 5.0.12-dev - 20150407 - $Id: b5c5906d452ec590732a93b051f3827e02749b83 $ | openssl v7.0.30-0+deb9u1 | pcre v7.0.30-0+deb9u1 | PDO v7.0.30-0+deb9u1 | pdo_mysql v7.0.30-0+deb9u1 | Phar v2.0.2 | posix v7.0.30-0+deb9u1 | readline v7.0.30-0+deb9u1 | redis v4.1.1 | Reflection v7.0.30-0+deb9u1 | session v7.0.30-0+deb9u1 | shmop v7.0.30-0+deb9u1 | SimpleXML v7.0.30-0+deb9u1 | sockets v7.0.30-0+deb9u1 | SPL v7.0.30-0+deb9u1 | standard v7.0.30-0+deb9u1 | sysvmsg v7.0.30-0+deb9u1 | sysvsem v7.0.30-0+deb9u1 | sysvshm v7.0.30-0+deb9u1 | tokenizer v7.0.30-0+deb9u1 | wddx v7.0.30-0+deb9u1 | xml v7.0.30-0+deb9u1 | xmlreader v7.0.30-0+deb9u1 | xmlwriter v7.0.30-0+deb9u1 | xsl v7.0.30-0+deb9u1 | Zend OPcache v7.0.30-0+deb9u1 | zlib v7.0.30-0+deb9u1

Pi

  • Model :- Raspberry Pi 3 Model B+ Rev 1.3 - 1GB (Sony UK)
  • SoC :- Broadcom BCM2835
  • Serial num. :- B4C03494
  • Temperature :- 56.38°C - 56.9°C
  • emonpiRelease :- emonSD-30Oct18
  • File-system :- read-write
Client Information

Client Information

HTTP

  • Browser :- Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.70 Safari/537.36
  • Language :- en-US,en;q=0.9

Window

  • Size :- 1903 x 937

Screen

  • Resolution :- 1920 x 1080

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.