Add the backup sync service.

This commit is contained in:
2025-01-16 21:52:23 +02:00
parent 192f930f8a
commit 359dcdfca6
5 changed files with 29 additions and 0 deletions
@@ -0,0 +1,3 @@
from .backup_sync_service import BackupSyncService
__all__ = ['BackupSyncService']
@@ -0,0 +1,20 @@
from tui_rsync.core.components.backup.application.backup_commands import BackupSyncCommand, BackupSyncCommandDryRun
from tui_rsync.core.components.backup_plan.application.repository import BackupPlanRepositoryPort
from tui_rsync.core.shared_kernel.components.common import UUID
class BackupSyncService:
def __init__(self, backup_plan_repository: BackupPlanRepositoryPort):
self.backup_plan_repository = backup_plan_repository
def sync_by_plan_id(self, uuid: UUID, args: str = '', dry_run: bool = False):
backup_plan = self.backup_plan_repository.get_by_id(uuid)
if dry_run:
for destination in backup_plan.destinations:
backup_command = BackupSyncCommandDryRun(backup_plan.source.path, destination.path, args)
backup_command.run()
else:
for destination in backup_plan.destinations:
backup_command = BackupSyncCommand(backup_plan.source.path, destination.path, args)
backup_command.run()