diff --git a/supervisor/backups/backup.py b/supervisor/backups/backup.py index fa330bb7926..3f32b025951 100644 --- a/supervisor/backups/backup.py +++ b/supervisor/backups/backup.py @@ -696,63 +696,6 @@ async def restore_folders(self, folder_list: list[str]) -> bool: """Backup Supervisor data into backup.""" success = True - async def _folder_restore(name: str) -> bool: - """Intenal function to restore a folder.""" - slug_name = name.replace("/", "_") - tar_name = Path( - self._tmp.name, f"{slug_name}.tar{'.gz' if self.compressed else ''}" - ) - origin_dir = Path(self.sys_config.path_supervisor, name) - - # Check if exists inside backup - if not tar_name.exists(): - _LOGGER.warning("Can't find restore folder %s", name) - return False - - # Unmount any mounts within folder - bind_mounts = [ - bound.bind_mount - for bound in self.sys_mounts.bound_mounts - if bound.bind_mount.local_where - and bound.bind_mount.local_where.is_relative_to(origin_dir) - ] - if bind_mounts: - await asyncio.gather( - *[bind_mount.unmount() for bind_mount in bind_mounts] - ) - - # Clean old stuff - if origin_dir.is_dir(): - await remove_folder(origin_dir, content_only=True) - - # Perform a restore - def _restore() -> bool: - try: - _LOGGER.info("Restore folder %s", name) - with SecureTarFile( - tar_name, - "r", - key=self._key, - gzip=self.compressed, - bufsize=BUF_SIZE, - ) as tar_file: - tar_file.extractall( - path=origin_dir, members=tar_file, filter="fully_trusted" - ) - _LOGGER.info("Restore folder %s done", name) - except (tarfile.TarError, OSError) as err: - _LOGGER.warning("Can't restore folder %s: %s", name, err) - return False - return True - - try: - return await self.sys_run_in_executor(_restore) - finally: - if bind_mounts: - await asyncio.gather( - *[bind_mount.mount() for bind_mount in bind_mounts] - ) - # Restore folder sequential avoid issue on slow IO for folder in folder_list: try: