zigbee-herdsman icon indicating copy to clipboard operation
zigbee-herdsman copied to clipboard

feat!: archive data before "overwrite" situations

Open Nerivec opened this issue 2 months ago • 1 comments

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

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

Nerivec avatar Nov 10 '25 19:11 Nerivec

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.

Nerivec avatar Nov 12 '25 20:11 Nerivec

Maybe do it time based? e.g. keep for a week

Koenkk avatar Nov 14 '25 18:11 Koenkk