Add freeze/thaw apis for external snapshots #4538
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed change
Users often run HAOS as a VM in software like KVM and Proxmox. These applications all contain snapshot features which quickly take a snapshot of the entire VM. For users of these applications this is significantly easier and faster alternative to backup then supervisor's native backup and restore features. Which makes sense, supervisor can't really compete with disk snapshot features given how and where we are running.
The problem is these features currently create data consistency issues. Home Assistant continues to run and write data to disk at an extremely rapid pace, it is definitely possible to end up with a corrupted database. Just like what used to happen to Supervisor's backups before we put in hooks to pause recorder during backups.
This adds a freeze API. When called it does the following:
FREEZE
statebackup_pre
for any running addons which have that configuredIt also adds a thaw API which reverses the above (unfreezes supervisor, tells HA the backup has ended, calls
backup_post
on addons and restarts any addons it stopped). Note that this thaw API only works on a freeze initiated by the freeze API, it errors if the freeze was initiated elsewhere.Type of change
Additional information
Checklist
black --fast supervisor tests
)If API endpoints of add-on configuration are added/changed: