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
This commit is contained in:
Théo Gaillard
2026-01-29 18:52:48 +01:00
committed by GitHub
parent 80948edbb4
commit 5414aba299

View File

@@ -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: