Skip to content

Instantly share code, notes, and snippets.

@bdwilson
Created March 21, 2020 00:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bdwilson/e320283934447f2a964b1a7a03677265 to your computer and use it in GitHub Desktop.
Save bdwilson/e320283934447f2a964b1a7a03677265 to your computer and use it in GitHub Desktop.
Backup hubitat device using last backup file created.
#!/bin/bash
#
# Code borrowed from https://community.hubitat.com/t/solved-downloading-latest-backup-file/18065/5
#
IP=$1
DIR="$2"
if [ $# -eq 0 ]; then
echo "Usage: $0 <IP Address> <Path to store backup>"
else
curl -s http://${IP}/hub/backup | grep data-fileName | grep download | sed 's/<td class=\"mdl-data-table__cell--non-numeric\"><a class=\"download mdl-button mdl-js-button mdl-bu
tton--raised mdl-js-ripple-effect\" href=\"#\" data-fileName=\"/\ /' | sed 's/\">Download<\/a><\/td>/\ /' | sed 's/ //g' | tail -1 | xargs -I @ curl -s -o ${DIR}/${IP}_@ http://${IP}/h
ub/backupDB?fileName=@
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment