I’m currently configuring backups for my Home Assistant deployment using Restic. I have the actual backing up configured and working on a nightly (systemd) timer, but I’d like more fidelity in my snapshots, so I can more easily examine and revert individual configuration changes.
I could modify the timer to run with more frequency (and that will be my last resort), but ideally I’d like to capture a snapshot every time the configuration is updated. Is there an event which I could use to trigger an automation within Home Assistant every time a configuration change is made?
I don’t believe you can with standard events - open two “Developer Tools” windows with one on the YAML tab and the other on the Events tab, then:
In the Events tab, start listening to “*” events
Quickly switch to the YAML tab and select to reload “Template Entities”. This is simulating you just changing the template.yaml file and reloading it.
Quickly switch back to the Events tab and stop listening.
You will probably see a lot of “state_changed” events for all of the template entities you have, but no general event signifying that you chose to reload “Template Entities”. This doesn’t even consider that you might save template changes but not reloaded.
However, you can use the Folder Watcher integration to raise new events when anything (or just *.yaml for example) in the /config folder changes. You could then trigger a backup from this.
EDIT: Actually you should use patterns, or at least filter out changes to homeassistant.log etc (not sure if that integration already ignores hidden folders like .storage too).
Thanks for the reply, Michael! If I’m going to rely on filesystem events (rather than logical “config changed” events), I’ll likely configure it at the host-level instead: thanks for the pointers to the files I should exclude!