Created
December 13, 2022 20:43
-
-
Save cbenard/6c917e5c6cc7d6aedf88b20d1853a657 to your computer and use it in GitHub Desktop.
Zigbee2MQTT Automated Backup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Requirements: | |
# Requires jq, base64, and unzip to be installed | |
MQTT_HOST=mosquitto | |
MQTT_USER=USERNAME_HERE | |
MQTT_PASSWORD=PASSWORD_HERE | |
MQTT_NETWORK=homeassistant_mqtt | |
MQTT_JSON=mqtt_output_zigbee2mqtt.json | |
MQTT_ZIP=zigbee2mqtt_backup.zip |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
SCRIPT=$(realpath "$0") | |
SCRIPTPATH=$(dirname "$SCRIPT") | |
source ${SCRIPTPATH}/backup_zigbee2mqtt.env | |
set -x | |
${SCRIPTPATH}/backup_zigbee2mqtt_background.sh & | |
sleep 1 | |
docker run -it --rm --network="${MQTT_NETWORK}" efrecon/mqtt-client \ | |
pub \ | |
-h $MQTT_HOST \ | |
-u $MQTT_USER \ | |
-P $MQTT_PASSWORD \ | |
-t "zigbee2mqtt/bridge/request/backup" \ | |
-m '{}' | |
sleep 4 | |
set +x | |
BASE64_ZIP=$(jq -r '.data.zip' ${SCRIPTPATH}/${MQTT_JSON}) | |
echo ${BASE64_ZIP} | base64 --decode --ignore-garbage > ${SCRIPTPATH}/${MQTT_ZIP} | |
set -x | |
unzip -l ${SCRIPTPATH}/${MQTT_ZIP} | |
rm -f ${SCRIPTPATH}/${MQTT_JSON} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
SCRIPT=$(realpath "$0") | |
SCRIPTPATH=$(dirname "$SCRIPT") | |
source ${SCRIPTPATH}/backup_zigbee2mqtt.env | |
set -x | |
docker run -i --rm --network="${MQTT_NETWORK}" efrecon/mqtt-client \ | |
sub \ | |
-h $MQTT_HOST \ | |
-u $MQTT_USER \ | |
-P $MQTT_PASSWORD \ | |
-t "zigbee2mqtt/bridge/response/backup" \ | |
-C 1 \ | |
-I zigbee_backup_receiver \ | |
-W 4 \ | |
> ${SCRIPTPATH}/${MQTT_JSON} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment