From 4ffaee6013d38621366eb477c33cfaa8ebe7b603 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joakim=20S=C3=B8rensen?= Date: Mon, 3 Aug 2020 14:28:54 +0200 Subject: [PATCH] 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 --- supervisor/homeassistant.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/supervisor/homeassistant.py b/supervisor/homeassistant.py index bb0f2e915..cdf4f3300 100644 --- a/supervisor/homeassistant.py +++ b/supervisor/homeassistant.py @@ -359,6 +359,17 @@ class HomeAssistant(JsonConfig, CoreSysAttributes): # Update going wrong, revert it if self.error_state and 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) else: raise HomeAssistantUpdateError()