@alexbloor gave me the login and I went through the usb-import.sh script manually copying commands to work with the structure that he had. It’s all up and running now.
For anyone reading this thread with a similar issue around unrecognised structure, this is the process i went through based on the usb-import script: backup/usb-import.sh at master · emoncms/backup · GitHub
The usb import script had already created the old_sd_root and old_sd_boot mount directories, so I mounted the SD card with:
sudo mount -r /dev/sdb2 /media/old_sd_root/
sudo mount -r /dev/sdb1 /media/old_sd_boot/
You can check at this point that the disk did mount and that you can see the files in each partition.
Next stop running scripts:
sudo systemctl stop emonhub
sudo systemctl stop feedwriter
sudo systemctl stop emoncms_mqtt
sudo systemctl stop mariadb
Check or find the old mysql data directory:
ls /media/old_sd_root/var/lib/mysql/emoncms/
Delete the directory on the new SD card:
sudo rm -rf /var/lib/mysql/emoncms
Copy the old mysql data directory across in it’s place:
sudo cp -rv /media/old_sd_root/var/lib/mysql/emoncms /var/lib/mysql/emoncms
Correct the permissions:
sudo chown mysql:mysql /var/lib/mysql/emoncms
sudo chown -R mysql:mysql /var/lib/mysql/emoncms
Start mariadb:
sudo systemctl start mariadb
Check/repair tables (password: emonpiemoncmsmysql2016)
mysqlcheck -A --auto-repair -uemoncms -p
Update database:
php /opt/openenergymonitor/EmonScripts/common/emoncmsdbupdate.php
Copy data files across (luckily in @alexbloor’s case only PHPFina no PHPFiwa to convert)
sudo cp -rfv /media/old_sd_root/var/lib/phpfina /var/opt/emoncms/phpfina
sudo cp -rfv /media/old_sd_root/var/lib/phptimeseries /var/opt/emoncms/phptimeseries
If the files copy to /var/opt/emoncms/phpfina/phpfina you will need to move them back to /var/opt/emoncms/phpfina Im not sure what I did wrong here but I had to do that…
Correct permissions:
sudo chwon -R www-data:root /var/opt/emoncms/phpfina
sudo chown -R www-data:root /var/opt/emoncms/phptimeseries/
Lastly you may want to copy your existing emonhub configuration, or I would suggest it might be better to use the new configuration and remap inputs and feeds if required.
The old configuration can be found here:
sudo nano /media/old_sd_root/etc/emonhub/emonhub.conf
Restart all the scripts:
sudo service emonhub restart
sudo service feedwriter restart
sudo service emoncms_mqtt restart
Check that emonhub is running and that data is coming through:
tail -f /var/log/emonhub/emonhub.log
Check your inputs and feeds, remap inputs as required.