[pbs-devel] [PATCH proxmox-backup v2 7/8] bin/proxmox-tape: add restore-single command to proxmox-tape
Thomas Lamprecht
t.lamprecht at proxmox.com
Wed May 5 13:04:30 CEST 2021
On 05.05.21 12:09, Dominik Csapak wrote:
> Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
> ---
> src/bin/proxmox-tape.rs | 62 +++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 62 insertions(+)
>
> diff --git a/src/bin/proxmox-tape.rs b/src/bin/proxmox-tape.rs
> index e18f334c..3d5d0cf3 100644
> --- a/src/bin/proxmox-tape.rs
> +++ b/src/bin/proxmox-tape.rs
> @@ -868,6 +868,61 @@ async fn backup(mut param: Value) -> Result<(), Error> {
> Ok(())
> }
>
> +#[api(
> + input: {
> + properties: {
> + store: {
> + schema: DATASTORE_MAP_LIST_SCHEMA,
> + },
> + drive: {
> + schema: DRIVE_NAME_SCHEMA,
> + optional: true,
> + },
> + "media-set": {
> + description: "Media set UUID.",
> + type: String,
> + },
> + "snapshots": {
> + description: "Comma-separated list of snapshots.",
> + type: Array,
> + items: {
> + type: String,
> + description: "A single snapshot',"
> + },
> + },
same here, and if we'd really like to add a extra command for restoring not all but
a list of snapshots I'd at least make snapshots a fixed "take all" parameter, e.g.:
proxmox-tape restore-snapshots --store bar --media-set foo vm/100/... ct/101/...
Or allow passing it multiple times for accumulation, as those can be better
tab-completed which would be really helpful compared to typing some date in.
(those pasting it in would not loose any benefit).
But as said, above is only for the case where we really want a separate command,
IMO this would fit fine into a single restore command...
> + "notify-user": {
> + type: Userid,
> + optional: true,
> + },
> + owner: {
> + type: Authid,
> + optional: true,
> + },
> + "output-format": {
> + schema: OUTPUT_FORMAT,
> + optional: true,
> + },
> + },
> + },
> +)]
> +/// Restore data from media-set
> +async fn restore_single(mut param: Value) -> Result<(), Error> {
> +
> + let output_format = get_output_format(¶m);
> +
> + let (config, _digest) = config::drive::config()?;
> +
> + param["drive"] = extract_drive_name(&mut param, &config)?.into();
> +
> + let mut client = connect_to_localhost()?;
> +
> + let result = client.post("api2/json/tape/restore-single", Some(param)).await?;
> +
> + view_task_result(&mut client, result, &output_format).await?;
> +
> + Ok(())
> +}
> +
> #[api(
> input: {
> properties: {
> @@ -981,6 +1036,13 @@ fn main() {
> .completion_cb("store", complete_datastore_name)
> .completion_cb("media-set", complete_media_set_uuid)
> )
> + .insert(
> + "restore-single",
> + CliCommand::new(&API_METHOD_RESTORE_SINGLE)
> + .arg_param(&["media-set", "store", "snapshots"])
> + .completion_cb("store", complete_datastore_name)
> + .completion_cb("media-set", complete_media_set_uuid)
> + )
> .insert(
> "barcode-label",
> CliCommand::new(&API_METHOD_BARCODE_LABEL_MEDIA)
>
More information about the pbs-devel
mailing list