1
0
mirror of https://github.com/home-assistant/supervisor.git synced 2025-12-22 11:28:45 +00:00

Handle TarError/OSError in backup routine (#3468)

* Handle TarError/OSError in Core config backup routine

Make sure to handle TarError and OSError exceptions and print a warning
when backing up the Home Assistant Core config folder. This restores
behavior before the introduction of Backup notification in #3305.

* Reraise errors during HA Core backup

* Raise BackupError when encountering error during Add-on Backup

* Log to error as well

Co-authored-by: Pascal Vizeli <pascal.vizeli@syshack.ch>
Co-authored-by: Joakim Sørensen <hi@ludeeus.dev>
This commit is contained in:
Stefan Agner
2022-04-07 20:37:51 +02:00
committed by GitHub
parent b701e1917e
commit 9847e456cd
3 changed files with 26 additions and 17 deletions

View File

@@ -34,6 +34,7 @@ from ..const import (
from ..coresys import CoreSys, CoreSysAttributes
from ..exceptions import (
ConfigurationFileError,
HomeAssistantBackupError,
HomeAssistantError,
HomeAssistantWSError,
)
@@ -351,6 +352,11 @@ class HomeAssistant(FileConfiguration, CoreSysAttributes):
_LOGGER.info("Backing up Home Assistant Core config folder")
await self.sys_run_in_executor(_write_tarfile)
_LOGGER.info("Backup Home Assistant Core config folder done")
except (tarfile.TarError, OSError) as err:
raise HomeAssistantBackupError(
f"Can't backup Home Assistant Core config folder: {str(err)}",
_LOGGER.error,
) from err
finally:
try:
await self.sys_homeassistant.websocket.async_send_command(