Compact/Repair DB on startup, rather than at time of day?

Joined
Jul 3, 2023
Messages
3
Reaction score
1
Location
Australia
Hi,

I'm running Blue Iris as a service on a computer which is turned on at a slightly unpredictable time of day each day. In our use case, we're using Blue Iris to interactively monitor camera feeds from the internals of a machine; it's not a surveillance system. When the cameras are needed the system is turned on, and when we aren't using them, the whole system is turned off. So I can't schedule a particular time of day when the Blue Iris server will always be turned on but the cameras will not be in use. While Blue Iris is running we do continuous recording.

We've been having issues with frequent corruption of the Blue Iris DB, which results in Blue Iris overflowing its allocated recording storage space, because it loses track of files that were already written to disk but where the corresponding DB records haven't been flushed to disk. I think the root cause of the DB corruption is that the PC sometimes is turned off by just cutting power rather than being properly shut down. Obviously that's bad for more reasons than Blue Iris alone, and I'm working on improving that situation, but right now it's not easy for me to guarantee that it always gets a proper shutdown. I accept that it's not reasonable to expect Blue Iris to avoid DB corruption under these circumstances; I don't think there's a Blue Iris bug.

But, regardless, because we're encountering DB corruption more often than we'd like, we want Blue Iris to do a database repair every time the service starts up. We would prefer to add a few minutes of startup delay to the system, rather than have to schedule the repair at a time of day where we would otherwise want uninterrupted operation & recording.

Is there a way to do this? E.g. via settings or scriptable command line instructions, or an API? I currently have 5.7.5.6 installed, but can upgrade if it will help.
 
Last edited:

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
17,047
Reaction score
39,653
Location
Alabama
Use Windows Task Scheduler to run BI's DB Repair upon startup but only after a slight delay giving time for BI to start as a service.
 
Joined
Jul 3, 2023
Messages
3
Reaction score
1
Location
Australia
Sounds good. What command should the scheduled task run to initiate the DB Repair? I didn't find the documentation of Blue Iris command line utilities/switches in the help PDF but I may have overlooked it.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
17,047
Reaction score
39,653
Location
Alabama
Sounds good. What command should the scheduled task run to initiate the DB Repair? I didn't find the documentation of Blue Iris command line utilities/switches in the help PDF but I may have overlooked it.
In BI's "Help", under "HTTP Interface", I found "/admin?db=rebuild, compact, or maintain Initiates the specified database operation."

So the complete URL would be "http://BI-server-IP:BI-port/admin?db=maintain" , I would assume.
 

Flintstone61

Known around here
Joined
Feb 4, 2020
Messages
6,688
Reaction score
11,080
Location
Minnesota USA
Any chance your " New" folder is on the C:\ drive where the OS and BI reside?
Can you give BI a bigger storage allotment? Like Terabytes bigger?
 

fenderman

Staff member
Joined
Mar 9, 2014
Messages
36,908
Reaction score
21,295
Simply leave the computer running... But not recording...
 
Joined
Jul 3, 2023
Messages
3
Reaction score
1
Location
Australia
I've gone through a couple of iterations of the storage layout, haha.

The current setup is that the OS, Blue Iris application, and Blue Iris DB are on C:\
All the video (I only use the New folder) is on D:\, which is dedicated to that purpose and has nothing else on it other than the Blue Iris video collection. D:\ is a 1.8 TB reasonably high-endurance SSD; the Blue Iris size limit is set to 1.6 TB to (hypothetically) ensure there should be a decent amount of slack space for the SSD's controller to manage wear levelling, block reallocations, etc.

That HTTP-based API looks like it will do the trick. I also note that the admin actions available via the HTTP API can also be invoked via MQTT. I'm already using MQTT for other things, so it might be a convenient way to hook up a small automation to trigger a compact/rebuild whenever the service reports that it's just started.

Thanks for the pointers!
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
17,047
Reaction score
39,653
Location
Alabama
It's a good thing it's not an old XP machine they're not shutting down properly.....:headbang:
 
Top