Their question was how to add the repack option under the configuration of the recorder component in configuration.yaml or if it is implied repack: true. Not in an automation.
EDIT: I just tested this in my development/testing sandbox by adding repack: true to my recorder configuration and it throws an error on restart saying it is an invalid config. In my production environment (without the repack option) I can watch my database size grow and shrink day to day. I believe the recorder automatically repacks to shrink the database. There is a note in the config docs that says the repack option is only supported for SQLite. I use MySQL on a separate MariaDB 10 server.
In your case, use the “purge_keep_days:” option in your config under recorder:. anything older than that gets automatically purged by HA. My config is below and I don’t have any problems with database size and it correctly purges.
The doc says “keep_purge_days” may not reduce db size and only repack will.
Caution : You’ll need to ensure there’s sufficient diskspace left as large as the DB pre-purge.
Repack isn’t a config option but you’ll need to call the “recorder.purge” service with following json:
{“keep_purge_days”:“2”,
“repack” : “true”}
Mine went from 373MB down to 28MB. Will let you know if I get myself into any troubles because of this.
I used the above in automations.yaml and went from a 12G db to 346M. I had recorder set to purge_interval: 1 and purge_keep_days: 60. it was doing its job but the db had grown large before that. Everything has been working as expected post repack for me.
This is an important and often overlooked point. If the database is large, already, reducing he amount of data you pump to is doesn’t reduce its size. My experience is also that repacking, or deleting the database is the only solution. Bear in mind that the process takes some time. I thin my 4Gb DB took maybe 10 minutes on my elderly lapbook server.
Nobody wants to lose their history. OTOH, if I have a card that shows the last 2 days of data, how do I look at the data in the file before that? It’s in there, but how do I get it out?!