Deleting old history from database

No matter what I do, I cannot get the system to purge old data from the database.

As per other threads I’ve seen, I’ve placed this in the configuration.yaml file

recorder:
purge_keep_days: 14
purge_interval: 1

And I’ve also placed this in the automations.yaml file

  • id: db_purge
    alias: Database Purge
    trigger:
    platform: time
    at: ‘1:00:00’
    action:
    • service: recorder.purge
      data:
      keep_days: 14
      repack: true

I expect the DB to purge daily. I also have a purge DB button available on the UI I can push. But nothing happens. the DB doesn’t get purged and slowly grows till the VM is full an the whole system crashes beyond recovery. A stupid design.

I’m using Hassio and the only way I’ve found is to go in and physically delete the home-assistant_v2.db file which totally clears all history.

Anyway, what am I missing? Even better, is there a way to tell home assistant to keep the DB under a given size rather than a fixed number of days?

1 Like

If your database doesn’t have 14 days of stuff, it’ll continue to grow until it does. I’d expect a 14 day database to be about 3 gigs with a moderate amount of state objects (~100).

Not mine. I have around 25 objects and 2Gb gets around 4 months of history.