dresden-elektronik / deconz-rest-plugin

deCONZ REST-API plugin to control ZigBee devices
BSD 3-Clause "New" or "Revised" License
1.9k stars 499 forks source link

RaspBee / ConBee configuration backup #620

Closed saurabh984 closed 5 years ago

saurabh984 commented 6 years ago

Hi there,

Could we please add a Wiki page here about reliable backup and restore options for deCONZ and RaspBee/ConBee settings including the ZigBee network?

Happy to write it if someone can point me in the right direction.

kylegordon commented 6 years ago

I'm not aware of an explicit export option for deCONZ, but I've had success in copying ~/.local/share/dresden-elektronik/deCONZ/ between locations. It appears to be a couple of SQLite databases (mainly zll.db)

ebaauw commented 6 years ago

There is an export/import function in the old web app. It's supported by (undocumented) API calls: https://github.com/dresden-elektronik/deconz-rest-plugin/blob/60491c02216fdcf620c8c418153aea6a788de19c/rest_configuration.cpp#L431

If memory serves, it creates a tar file of the ~/.local/share/dresden elektronik/deCONZ directory with an additional file containing the RaspBee/ConBee configuration (network key, etc).

manup commented 6 years ago

In the Phoscon App the same backup function is also available under Menu > Gateway > Settings. Currently multiple files are stored in the backup file. In the future most of the data will be stored in the zll.db sqlite3 database file since it is the superior format.

Skorfulose commented 6 years ago

Why is this closed? There is no Wiki page yet. I just created a stub and still have some questions: https://github.com/dresden-elektronik/deconz-rest-plugin/wiki/Backup-&-Restore

saurabh984 commented 6 years ago

Re-opened. I haven’t had the time to test this or document it yet!

saurabh984 commented 6 years ago

How can I migrate from RaspBee to ConBee? I have a RaspBee running on RPi 3 B+ and since it was moved inside a enclosed accoustic server rack in the garage I'm seeing some signal issues.

Can I just plug in the ConBee and the network settings will be preserved?

manup commented 6 years ago

The cleanest and recommend way would be to reset all devices in the RaspBee network and add them to ConBee network. Depending on the network size this may be complicated, but you could reuse the zll.db file from the RaspBee configuration.

saurabh984 commented 6 years ago

@manup Would just plugging in ConBee to the RPi and removing the RaspBee work? I have way too many rules and battery powered Aqara Devices to repair them all :(

manup commented 6 years ago

With a bit of work yes, after replacing RaspBee with ConBee and keep all deCONZ configuration files from RaspBee setup.

Then reset all devices and rejoin them, since they are still known by configuration and database they will just be reborn with the old settings, names, rules etc but. The only difference is they will belong to ConBee ZigBee network.

Note: Reset lights is easiest done with a Philips dimmer switch.

stale[bot] commented 5 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

popy2k14 commented 4 years ago

@ebaauw

Just to be clear, the tar.gz backup contains all to restore the bindings, Groups... all which is needed to restore the setup after an rpi/conbee HW failure?

Now i am running an bash script every sunday with the following contents:

!/bin/bash

backupdeconz bridge script, by Me :-)

echo Running backup... curl -k -S -v -H "Content-Type: application/json" http://####IP####:8080/ -X "POST /api/####APIKEY####/config/export" sudo cp /home/pi/.local/share/dresden-elektronik/deCONZ/deCONZ.tar.gz /mnt/mediaserver-backups/deconz/raspbee_gatewayconfig$(date +"%Y-%m-%d").dat echo deconz bridge config backuped!

thx a lot

ebaauw commented 4 years ago

The backup contains the REST API resources, the GUI settings, and the RaspBee/ConBee settings. It does not contain the settings stored on each ZigBee device, but the REST API plugin should re-create these from the resources.

popy2k14 commented 4 years ago

Ok thx a lot. Then it should be enough.

seal61 commented 4 years ago

Now i am running an bash script every sunday with the following contents:

Very nice - but how to get the API key? I've been searching for ages but cant find it. The only thing I found were some options in the phoscon web app that allow 3rd party apps to connect for 60seconds.

EDIT: nevermind, I got it - I installed iobroker, installed deconz zigbee adapter, in the settings of the adapter entered the IP and Port of the phoscon app, enabled 60s 3rd party access in phoscon app unter settings -> more settings, clicked on generate api key in deconz zigbee adapter, api key was filled out. using this api key also for my backup script.

popy2k14 commented 4 years ago

Nice that you can use my script and you found teh api key! Have fun :-)

MrWGT commented 3 years ago

Is the backup and restore also cross-platform? E.g. backup my old raspi (hoobs sd card) and restore on new x86 Linux (Ubuntu)?

Tnx Gerd

bastian-mer commented 3 years ago

Is the backup and restore also cross-platform? E.g. backup my old raspi (hoobs sd card) and restore on new x86 Linux (Ubuntu)?

Without absolute guarantee but as far as I see, there is not architecture specific binary code in the backup. I for myself migrated my ziggbee network without problems using the deCONZ backup functionality moving from an armhf to an arm64 platform.

rhdny commented 3 years ago

I moved my setup from an Ubuntu VM to a Docker container. The Phoscon backup and recovery worked great. The only thing I seem to be missing are the bulb configurations I made via the DeConz cluster interface (ex. power off return to previous state, color, etc).

It would be no fun to reset all those. Any idea where that configuration data is stored and if I can copy it over?

BabaIsYou commented 1 year ago

Based on your script I did some modification because the API doesn't take care of local DDF files, config.ini and zll.db WAL files (-shm and -wal files) when you change standard SQLite atomic rollback and commit to "Write-Ahead Log" option. Then I modified it to :

backup_path=/mnt/backup
retention_days=7
curl -k -S -v -H "Content-Type: application/json" http://####IP####:8080/ -X "POST /api/####APIKEY####/config/export"
tar -zcvf $backup_path/backup-DeConz-$(date +%Y%m%d).tar.gz  /home/pi/.local/share/dresden-elektronik/deCONZ
find $backup_path/$backup-DeConz-*.tar.gz -mtime +$retention_days -type f -delete