mirror of
https://github.com/netinvent/npbackup.git
synced 2025-09-13 00:16:21 +08:00
CLI: Update --dump usage
This commit is contained in:
parent
96bd944845
commit
987317cec8
3 changed files with 14 additions and 10 deletions
|
@ -97,7 +97,7 @@ This is free software, and you are welcome to redistribute it under certain cond
|
||||||
type=str,
|
type=str,
|
||||||
default=None,
|
default=None,
|
||||||
required=False,
|
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(
|
parser.add_argument(
|
||||||
"-s",
|
"-s",
|
||||||
|
@ -109,9 +109,10 @@ This is free software, and you are welcome to redistribute it under certain cond
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--ls",
|
"--ls",
|
||||||
type=str,
|
type=str,
|
||||||
default=None,
|
|
||||||
required=False,
|
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(
|
parser.add_argument(
|
||||||
"--find",
|
"--find",
|
||||||
|
@ -203,7 +204,7 @@ This is free software, and you are welcome to redistribute it under certain cond
|
||||||
type=str,
|
type=str,
|
||||||
default=None,
|
default=None,
|
||||||
required=False,
|
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(
|
parser.add_argument(
|
||||||
"--stats",
|
"--stats",
|
||||||
|
@ -665,7 +666,10 @@ This is free software, and you are welcome to redistribute it under certain cond
|
||||||
cli_args["operation"] = "recover"
|
cli_args["operation"] = "recover"
|
||||||
elif args.dump or args.group_operation == "dump":
|
elif args.dump or args.group_operation == "dump":
|
||||||
cli_args["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":
|
elif args.stats is not None or args.group_operation == "stats":
|
||||||
cli_args["operation"] = "stats"
|
cli_args["operation"] = "stats"
|
||||||
cli_args["op_args"] = {"subject": args.stats}
|
cli_args["op_args"] = {"subject": args.stats}
|
||||||
|
|
|
@ -1631,11 +1631,11 @@ class NPBackupRunner:
|
||||||
@has_permission
|
@has_permission
|
||||||
@is_ready
|
@is_ready
|
||||||
@apply_config_to_restic_runner
|
@apply_config_to_restic_runner
|
||||||
def dump(self, path: str) -> bool:
|
def dump(self, snapshot: str, path: str) -> bool:
|
||||||
self.write_logs(
|
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
|
return result
|
||||||
|
|
||||||
@threaded
|
@threaded
|
||||||
|
|
|
@ -1254,14 +1254,14 @@ class ResticRunner:
|
||||||
return self.convert_to_json_output(result, output, msg=msg, **kwargs)
|
return self.convert_to_json_output(result, output, msg=msg, **kwargs)
|
||||||
|
|
||||||
@check_if_init
|
@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
|
Dump given file directly to stdout
|
||||||
"""
|
"""
|
||||||
kwargs = locals()
|
kwargs = locals()
|
||||||
kwargs.pop("self")
|
kwargs.pop("self")
|
||||||
|
|
||||||
cmd = f'dump "{path}"'
|
cmd = f'dump {snapshot} {path}'
|
||||||
result, output = self.executor(cmd)
|
result, output = self.executor(cmd)
|
||||||
if result:
|
if result:
|
||||||
msg = f"File {path} successfully dumped"
|
msg = f"File {path} successfully dumped"
|
||||||
|
|
Loading…
Add table
Reference in a new issue