Hub file overwritten after reboot

I have 2 hub files I log data to periodically, with "Append" in the rule machine. One logs every minute and the other every hour. The minute log file has been collecting data since August, and had grown to a few MB. After a recent reboot I noticed the file had been emptied, like the first Append after the reboot executed as a Write, instead. The hourly file was not affected, and retained all of the pre-reboot data. The reboot was due to a power outage and restore. Any thoughts on why this would happen, or how to avoid it in the future?

Put your hub on an Uninterruptable Power Supply (“UPS”).

Also, back up your File Manager files periodically:

2 Likes

Thanks. I've avoided the UPS as everything the hub controls is down when then power is down, and comes back with the power. Haven't had any problems with that until now. I'll look into the backup manager. Though it would be simpler if my PC could just copy the files off of the hub periodically.

You may misunderstand the purpose of the UPS. It’s not to keep the hub operating while power is down. Instead, it’s to prevent database corruption on the hub. The underlying database package used by the hub is, um, somewhat fragile. Corruption can occur during power fail.

If you have a UPS and also have something on your system to detect power fails, you can set up a rule to shut your hub down cleanly before the UPS is exhausted. I use Ring Extender Gen 2 devices, which send a power fail event to the hub. A Rule shuts the hub down cleanly after a few minutes if power hasn’t been restored.

1 Like

Thanks, was not aware the database was that vulnerable. Once your hub is shutdown, do you have a way to automatically/remotely restart it when the power comes back? Or do you have to do that locally/manually?

Well, you can do it manually, but, if you want to do it automatically, you need to put the hub on a WiFi controlled outlet and remove and restore power to the (then shut down) hub so that it reboots. I am able to VPN into my home if I am away so that I can reboot the hub by cycling that WiFi outlet, or I can ask Alexa to do it. Except for one extended power fail of a week a while back during a bad storm, our power is rarely out for more than a short time.

2 Likes

Good, I just put my hub on an Alexa wifi outlet I had, so I could reboot it remotely, if it wasn't talking. Had a low memory issue and the app couldn't connect. I've installed the HubInfo device so I can anticipate low memory and have it reboot itself if it happens again. Still wanted the external reboot option of some other issue came up. Gives me more to think about integrating a UPS into the scheme.

1 Like

I now have a script that runs on the PC and copies the log files everyday to a file on the PC. The file name is date stamped so I can purge older files. They are then backed up with my normal PC backups. That protects my accumulated data sufficiently.