diff --git a/npbackup/__main__.py b/npbackup/__main__.py index 14b8b9e..7d61534 100644 --- a/npbackup/__main__.py +++ b/npbackup/__main__.py @@ -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} diff --git a/npbackup/core/runner.py b/npbackup/core/runner.py index db2f825..b2bb15c 100644 --- a/npbackup/core/runner.py +++ b/npbackup/core/runner.py @@ -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 diff --git a/npbackup/restic_wrapper/__init__.py b/npbackup/restic_wrapper/__init__.py index 0ffed90..0431148 100644 --- a/npbackup/restic_wrapper/__init__.py +++ b/npbackup/restic_wrapper/__init__.py @@ -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"