Skip to content

Instantly share code, notes, and snippets.

@oksbwn

oksbwn/backup.sh

Created Mar 28, 2020
Embed
What would you like to do?
A shell to script to backup openhab, nodred and influxDB
#!/bin/sh
currentDate=`date +%m-%d-%Y-%H:%M`
#backing up NodeRED
cd ~/.node-red
sudo cp flows_*.json /srv/openhab2-conf/.nodered/
sudo cp flows_*_cred.json /srv/openhab2-conf/.nodered/
sudo cp settings.js /srv/openhab2-conf/.nodered/
sudo cp package.json /srv/openhab2-conf/.nodered/
sudo cp .config.json /srv/openhab2-conf/.nodered/
sudo cp lib -R /srv/openhab2-conf/.nodered/
sudo cp .sessions.json /srv/openhab2-conf/.nodered/
sudo cp nodes -R /srv/openhab2-conf/.nodered/
#Backing up grafana
sudo cp /etc/grafana/grafana.ini /srv/openhab2-conf/.grafana/
sudo cp /var/lib/grafana/grafana.db /srv/openhab2-conf/.grafana/
sudo cp -R /usr/share/grafana /srv/openhab2-conf/.grafana/
# Backing up InfluxDB
# influxd restore -portable path-to-backup
export INFLUX_USERNAME=<admin_username>
export INFLUX_PASSWORD=<admin_password>
sudo rm -R /srv/openhab2-conf/.influxdb/
influxd backup -portable -host localhost:8088 /srv/openhab2-conf/.influxdb/
# Backing up MongoDB
mongodump -h localhost -d alberto -u node_red -p om -o /etc/openhab2/.mongodb
# Make evrything public
sudo chmod 777 -R /srv/openhab2-conf/
#Backing up Openhab Confs folder
cd /srv/openhab2-conf/
git add .
#git checkout master
git commit -m "Auto commit on "$currentDate
git push https://<github_username>:<github_password>@github.com/<username>/<repository> --all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.