mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-08 05:54:25 +08:00
CLI: Fix --dry-run should not be at the end of command, fixes #111
This commit is contained in:
parent
e1afcaba4e
commit
7cd2e5727c
1 changed files with 5 additions and 2 deletions
|
@ -330,18 +330,21 @@ class ResticRunner:
|
|||
if self.additional_parameters
|
||||
else ""
|
||||
)
|
||||
_cmd = f'"{self._binary}"{additional_parameters}{self.generic_arguments} {cmd}'
|
||||
|
||||
if self.dry_run:
|
||||
# Only some restic commands support --dry-run, and it must be added after the main command
|
||||
# eg restic --dry-run backup / doesn't work
|
||||
# but restic backup / --dry-run does
|
||||
# We need to make sure we put dry-run just after the main command, so we don't add it to the end of a stdin command
|
||||
operation = fn_name(1)
|
||||
if operation in ["backup", "forget", "prune", "restore", "rewrite"]:
|
||||
self.write_logs(
|
||||
"Running in dry mode. No modifications will be done", level="info"
|
||||
)
|
||||
_cmd += " --dry-run"
|
||||
# Replace first occurence of possible operation
|
||||
cmd = cmd.replace(operation, f"{operation} --dry-run", 1)
|
||||
|
||||
_cmd = f'"{self._binary}"{additional_parameters}{self.generic_arguments} {cmd}'
|
||||
|
||||
self._executor_running = True
|
||||
self.write_logs(f"Running command: [{_cmd}]", level="debug")
|
||||
|
|
Loading…
Add table
Reference in a new issue