-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enhancement: Purging Database Without Losing Configuration Settings Or Export/Import Configuration Settings #175
Comments
The stored values are all UTC-based. The server uses the timezone only to set the date boundaries for its in-memory indexes and to tell the UI what timezone to display. So I'm not sure exactly what went wrong, but if you restart the server with the correct timezone and refresh the webpage, the previous timezone shouldn't matter at all. One annoying weakness in the current model is that the server communicates the timezone to the UI by name, rather than giving it the full rules associated with the timezone. If say the server has a different idea of what But yeah, an API to purge stuff is a totally reasonable request, as is config import/export. |
"purge all the data entries relating to recordings" is also required for the "I just deleted the video directory on disk" case. Currently there doesn't seem to be a good way to handle that :/ just pressing on the config entry in "sample file directories" when the directory has been nuked just quits the config UI, and even changing a stream's directory is not possible, it says "Unable to edit camera: can't change sample_file_dir_id 1->None for non-empty stream 1". |
Yeah, we don't have much support yet for cleaning up after mistakes. I think there are basically three options now:
$ moonfire-nvr sql
pragma foreign_keys = on;
begin transaction;
delete from recording_playback;
delete from recording_integrity;
delete from recording;
delete from garbage;
update stream set sample_file_dir_id = null;
delete from sample_file_dir;
commit; It'd be nice to also have some commands for things like:
|
Yeah (3) is pretty much what I did, except I used the system |
moonfire-nvr/server/src/cmds/sql.rs Lines 54 to 58 in 0406e09
I should add to those arguments: select
count(*)
from
garbage
where
not exists (
select
'x'
from
sample_file_dir
where
sample_file_dir.id = garbage.sample_file_dir_id); |
I'm testing various instances of moonfire on different servers using TCP and UDP. Unfortunately, on one instance, I neglected to "export TZ=US/Pacific" prior to running and the result is that rows based UTC (7 hours ahead of my zone as of Oct 1, 2021) were presumably saved in the database. When I then reran moonfire with the time zone appropriately specified, the results in the database from the earlier run appear to be affecting the web UI which is showing nothing recently recorded.
What I'd like to do is be able to purge all the data entries relating to recordings, but not the configuration. Could there a SQL script that could be promulgated that accomplishes this without corrupting the internal relations? I could propose one, but the consequences of row deletions is outside my ken of how moonfire interacts with the database.
Or, it would be great to have an export/import of configuration settings, i.e. to an XML or JSON file, since it takes some time and keyboard entry of values to specify the configurations. Presumably, I could just delete the database, import the configuration settings and start anew. Also, a peeve: when configuring the disk space, I cannot specify the limit, I have to re-enter the configuration setting in order to provide a limit value -- a step I sometimes forget. It would be helpful to be able to specify the maximum disk space in the initial configuration setting ("new").
The text was updated successfully, but these errors were encountered: