Make a copy of the logfile before rollback (#1867)

* Make a copy of the logfile before rollback

* Review changes and add log about the log file
This commit is contained in:
Joakim Sørensen 2020-08-03 14:28:54 +02:00 committed by GitHub
parent e1ce19547e
commit 4ffaee6013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -359,6 +359,17 @@ class HomeAssistant(JsonConfig, CoreSysAttributes):
# Update going wrong, revert it # Update going wrong, revert it
if self.error_state and rollback: if self.error_state and rollback:
_LOGGER.critical("HomeAssistant update fails -> rollback!") _LOGGER.critical("HomeAssistant update fails -> rollback!")
# Make a copy of the current log file if it exsist
logfile = self.sys_config.path_homeassistant / "home-assistant.log"
if logfile.exists():
backup = (
self.sys_config.path_homeassistant / "home-assistant-rollback.log"
)
shutil.copy(logfile, backup)
_LOGGER.info(
"A backup of the logfile is stored in /config/home-assistant-rollback.log"
)
await _update(rollback) await _update(rollback)
else: else:
raise HomeAssistantUpdateError() raise HomeAssistantUpdateError()