Backup command from HTTP

530 views
Skip to first unread message

TriLife

unread,
Jan 16, 2022, 10:51:32 AM1/16/22
to TasmotaUsers
Greetings;

I need to back up all of my sonoff switches (100+), because it seems that occasionally they revert to factory for some mysterious reason (power fluctuations, most likely).

I know how to do it from the WEB GUI, but it involves a lot of steps.

Can I not do this from an HTTP request, so I only have to change the IP address?

Thanks

Philip Knowles

unread,
Jan 16, 2022, 11:39:39 AM1/16/22
to TriLife, TasmotaUsers

It’s worth looking at TasmoAdmin because, no, it’s not possible to backup via MQTT or HTTP request.

 

Regards

 

Phil K

 

 

 

Sent from Mail for Windows

--
You received this message because you are subscribed to the Google Groups "TasmotaUsers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sonoffusers...@googlegroups.com.
To view this discussion on the web, visit https://groups.google.com/d/msgid/sonoffusers/e7d1ede5-4a45-444b-b373-2110122807e9n%40googlegroups.com.

 

Jean-Robert STRELE

unread,
Jan 16, 2022, 1:04:00 PM1/16/22
to Philip Knowles, TasmotaUsers
Thanks Phil;

That looks interesting indeed.

With fairly frequent updates, being able to update all of them is a sweet feature. But it doesn't seem to work with TasmoAdmin. I tried it out with a single switch, using AUTOMATIC. It initiates the update to 10.1.0 from 9.5.0. and after about 60 seconds says that the update was successful. However, when I go to the WebUI of the switch, it still shows it at the original 9.5.0. Using tasmota.bin from the OTA site.

Cheers.


Piotr Antczak

unread,
Jan 16, 2022, 1:45:47 PM1/16/22
to TasmotaUsers
I'm using https://github.com/tasmota/decode-config to backup regularly all of my devices. 
What I do is call a wrapper script, which discovers all my devices via mqtt and then passes this information to decode-config.py script to backup their configuration.
This way I don't have to worry about new devices I introduced (they will be discovered via mqtt next time the backup script runs), and don't have to worry about devices which are gone (no error messages in backup log) - the script backups only online devices.

For a simple solution you can call decode-config.py script in a loop over all of your devices. Then when you add a new device, you have to remember to add it to the list of devices in a script, and when you remove one just remove it from the list. Here is a quick example (not tested!!!!):
#!/bin/env bash
devices=(192.168.10.15
  192.168.10.16
  192.168.10.17
  192.168.10.18)

for device in ${devices[*]};do
  decode-config.py -s $device -o Bac...@H.dmp
done

 





--
Piotr Antczak

Ron L

unread,
Jan 16, 2022, 6:55:31 PM1/16/22
to TasmotaUsers
+1 on using "decode-config.py" for backups.  I am using this on a Windows10 machine, basically install Python3, Pip3 and the dependencies per instructions (using Windows10 PowerShell).  While I am not a script writer, I leveraged a script provided by @Greg from Oz which is slightly different than @Piotr's script above in that you just provide a "range" of IP's.
I created the destination directories manually.

$DATALOC="\Tasmota\TasmotaConfigBackups"
$val = 5        # lowest IP of Tasmota devices
$upperVal = 50        # highest IP of Tasmota devices + 1

while($val -ne $upperVal)
     {
           $ADDR = "192.168.1." + $val
       Write-Output $ADDR
           python /Tasmota/TasmotaConfigBackups/decode-config.py -u user -p password -d $ADDR -o $DATALOC/Config_@d_@v.dmp -o $DATALOC/Config_@d_@v.json
           $val++
     }
  
This script makes the traditional .dmp backup file as well as a .json file which is easier to read.

Tom

unread,
Jan 19, 2022, 6:49:08 AM1/19/22
to TasmotaUsers
You can easily run: curl -OJ http://tasmota.ip.or.host.name/dl 
This will download the current config file and save it as Config_tasmota-version_device-host-name.dmp

I run the following script to backup the devices which are currently online once a week:

mosquitto_pub -h mqtt.example.com -t 'cmnd/tasmotas/WebServer' -m '2'
datetime=`date +%Y%m%d_%H%M%S`
tasmotas=`mosquitto_sub -h mqtt.example.com -t 'tele/+/LWT' -v -W 1 | grep -Pv '(rpi4|Offline)' | sed -r 's#tele/([^/]+)/.*#\1.example.com#'`
for tasmota in $tasmotas; do
    curl -OJ http://$tasmota/dl
done
rename Config_ ${datetime}_Config_ Config_*.dmp
mosquitto_pub -h mqtt.example.com -t 'cmnd/tasmotas/WebServer' -m '1'


Tom

Dne pondělí 17. ledna 2022 v 0:55:31 UTC+1 uživatel Ron L napsal:

trei...@gmail.com

unread,
Jan 22, 2022, 5:40:14 AM1/22/22
to TasmotaUsers

Hi tom, 
script is very interessting for me but run into errors.

question, what to rename in sed : /.*#\1.example.com#'` ? 
Thx  

Tom

unread,
Jan 24, 2022, 11:30:20 AM1/24/22
to TasmotaUsers
Hi,

this sed just translates "tele/light.kitchen/LWT Online" as returned by mosquitto_sub into "light.kitchen.example.com" so I can use it easily within the for-loop with cUrl 

Tom

Dne sobota 22. ledna 2022 v 11:40:14 UTC+1 uživatel trei...@gmail.com napsal:
Reply all
Reply to author
Forward
Message has been deleted
Message has been deleted
Message has been deleted
0 new messages