From 5414aba2996bab141b32ee2d2cbcebf8ef90a9fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Gaillard?= Date: Thu, 29 Jan 2026 18:52:48 +0100 Subject: [PATCH] fix(backup_service): backup methods use proper paths (#769) (#770) * fix(backup_service): streamline backup methods for proper paths and add docstring * fix(backup_service): add proper destination_path in verbose output * fix(backup_service): replaces html headers with { } to avoid rendering * nitpick(backup_service): correct variable name for backup destination path in logging --- kiauh/core/services/backup_service.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/kiauh/core/services/backup_service.py b/kiauh/core/services/backup_service.py index b685de9..c912b5e 100644 --- a/kiauh/core/services/backup_service.py +++ b/kiauh/core/services/backup_service.py @@ -68,10 +68,11 @@ class BackupService: backup_dir = self._backup_root.joinpath(target_path) backup_dir.mkdir(parents=True, exist_ok=True) - shutil.copy2(source_path, backup_dir.joinpath(filename)) + target_path = backup_dir.joinpath(filename) + shutil.copy2(source_path, target_path) Logger.print_ok( - f"Successfully backed up '{source_path}' to '{backup_dir}'" + f"Successfully backed up '{source_path}' to '{target_path}'" ) return True @@ -134,27 +135,29 @@ class BackupService: ################################################ def backup_printer_cfg(self): + """Backup printer.cfg files of all Klipper instances. + Files are backed up to: + {backup_root}/{instance_data_dir_name}/printer_{timestamp}.cfg + """ klipper_instances: List[Klipper] = get_instances(Klipper) for instance in klipper_instances: - target_path: Path = self._backup_root.joinpath( - instance.data_dir.name, f"config_{self.timestamp}" - ) + target_path: Path = self._backup_root.joinpath(instance.data_dir.name) self.backup_file( source_path=instance.cfg_file, target_path=target_path, - target_name=instance.cfg_file.name, ) def backup_moonraker_conf(self): + """Backup moonraker.conf files of all Moonraker instances. + Files are backed up to: + {backup_root}/{instance_data_dir_name}/moonraker_{timestamp}.conf + """ moonraker_instances: List[Moonraker] = get_instances(Moonraker) for instance in moonraker_instances: - target_path: Path = self._backup_root.joinpath( - instance.data_dir.name, f"config_{self.timestamp}" - ) + target_path: Path = self._backup_root.joinpath(instance.data_dir.name) self.backup_file( source_path=instance.cfg_file, target_path=target_path, - target_name=instance.cfg_file.name, ) def backup_printer_config_dir(self) -> None: