mirror of
https://github.com/dw-0/kiauh.git
synced 2026-02-02 23:47:46 +05:00
* 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:
@@ -68,10 +68,11 @@ class BackupService:
|
|||||||
backup_dir = self._backup_root.joinpath(target_path)
|
backup_dir = self._backup_root.joinpath(target_path)
|
||||||
|
|
||||||
backup_dir.mkdir(parents=True, exist_ok=True)
|
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(
|
Logger.print_ok(
|
||||||
f"Successfully backed up '{source_path}' to '{backup_dir}'"
|
f"Successfully backed up '{source_path}' to '{target_path}'"
|
||||||
)
|
)
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -134,27 +135,29 @@ class BackupService:
|
|||||||
################################################
|
################################################
|
||||||
|
|
||||||
def backup_printer_cfg(self):
|
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)
|
klipper_instances: List[Klipper] = get_instances(Klipper)
|
||||||
for instance in klipper_instances:
|
for instance in klipper_instances:
|
||||||
target_path: Path = self._backup_root.joinpath(
|
target_path: Path = self._backup_root.joinpath(instance.data_dir.name)
|
||||||
instance.data_dir.name, f"config_{self.timestamp}"
|
|
||||||
)
|
|
||||||
self.backup_file(
|
self.backup_file(
|
||||||
source_path=instance.cfg_file,
|
source_path=instance.cfg_file,
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
target_name=instance.cfg_file.name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def backup_moonraker_conf(self):
|
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)
|
moonraker_instances: List[Moonraker] = get_instances(Moonraker)
|
||||||
for instance in moonraker_instances:
|
for instance in moonraker_instances:
|
||||||
target_path: Path = self._backup_root.joinpath(
|
target_path: Path = self._backup_root.joinpath(instance.data_dir.name)
|
||||||
instance.data_dir.name, f"config_{self.timestamp}"
|
|
||||||
)
|
|
||||||
self.backup_file(
|
self.backup_file(
|
||||||
source_path=instance.cfg_file,
|
source_path=instance.cfg_file,
|
||||||
target_path=target_path,
|
target_path=target_path,
|
||||||
target_name=instance.cfg_file.name,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
def backup_printer_config_dir(self) -> None:
|
def backup_printer_config_dir(self) -> None:
|
||||||
|
|||||||
Reference in New Issue
Block a user