Community
OpenEnergyMonitor

Community

Backup module usb-import.sh script (beta)

Tags: #<Tag:0x00007fc351065268>

Excellent. What I would say is that it would be really useful if this was an option on first setup rather than having to register a user, then upload the data.

An option at the register stage to import data would be even better :grinning:.

Will it pick up in-built usb card readers on laptops?

I agree that would be nice.

At the moment it looks for ‘usb-Generic_Mass-Storage’ in the disk name, so probably not.

Stupid question actually, as designed, it need to be plugged into the actual Pi.

I was thinking you might want to use it, to import an SD card to a local copy of emoncms running on your laptop… I think it should work, if you use a USB reader.

No I was thinking of accessing the web interface - totally daft suggestion.

One advantage of this usb import approach is that it can in certain cases be used to recover a corrupted SD card were a previous backup archive was not made - or is quite old. If the SD card mounts ok the script may run without trouble, but if the damage is greater, running the file system consistency check utility (fsck) maybe needed before doing an import.

Both Glyn and I had our home systems go down following the same power cut in our village last weekend. While my system booted there were issues with emonhub and redis resulting from SD card corruption. I was able to recover using the importer tool without running fsck. Glyn’s on the other hand would not boot initially - but after running fsck we were able to mount the old SD card and run the import script.

Here are the steps to do this:

1. Insert SD card in SD card reader and plug in to the emonPi/emonbase/raspberrypi running a fresh copy of the emonSD image.
2. Attempt to recover the SD card partitions e.g:

sudo fsck.ext4 /dev/sda2 (root OS partition)
sudo fsck.ext2 /dev/sda3 (data partition)

3. Once complete, run the importer tool as above.

1 Like

And you’ve now both got spike protection… :grinning:

1 Like

Worth adding a page on the docs for this I’d suggest.

1 Like

Actually, @TrystanLea a comprehensive guide on upgrading an SDCard would be fantastic. I cannot remember what is out there right now.

My current advice would be

You are running an older setup. My advice is to upgrade to the lastest version. emonSD-17Oct19 release

To do this;

1 Like

I’ve added the USB import method now to the backup module guide and to a new guide on updating and upgrading emonpi/emonbase systems.

Backup Guide:
https://guide.openenergymonitor.org/setup/import

Update and Upgrade
https://guide.openenergymonitor.org/setup/update

Thanks @borpin for your start on this, you will see I’ve made use of what you wrote here: https://github.com/openenergymonitor/emonpi/wiki/Restore-Data-From-SD-Card-(USB)

1 Like

@TrystanLea great. Could you add in a bookmark for the Upgrade section so a direct link can be created to it please?

Couple of things.

“Place the old SD card in a SD” I think it should be ‘an’ so “Place the old SD card in an SD”

“Create a temporary user on the new system if you have not done so already.”

This instruction could be confusing as to whether you mean a user on the OS or on the EmonCMS system. Perhaps

“From the EmonCMS login page, click register and create a temporary user. Once the import is complete the original user details will be used.”

and add

“5. Once the import is complete, log out and back into the EmonCMS page with the original user details”.

1 Like

Great will add those in, thanks @borpin

1 Like

Thanks @borpin I’ve made the changes you suggested. Apparently bookmarks work to any heading, you just need to type the full heading in lower case and with dashes:

https://guide.openenergymonitor.org/setup/update/#upgrading-to-a-new-emonsd-image

For some headings the link appears when you mouse over as in

image

I could not get the USB import to work so went to a ssh session and found my USB device was found as


I edited the https://github.com/emoncms/backup/blob/master/usb-import.sh
usb=$(ls $disk_id | grep ‘usb-Generic_Mass-Storage’) to usb=$(ls $disk_id | grep ‘usb-Generic’)

1 Like

also they should be a little more checking, if you click import from USB without the usb the web interface dies with
’ Can’t connect to database, please verify credentials/configuration in settings.php
Error message: Unknown database ‘emoncms’

Thanks @Pukka, that’s useful to know, I did wonder how many varients on the grep search term for the usb-Generic… there might be. I’ve created a github issue to keep track of this https://github.com/emoncms/backup/issues/52.

1 Like

Yet another example of why new “features” need to be “wrung out” before getting released.

I was sure I’d tested this one, its now fixed, thanks!

I have just updated to emonSD-17Oct19 and get “USB drive not found”. The USB drive is: