Make --dry-run parameter available for all future commands

This commit is contained in:
Orsiris de Jong 2023-03-01 19:11:42 +01:00
parent a31edd00c0
commit 9249a63f65
2 changed files with 3 additions and 5 deletions

View file

@ -315,7 +315,6 @@ class NPBackupRunner:
self.minimum_backup_age = 1440
self.restic_runner.verbose = self.verbose
self.restic_runner.dry_run = self.dry_run
self.restic_runner.stdout = self.stdout
@exec_timer
@ -498,6 +497,7 @@ class NPBackupRunner:
)
)
self.restic_runner.dry_run = self.dry_run
result, result_string = self.restic_runner.backup(
paths=paths,
exclude_patterns=exclude_patterns,
@ -508,7 +508,6 @@ class NPBackupRunner:
use_fs_snapshot=use_fs_snapshot,
tags=tags,
additional_parameters=additional_parameters,
dry_run=self.dry_run,
)
logger.debug("Restic output:\n{}".format(result_string))
metric_writer(self.config_dict, result, result_string)

View file

@ -181,6 +181,8 @@ class ResticRunner:
start_time = datetime.utcnow()
self._executor_finished = False
_cmd = '"{}" {}{}'.format(self._binary, cmd, self.generic_arguments)
if self.dry_run:
_cmd += " --dry-run"
logger.debug("Running command: [{}]".format(_cmd))
self._make_env()
if live_stream:
@ -486,7 +488,6 @@ class ResticRunner:
use_fs_snapshot: bool = False,
tags: List[str] = [],
one_file_system: bool = False,
dry_run: bool = False,
additional_parameters: str = None,
) -> Tuple[bool, str]:
"""
@ -524,8 +525,6 @@ class ResticRunner:
tag = tag.strip()
if tag:
cmd += " --tag {}".format(tag)
if dry_run:
cmd += " --dry-run"
if additional_parameters:
cmd += " {}".format(additional_parameters)
result, output = self.executor(cmd, live_stream=True)