CLI: Update --dump usage

This commit is contained in:
deajan 2024-12-10 11:17:11 +01:00
parent 96bd944845
commit 987317cec8
3 changed files with 14 additions and 10 deletions

View file

@ -97,7 +97,7 @@ This is free software, and you are welcome to redistribute it under certain cond
type=str,
default=None,
required=False,
help="Restore to path given by --restore",
help="Restore to path given by --restore, add --snapshot-id to specify a snapshot other than latest",
)
parser.add_argument(
"-s",
@ -109,9 +109,10 @@ This is free software, and you are welcome to redistribute it under certain cond
parser.add_argument(
"--ls",
type=str,
default=None,
required=False,
help='Show content given snapshot. Use "latest" for most recent snapshot.',
nargs="?",
const="latest",
help='Show content given snapshot. When no snapshot id is given, latest is used',
)
parser.add_argument(
"--find",
@ -203,7 +204,7 @@ This is free software, and you are welcome to redistribute it under certain cond
type=str,
default=None,
required=False,
help="Dump a specific file to stdout, use with --dump [snasphot-id] file, where snapshot-id can be 'latest'",
help="Dump a specific file to stdout, use with --dump [file], add --snapshot-id to specify a snapshot other than latest",
)
parser.add_argument(
"--stats",
@ -665,7 +666,10 @@ This is free software, and you are welcome to redistribute it under certain cond
cli_args["operation"] = "recover"
elif args.dump or args.group_operation == "dump":
cli_args["operation"] = "dump"
cli_args["op_args"] = {"path": args.dump}
cli_args["op_args"] = {
"snapshot": args.snapshot_id,
"path": args.dump,
}
elif args.stats is not None or args.group_operation == "stats":
cli_args["operation"] = "stats"
cli_args["op_args"] = {"subject": args.stats}

View file

@ -1631,11 +1631,11 @@ class NPBackupRunner:
@has_permission
@is_ready
@apply_config_to_restic_runner
def dump(self, path: str) -> bool:
def dump(self, snapshot: str, path: str) -> bool:
self.write_logs(
f"Dumping {path} from {self.repo_config.g('name')}", level="info"
f"Dumping {path} from {self.repo_config.g('name')} snapshot {snapshot}", level="info"
)
result = self.restic_runner.dump(path)
result = self.restic_runner.dump(snapshot, path)
return result
@threaded

View file

@ -1254,14 +1254,14 @@ class ResticRunner:
return self.convert_to_json_output(result, output, msg=msg, **kwargs)
@check_if_init
def dump(self, path: str) -> Union[bool, str, dict]:
def dump(self, snapshot: str, path: str) -> Union[bool, str, dict]:
"""
Dump given file directly to stdout
"""
kwargs = locals()
kwargs.pop("self")
cmd = f'dump "{path}"'
cmd = f'dump {snapshot} {path}'
result, output = self.executor(cmd)
if result:
msg = f"File {path} successfully dumped"