Include network storage mount configurations in backups#6411
Conversation
|
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
404f6d2 to
ec11578
Compare
When creating backups, now stores mount configurations (CIFS/NFS shares) including server, share, credentials, and other settings. When restoring from a backup, mount configurations are automatically restored. This fixes the issue where network storage definitions for backups were lost after restoring from a backup, requiring users to manually reconfigure their network storage mounts. Changes: - Add ATTR_MOUNTS schema to backup validation - Add store_mounts() method to save mount configs during backup - Add restore_mounts() method to restore mount configs during restore - Add MOUNTS stage to backup/restore job stages - Update BackupManager to call mount backup/restore methods - Add tests for mount backup/restore functionality Fixes home-assistant/core#148663
ec11578 to
e6778d7
Compare
mdegat01
left a comment
There was a problem hiding this comment.
So first of all - thank you. I am not entirely sure how this got missed but mounts should absolutely be in backups.
That being said, we're going to need to rework the approach a bit. See my comments for some of the issues. The two biggest ones are currently this will store passwords unencrypted and we should change how we're restoring mounts so it doesn't fail to restore if one happens to be down at that time.
Changes based on PR review: - Store mount configs in encrypted mounts.tar instead of unencrypted backup metadata (security fix for passwords) - Separate mount restore into config save + async activation tasks (mounts activate in background, failures don't block restore) - Add replace_default_backup_mount parameter to control whether to overwrite existing default mount setting - Remove unnecessary broad exception handler for default mount setter - Simplify schema: ATTR_MOUNTS is now just a boolean flag since actual data is in the encrypted tar file - Update tests to reflect new async API and return types
66e8f5a to
f2ade15
Compare
- Add bind mount handling for MEDIA and SHARE usage types in _activate_restored_mount() to mirror MountManager.create_mount() - Fix double save_data() call by using needs_save flag - Import MountUsage const for usage type checks
|
Passwords unencrypted | ✅ Fixed - now in encrypted mounts.tar |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@ptarjan it seems tests need some updates. |
mdegat01
left a comment
There was a problem hiding this comment.
Looks good. Couple smaller comments. Also you have a couple test failures, one with the new test and the other because test_backup_progress has to be adjusted to account for the new backup stage.
- Catch OSError separately and check errno.EBADMSG for drive health
- Validate mounts JSON against SCHEMA_MOUNTS_CONFIG before importing
- Use mount_data[ATTR_NAME] instead of .get("name", "unknown")
- Overwrite existing mounts on restore instead of skipping
- Move restore_mount/activate logic to MountManager (no more
protected-access in Backup)
- Drop unused replace_default_backup_mount parameter
- Fix test_backup_progress: add mounts stage to expected events
- Fix test_store_mounts: avoid create_mount which requires dbus
- Change create_inner_tar() to create_tar() per home-assistant#6575 - Remove "r" argument from SecureTarFile (now read-only by default) - Change warning to info for missing mounts tar (old backups won't have it) - Narrow exception handler to (MountError, vol.Invalid, KeyError, OSError)
agners
left a comment
There was a problem hiding this comment.
Sorry for the piece wise review here, but I think with these changes we should really be ready to land this.
- Remove ATTR_SUPERVISOR boolean flag from backup metadata; instead check for physical presence of supervisor.tar (like folder backups) - Remove has_supervisor_config property - Always attempt supervisor config restore (tar existence check handles it) - Add HostFeature.MOUNT check in _activate_restored_mount before attempting to activate mounts on systems without mount support
agners
left a comment
There was a problem hiding this comment.
There is a test failure still which needs addressing.
Resolve merge conflicts with securetar v3 and empty password changes. Update OSError handling to use centralized check_oserror() pattern. Fix test_restore_supervisor_config_no_tar to create and open backup before calling restore. Add supervisor_config stage to restore progress test expectations. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
agners
left a comment
There was a problem hiding this comment.
This LGTM, but a second review makes sense since I've pushed the last commit.
Proposed change
When creating backups, now stores mount configurations (CIFS/NFS shares) including server, share, credentials, and other settings. When restoring from a backup, mount configurations are automatically restored.
This fixes the issue where network storage definitions for backups were lost after restoring from a backup, requiring users to manually reconfigure their network storage mounts.
Changes:
Type of change
Additional information
Checklist
ruff format supervisor tests)If API endpoints or add-on configuration are added/changed: