mirror of
https://gitlab.com/KKlochko/tui-rsync.git
synced 2026-08-12 17:57:43 +00:00
Add the backup commands to sync the data.
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
from .backup_command_port import BackupCommandPort
|
||||
from .backup_sync_command import BackupSyncCommand
|
||||
from .backup_sync_command_dry_run import BackupSyncCommandDryRun
|
||||
|
||||
__all__ = ['BackupCommandPort', 'BackupSyncCommand', 'BackupSyncCommandDryRun']
|
||||
@@ -0,0 +1,7 @@
|
||||
from abc import ABC, abstractmethod
|
||||
|
||||
|
||||
class BackupCommandPort(ABC):
|
||||
@abstractmethod
|
||||
def run(self):
|
||||
pass
|
||||
@@ -0,0 +1,14 @@
|
||||
import shlex
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from . import BackupCommandPort
|
||||
|
||||
|
||||
class BackupSyncCommand(BackupCommandPort):
|
||||
def __init__(self, source: str, destination: str, args: str):
|
||||
self._args = ["rsync"] + shlex.split(args) + [source, destination]
|
||||
|
||||
def run(self):
|
||||
output = Popen(self._args, stdout=PIPE)
|
||||
response = output.communicate()
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
import shlex
|
||||
from subprocess import Popen, PIPE
|
||||
|
||||
from . import BackupCommandPort
|
||||
|
||||
|
||||
class BackupSyncCommandDryRun(BackupCommandPort):
|
||||
def __init__(self, source: str, destination: str, args: str):
|
||||
self._args = ["rsync"] + shlex.split(args) + ['--dry-run', source, destination]
|
||||
|
||||
def run(self):
|
||||
output = Popen(self._args, stdout=PIPE)
|
||||
return output.communicate()
|
||||
|
||||
Reference in New Issue
Block a user