Is it possible to create and download new local backup programmatically?

It seems like, although I'm not sure, it would be worthwhile to download a local backup onto a laptop periodically instead of just depending on the hub backup copy.

Is it worthwhile; is it possible to set up a schedule; and how would one do this?

Thanks.

1 Like

I download backups each night to a raspberry pi and keep 14 days worth. The script is posted somewhere around here, I can dig it out if you are interested. If you are running Windows I'm sure the same thing could be done using PowerShell.

I upload my database backups to Dropbox twice/week using Node Red. It has to download the DBs to the Raspberry Pi hosting Node Red first so I probably take one more step than @sburke781.

There is a wget for Windows 10, so by using the Windows Scheduler to run a cmd file (or PowerShell) you can invoke the wget command to force a backup and download

 cd c:\HubitatBackupLocation
wget --content-disposition -P /HubitatBackupLocation  http://hubIpAddress/hub/backupDB?fileName=latest
3 Likes

This all is going to take some learning for me.

here is an auto backup setup for a qnap nas..

Couldn't I do that get from inside RM? I tried this but it didn't work, but if I put it in a browser address line, it does download.

you cannot "send a get" to another machine. it has to run on that machine..

if you have ftp or sftp servers running. you could download and ftp to the other machine.

exactly what type of machine are you trying to get a nightly backup downloaded to?

My laptop.

If you want to download to your Windows Laptop, then @thebearmay’s solution sing Windows Scheduler would likely be the easiest solution. I had implemented this a while back on an always-on laptop and it worked well.

1 Like

as thebearmay said you need to get wget on your pc and setup in windows scheduler if you want an auto backup, but if a laptop i doubt it is up 24/7 so may not be your ideal solution..

maybe invest in an inexpensive 2 disk nas either qnap or synology and setup a nightly job there. or if you do have a windows box that is up 24/7 set it up there.

You can use Task Scheduler in Windows to run a batch script that will grab a backup as often as you want. I have mine doing it every Wednesday morning.

You don't need a machine that is on 24/7 if you run task as soon as possible after scheduled start is missed. If I don't turn on my computer on Wednesday (when my backup is scheduled), it will run whenever I do turn it on.

image

Anywho, here's my batch script in another thread. I had to download and install wget for this to work.

Save the script in a text document with a .bat extension. You can also run it manually by double clicking on it in a folder to test the paths in the script.

3 Likes

I didn't realize this and the other tools even existed. Thanks.

Looking at that other thread, was there a problem with using Task Scheduler directly vs your .bat method? I noticed someone mentioned about his retention limit not letting him save a new file unless a file was deleted first. Is that why you went the .bat route? Also, any opinion on why the sequential integer after the .lzf extension? Thanks.

The option --content-disposition is not in PS 5.1. If running wget on Windows, are you running PS 7.x?
(In Windows wget is an alias for Invoke-WebRequest.)

Well, it's working. Just using Windows Task Scheduler, no .bat files. Popped up at 9 this morning, as planned. Made it hidden.

Although I've never used it, the folder I'm backing up to is synced with the trial version of OneDrive, so I guess it's in the cloud too.

I didn't see anything so far about 'retention', maybe in wget? No big deal to erase some old files manually.

I like the fact that there are once a day updates, off-hub. If all of the on-hub backups are somehow screwed up, like after a firmware update or something, you have something else to fall back on.

edit: I've got that 'run task as soon as possible if missed' box checked as well.

1 Like

As long as you bear in mind that this backup is just the hub’s h2 database. Radio data is not included. Nor are files that were uploaded using File Manager.

Well, that's the same as if you press the button on the backup/restore page, no? For more stuff you have to pay, I thought.

Correct. And I’ve needed to use radio backups on a few occasions - so it is well worth it, IMO.

3 Likes

Ha! I didn't even think that I could run it directly from the Task Scheduler. My .bat also deletes backups older than 90 days, but you can probably add another scheduled task for that as well.

1 Like