Skip to content

Commit

Permalink
Handle backup errors more consistently (home-assistant#133522)
Browse files Browse the repository at this point in the history
* 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 28fd7a5.

* Inherit BackupReaderWriterError in IncorrectPasswordError

---------

Co-authored-by: Erik Montnemery <[email protected]>
  • Loading branch information
MartinHjelmare and emontnemery authored Jan 2, 2025
1 parent aa9e721 commit a329828
Show file tree
Hide file tree
Showing 10 changed files with 1,150 additions and 198 deletions.
2 changes: 2 additions & 0 deletions homeassistant/components/backup/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
BackupManager,
BackupPlatformProtocol,
BackupReaderWriter,
BackupReaderWriterError,
CoreBackupReaderWriter,
CreateBackupEvent,
IncorrectPasswordError,
Expand All @@ -40,6 +41,7 @@
"BackupAgentPlatformProtocol",
"BackupPlatformProtocol",
"BackupReaderWriter",
"BackupReaderWriterError",
"CreateBackupEvent",
"Folder",
"IncorrectPasswordError",
Expand Down
6 changes: 3 additions & 3 deletions homeassistant/components/backup/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from homeassistant.util import dt as dt_util

from .const import LOGGER
from .models import Folder
from .models import BackupManagerError, Folder

if TYPE_CHECKING:
from .manager import BackupManager, ManagerBackup
Expand Down Expand Up @@ -318,9 +318,9 @@ async def _create_backup(now: datetime) -> None:
password=config_data.create_backup.password,
with_automatic_settings=True,
)
except BackupManagerError as err:
LOGGER.error("Error creating backup: %s", err)
except Exception: # noqa: BLE001
# another more specific exception will be added
# and handled in the future
LOGGER.exception("Unexpected error creating automatic backup")

manager.remove_next_backup_event = async_track_point_in_time(
Expand Down
Loading

0 comments on commit a329828

Please sign in to comment.