Why is this curl script not working? It just prints out the html from a hubitat page on the command line and doesn't do anything else. The variables are defined but obviously not included here.
Yes, probably is the same script as I got it elsewhere in the forums. I do have "Hub Login Security" checked on the "Hub Login Security" settings screen if that's what you're asking.
For folks who are finding this and still looking for a solution:
Couple quick edits to that backup script --
use this to get the find command to work (my Synology needed this version, but it should work almost anywhere): find "$backupdir" -name "*.lzf" -mtime +10 -exec rm {} \;
(If you're nervous about that rm command, first change the rm to ls -l and run it to see what files it finds.)
And my backupdir has a space in the name, so I needed a bunch of " around things. Here's my updated version:
#!/bin/bash
# Script to download hubitat backup
he_login="XXX" #This is the username you use to log into the hub
he_passwd="XXX" #This is the password you use to log into the hub
he_ipaddr="XXX" #This is the host name or IP of the hub
backupdir='/volume1/Dir With Spaces/HubitatBackups'
cookiefilename="/cookiefile.txt"
cookiefile=$backupdir$cookiefilename
backupfile=$backupdir/LVRM_$(date +%Y%m%d-%H%M).lzf
#Delete Files more than 10 days old
find "$backupdir" -name "*.lzf" -mtime +10 -exec rm {} \;
# Fetch login page with user/pass to get a session cookie
curl -k -c "$cookiefile" -d username=$he_login -d password="$he_passwd" https://$he_ipaddr/login
# Now get the actual backupfile sending the session cookie
curl -k -sb "$cookiefile" https://$he_ipaddr/hub/backupDB?fileName=latest -o "$backupfile"
# remove the session cookie file
rm "$cookiefile"
If you're having issues, you can always get debugging output by bash -x scriptname