Commit Graph

84 Commits

Author SHA1 Message Date
Erik Montnemery
2b4b46eaf8 Add async_iterator util (#153194) 2025-09-29 18:54:23 +02:00
Marc Mueller
aac015e822 Fix backup manager delete backup error filter (#151490) 2025-09-01 12:22:23 +02:00
Roman Sivriver
b4e50902eb Fix typo in backup log message (#149705) 2025-07-30 22:29:26 +01:00
Erik Montnemery
741a3d5009 Remove backup helper (#143558)
* Remove backup helper

* Update aws_s3 tests
2025-06-30 14:11:10 +02:00
Erik Montnemery
0260a03447 Store information about add-ons and folders which could not be backed up (#145367)
* Store information about add-ons and folders which could not be backed up

* Address review comments
2025-05-26 16:07:33 +02:00
Erik Montnemery
eb85185072 Minor code deduplication in backup manager (#145366) 2025-05-21 10:19:53 +02:00
Erik Montnemery
8e74f63d47 Create repair issue if not all add-ons or folders were backed up (#144999)
* Create repair issue if not all add-ons or folders were backed up

* Fix spelling

* Fix _collect_errors

* Make time patching by freezegun work with mashumaro

* Addd test to hassio

* Add fixture

* Fix generating list of folders

* Add issue creation tests

* Include name of failing add-on in message

* Improve code formatting

* Rename AddonError to AddonErrorData
2025-05-20 15:23:52 +02:00
Erik Montnemery
36d32eaabc Improve backup exclude filters (#141311)
* Improve backup exclude filters

* Add comment
2025-03-25 09:52:45 +01:00
Michael
e96e95c32d Add sensor platform to backup integration (#138663)
* add sensor platform to backup integration

* adjust namings, remove system integration flag

* add first simple test

* apply review comments

* fix test

* add sensor tests

* adjustements to use backup helper

* remove obsolet async_get_manager from init

* unsubscribe from events on entry unload

* add configuration_url

* fix doc string

* fix sensor tests

* mark async_unsubscribe as callback

* set integration_type service

* extend sensor test

* set integration_type on correct integration :)

* fix after online conflict resolution

* add sensor update tests

* simplify the sensor update tests

* avoid io during tests

* Add comment

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-03-24 12:54:16 +01:00
Erik Montnemery
05c61b7ec3 Rename BackupManager last_non_idle_event to last_action_event (#140291)
* Rename BackupManager last_non_idle_event to last_action_event

* Update snapshots
2025-03-19 17:28:40 +01:00
Erik Montnemery
219b441be0 Don't allow creating backups if Home Assistant is not running (#139499)
* Don't allow creating backups if hass is not running

* Revert "Don't allow creating backups if hass is not running"

This reverts commit 1bf545eb25.

* Set backup manager to idle only after Home Assistant has started

* Update according to discussion, add tests

* Add more test
2025-03-10 14:40:08 +01:00
Erik Montnemery
6ba45a32c0 Update typing of BackupAgent.async_get_backup (#139923)
* Update typing of BackupAgent.async_get_backup

* Remove manual reset of frame helper
2025-03-06 17:25:34 +01:00
Erik Montnemery
e55757dc82 Simplify error handling in BackupAgent when a backup is not found (#139754)
Simplify error handling in BackupAgent when backup is not found
2025-03-04 15:56:12 +01:00
Erik Montnemery
228a4eb391 Improve error handling in CoreBackupReaderWriter (#139508) 2025-02-28 14:25:35 +01:00
Erik Montnemery
ee01aa73b8 Improve error message when failing to create backups (#139262)
* Improve error message when failing to create backups

* Check for expected error message in tests
2025-02-26 13:44:09 +01:00
Martin Hjelmare
27f7085b61 Create repair for configured unavailable backup agents (#137382)
* Create repair for configured not loaded agents

* Rework to repair issue

* Extract logic to config function

* Update test

* Handle empty agend ids config update

* Address review comment

* Update tests

* Address comment
2025-02-25 16:27:56 +01:00
Erik Montnemery
bf190a8a73 Add backup helper (#139199)
* Add backup helper

* Add hassio to stage 1

* Apply same changes to newly merged `webdav` and `azure_storage` to fix inflight conflict

* Address comments, add tests

---------

Co-authored-by: J. Nick Koston <nick@koston.org>
2025-02-25 10:19:41 +01:00
Martin Hjelmare
119b296c26 Make backup config update a callback (#138925) 2025-02-20 11:11:34 +00:00
Erik Montnemery
b70c5710a9 Correct invalid automatic backup settings when loading from store (#138716)
* Correct invalid automatic backup settings when loading from store

* Improve docstring

* Improve tests
2025-02-19 16:24:30 +01:00
Erik Montnemery
10180cd464 Fix BackupManager.async_delete_backup (#138286) 2025-02-11 14:53:07 +01:00
Erik Montnemery
e1817d466e Keep one backup per backup agent when executing retention policy (#138189)
* Keep one backup per backup agent when executing retention policy

* Add tests

* Use defaultdict instead of dict.setdefault

* Update hassio tests
2025-02-10 18:09:57 +02:00
Abílio Costa
c2bb376c43 Handle generic agent exceptions when getting and deleting backups (#138145)
* Handle generic agent exceptions when getting backups

* Update hassio test

* Update delete_backup
2025-02-10 01:31:55 +01:00
Erik Montnemery
2f116eab9e Adjust logic for per-backup agent encryption (#137420) 2025-02-05 12:14:06 +01:00
Erik Montnemery
bfbf95f515 Allow creating backup if at least one agent is available (#137409) 2025-02-05 10:14:39 +01:00
Erik Montnemery
eb5036854f Improve error handling when supervisor backups are deleted (#137331)
* Improve error handling when supervisor backups are deleted

* Move exception definitions
2025-02-04 19:49:55 +01:00
Erik Montnemery
065cdf421f Delete old addon update backups when updating addon (#136977)
* Delete old addon update backups when updating addon

* Address review comments

* Add tests
2025-01-31 13:33:48 -05:00
Erik Montnemery
e18dc063ba Make backup file names more user friendly (#136928)
* Make backup file names more user friendly

* Strip backup name

* Strip backup name

* Underscores
2025-01-31 17:33:30 +01:00
Joost Lekkerkerker
c3b0bc3e0d Show name of the backup agents in issue (#136925)
* Show name of the backup agents in issue

* Show name of the backup agents in issue

* Update homeassistant/components/backup/manager.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-01-30 18:15:54 +01:00
Erik Montnemery
bab616fa61 Fix handling of renamed backup files in the core writer (#136898)
* Fix handling of renamed backup files in the core writer

* Adjust mocking

* Raise BackupAgentError instead of KeyError in get_backup_path

* Add specific error indicating backup not found

* Fix tests

* Ensure backups are loaded

* Fix tests
2025-01-30 15:25:16 +01:00
Erik Montnemery
b2ec72d75f Persist backup restore status after core restart (#136838)
* Persist backup restore status after core restart

* Don't blow up if restore result file can't be removed

* Update tests
2025-01-29 16:58:33 +01:00
Erik Montnemery
9a687e7f94 Add support for per-backup agent encryption flag (#136622)
* Add support for per-backup agent encryption flag

* Adjust

* Don't attempt decrypting an unprotected backup

* Address review comments

* Add some tests

* Add fixture

* Rename fixture

* Correct condition for when we should encrypt or decrypt

* Update tests in integrations

* Improve test coverage

* Fix onedrive tests

* Add test

* Improve cipher worker shutdown

* Improve test coverage

* Fix google_drive tests

* Move inner class _CipherBackupStreamer._WorkerStatus to module scope
2025-01-29 14:04:17 +01:00
Erik Montnemery
7249c02655 Add backup endpoints to the onboarding integration (#136051)
* Add backup endpoints to the onboarding integration

* Add backup as after dependency of onboarding

* Add test snapshots

* Fix stale docstrings

* Add utility function for getting the backup manager instance

* Return backup_id when uploading backup

* Change /api/onboarding/backup/restore to accept a JSON body

* Fix with_backup_manager
2025-01-29 12:32:18 +01:00
Erik Montnemery
abb58ec785 Include error reason in backup events (#136697)
* Include error reason in backup events

* Update hassio backup tests

* Sort code

* Remove catching BackupError in async_receive_backup
2025-01-28 14:44:09 +01:00
Erik Montnemery
e120a7b59c Fix deadlock in WS command backup/can_decrypt_on_download (#136707) 2025-01-28 13:48:42 +01:00
Erik Montnemery
b1abf50a31 Tag backups created when updating addon with supervisor.addon_update (#136690) 2025-01-28 13:48:28 +01:00
Erik Montnemery
245ee2498e Update hassio to use the backup integration to make backups before update (#136235)
Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-01-27 08:25:22 +01:00
Erik Montnemery
760168de83 Allow backup writer to update progress during restore (#135975)
* Allow backup writer to update progress during restore

* Clarify comment
2025-01-20 12:58:17 +01:00
Erik Montnemery
9db6be11f7 Support decrypting backups when downloading (#135728)
* Support decrypting backups when downloading

* Close stream

* Use test helper

* Wait for worker to finish

* Simplify

* Update backup.json

* Simplify

* Revert change from the future
2025-01-16 12:36:12 +01:00
Erik Montnemery
f36a10126c Add WS command backup/can_decrypt_on_download (#135662)
* Add WS command backup/can_decrypt_on_download

* Wrap errors

* Add default messages to exceptions

* Improve test coverage
2025-01-15 19:40:29 +01:00
Martin Hjelmare
4ccc686295 Improve logging of backup upload errors (#135672)
Improve logging for upload errors
2025-01-15 14:59:42 +02:00
Erik Montnemery
edc7c0ff2f Bump securetar to 2025.1.1 (#135582) 2025-01-14 13:28:43 +01:00
Joost Lekkerkerker
4d93fbcb52 Fix backup formatting (#135350) 2025-01-11 11:15:00 +01:00
Joakim Sørensen
fce5be928e Log upload BackupAgentError (#134865)
* Log out BackupAgentError

* Update homeassistant/components/backup/manager.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Update homeassistant/components/backup/manager.py

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>

* Format

---------

Co-authored-by: Martin Hjelmare <marhje52@gmail.com>
2025-01-06 14:19:34 +01:00
Erik Montnemery
336af8b551 Avoid early COMPLETED event when restoring backup (#134546) 2025-01-03 14:44:24 +01:00
Erik Montnemery
dc048bfcf5 Simplify error handling when creating backup (#134528) 2025-01-03 14:16:05 +01:00
Paulus Schoutsen
0ef254bc9a Fix backup dir not existing (#134506) 2025-01-03 00:21:19 -05:00
Martin Hjelmare
a329828bdf Handle backup errors more consistently (#133522)
* Add backup manager and read writer errors

* Clean up not needed default argument

* Clean up todo comment

* Trap agent bugs during upload

* Always release stream

* Clean up leftover

* Update test for backup with automatic settings

* Fix use of vol.Any

* Refactor test helper

* Only update successful timestamp if completed event is sent

* Always delete surplus copies

* Fix after rebase

* Fix after rebase

* Revert "Fix use of vol.Any"

This reverts commit 28fd7a544899bb6ed05f771e9e608bc5b41d2b5e.

* Inherit BackupReaderWriterError in IncorrectPasswordError

---------

Co-authored-by: Erik Montnemery <erik@montnemery.com>
2025-01-02 15:45:46 +01:00
Erik Montnemery
0c3489c1b3 Adjust language in backup integration (#134440)
* Adjust language in backup integration

* Update tests
2025-01-02 13:29:46 +01:00
Bram Kragten
06b33e5589 Set backup manager state to completed when restore is finished (#134283) 2024-12-31 15:01:06 +01:00
Erik Montnemery
82f54eb9d2 Adjust the default backup name (#133668) 2024-12-21 09:38:59 +01:00