feat!: archive data before "overwrite" situations
Supersedes https://github.com/Koenkk/zigbee-herdsman/pull/1526
Creates a "backup-2025-01-01.01-01-01" folder (with database.db & coordinator-backup.json) before:
- adapter "reset" triggers a wipe of previous data from controller
- controller
backup- when triggered by
stop
- when triggered by
Removes databaseBackupPath Controller options (no longer used).
Removes supportsBackup Adapter function in favor of a plain variable (defaults to true, adapters without can override, same as hasZdoMessageOverhead).
TODO:
- [ ] test coverage
- [ ] update Z2M to match new API
How do we handle rotating this stuff? I figure we don't want to be keeping 100 folders :sweat_smile: Should we use a subfolder as default (like Z2M logs)? Static const, use a Z2M config for rotation params? Should it run on start? Have to keep in mind that a bad shutdown could end up doing a few retries (watchdog), each could end up "backing up" bad files, we want to avoid overwriting the last "good one"... as much as possible.
Sidenote: not sure how old coordinator backups will behave in all stacks with frame counters & such.
Maybe do it time based? e.g. keep for a week