Automatic download backups for Hubitat

It's fantastic that Hubitat does automatic backups, but to me the point of the backup is to have an offsite version if something happens locally. e.g. Hubitat hardware dies. So I've been making it a habit to download the backup as often as I can remember, but not as often as I should.

This may also break the local-only philosophy but it would also be nice if we could set a path for these downloads to a cloud-based service, e.g. send uploads to my Google Drive account on a daily or weekly basis. May pose security concerns though.

2 Likes

You might find some answers on how to accomplish this in the following thread. I personally use a Scheduled Task on my Windows PC to download a backup of my hub every morning at 6am.

4 Likes

I do the same, but using a cron job, wget and the OneDrive CLI Client for Linux (my work provides me with a 1TB OneDrive share for personal use, so I use it lol).

I 100% agree there needs to be some work done to allow a user to choose an auto backup place in the cloud. Start with Google Drive and go from there.

I wrote the following dirt-simple VB6 program to do nightly backups of all three of my hubs:

Option Explicit

Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long

Sub Main()
Dim ret As Long

ret = URLDownloadToFile(0, "http://192.168.1.10/hub/backupDB?fileName=latest", "\\server\backups\Hubitat 0.lzf", 0, 0)
ret = URLDownloadToFile(0, "http://192.168.1.11/hub/backupDB?fileName=latest", "\\server\backups\Hubitat 1.lzf", 0, 0)
ret = URLDownloadToFile(0, "http://192.168.1.12/hub/backupDB?fileName=latest", "\\server\backups\Hubitat 2.lzf", 0, 0)

End Sub

This program gets triggered at 3:30 AM every day; some other code on my server moves the files out of "backups" to individual directories.

I do not have a computer at home that is on all the time I only have a laptop that I use for work so having a nightly script run is not going to work for me. I am thinking that I am going to create a Google Function that will do the HTTP get request from the cloud and then store it in a Google Storage Bucket. I will have to punch a hole in the firewall to do this. I wish Hubitat had a push command so that you could push the file to a URL at night so that I did not have to open my firewall. This needs to be automated and automated from the Hubitat device and offsite or else it's not a back up to be honest and even after owning my device for only 2 weeks I would not want to start from scratch!!

Have you considered getting an SBC like a RPi. They don't consume much power, and there's plenty of cron & curl based backup script examples that you can find here.

An added bonus is the ability to use Hubitat integrations that use NodeJs servers (or anything else that runs on Linux).

3 Likes

Yeah that is actually a great idea to play middle man to the backup. I am going to test creating a cloud function to see if that works first as it required no hardware and I love using cloud storage for backups!

1 Like

The same can be done using a home NAS if you have one.
And most NAS devices have the ability to upload to cloud, Dropbox, Box, Google

1 Like

I wish I had a NAS :slight_smile: I want one for a Plex server but hard to convince the wife that it would be worth spending the money.

A NAS would be great for storing her pictures. :wink:

1 Like

I told her it would be like Netflix but our own downloaded movies so you don't have to cast them to the TV.. She's warming up to the idea....

1 Like

That's a great idea.

I didn't want to hijack this thread with my attempt so I created a new thread here for using Google Cloud to backup the Hubitat

If anyone is interested pop over to this thread..

Edit: updated to a little more proper powershell script with parameters

Add the hub name into the file name as well and you will have some new fans. :slight_smile:

I know a few people (especially with multiple hubs) wanted that so they could distinguish where the backup was from.

The hub name is now included. I made it into a script with parameters.

2 Likes

So, I'm not clear on how I can use this, being that I have a Mac Mini and a Synology NAS to work with. Or do I have to have an always-on windows machine?

There are curl scripts in the community that you can use on a Mac or NAS. The NAS is probably the better choice since it is a storage device and likely doesn't get powered down.

Edit @JustinL there are several in this thread [SOLVED] Downloading Latest Backup File

Here is a very simple one as well.

The backup generated with your script seems to be a lot smaller than the native Hubitat backup. I feel like something is going wrong somewhere. Do you have any suggestions on why your scripts backup is much smaller?

Download the Hubitat app