[RELEASE] File Manager Backup & Restore

Did a rewrite of the restore logic and managed to cut down the restore time by about 500%. Please upgrade to v1.2.0

4 Likes

Added an endpoint to allow retrieval of the backups to a NAS, rPi, etc. The script I'm running on my Synology is:

cd /volume1/HubitatBackups 
wget /volume1/HubitatBackups backupEndpoint -O fmBackupMain$(date +%Y-%m-%d_%H%M%S).hgz

The backupEndpoint value is now on the first screen of the app. As a result of the change OAuth will need to be enabled.

3 Likes

I assume during a soft reset the files are not wiped? Because i have done this and restored and my hubigraph files are still there.

Correct, although I have an app somewhere that will wipe the File Manager if you need it. (Who would have thought it? :rofl:)

2 Likes

This right here is exactly what I was looking for!! Is it also possible to pull the normal Hubitat Backup to the synology?

Just set up a scheduled task with something like:

cd /volume1/backupDirectory 
wget --content-disposition -P /volume1/backupDirectory http://<hubIP>/hub/backupDB?fileName=latest

Can you explain this command a little more. What does it do?

First line changes to the backup directory on the Synology, second line issues a get against the hub backup endpoint and stores it on the Synology.

2 Likes

Just ran into this thread by accident and thinking to myself ...... I should find a way get an alert when @thebearmay post a new subject. This will save me a lot of time looking for solutions he has already figured out and created an app for.
All I'm left with now is to find the way to reach this backup's endpoint using Node-red when the file was created and move it to my RPI.
@thebearmay , your work is very much appreciated

1 Like

There is an endpoint that you should be able to hit with an HTTP GET:

1 Like

Your code above is excellent for getting the files backed up because it uses an endpoint, and that way bypasses the user/password on /hub/backupDB (when hub security is enabled) that no one seems to be able to get by for automation purposes.

Any suggestions for that situation? This script is working like a champ and my Synology now has backups of my hubitat... except for the stuff in the normal backup which no amount of curl and wget I can come up with seems to let me get to. I don't like the idea of disabling hub security, so I may be stuck to manual backups.

Anyone?

To follow this up, the key is running curl once with user/pass to get a session cookie, and then a second time to pull the backup. Here's the script I'm using:

#!/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"

Note that if it doesn't work, you can call the script via bash -x scriptname and see what's happening under the covers. You may also need to choose a security password without special characters if you're not getting a result, or play the backslash-stuff-until-it-works game. (You'll know because the cookiefile will be empty.) The cookiefile should look like this:

# Netscape HTTP Cookie File
# https://curl.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.

YOURHUBIPADDR	FALSE	/	TRUE	0	HUBSESSION	node0SOMESTUFFHERE.node0
1 Like

Any possibility of renaming a LTS file being restored? That would ease the transition from Hubigraphs to webCoRE.

Could easily add logic to allow a change of extension as the no overwrite logic already has that code, if you need to change more than that it can be done, but might take a day or two.

Edit: Easier to write a quick File Manager Rename or Copy App. (https://raw.githubusercontent.com/thebearmay/hubitat/main/apps/fmCopy.groovy)

2 Likes

Thanks, brilliant. I did manage to hose it up. I was renaming three Hubigraph files to webCoRE. I renamed webCoRE to oldwebCoRE and hubigraph to webCoRE. Somehow I ended up deleting the hubigraph files and renaming the webCoRE files. I should have renamed them all to old first and then done the switch as a second step. Operator error and my graph data will catch up in a couple of days. In other news I can now remove the last remnants of Hubigraph which had worked well for me. Earlier today I mad a backup of the file mgr, restored the Hubigraph info files and gave it another go. For some reason the webcore graph doesn't see the older data. I thought renaming the file would do it but there must be something else at play.

Sorry, but don't know how to start a new topic. My issue is, running 2.3.8.118 on a C8, I successfully install the File Manager Backup and Restore but then it does not show up in the APPS section of the Hubitat. Where do I go to find the interface to this very useful mod?

Thanks.

Go to the Apps tab and Click Add user app, it should be listed there. Click it to install.

1 Like

From main community page: notice the button labeled + New Topic

2 Likes

wanted to check backups today - I handle them manually as well on occassion so not concerned - but got this message:


v1.3.1
Recommendations? delete the app and reinstall?
my DB is 34MB, with 312461 KB free mem per Hub Info

The hub’s next GC cycle should free the space back up