From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 867BE79B02 for ; Wed, 5 May 2021 12:09:54 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9376713BEB for ; Wed, 5 May 2021 12:09:23 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 124A313995 for ; Wed, 5 May 2021 12:09:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E031A458B9 for ; Wed, 5 May 2021 12:09:19 +0200 (CEST) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Wed, 5 May 2021 12:09:17 +0200 Message-Id: <20210505100918.506-8-d.csapak@proxmox.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20210505100918.506-1-d.csapak@proxmox.com> References: <20210505100918.506-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.016 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [proxmox-tape.rs] Subject: [pbs-devel] [PATCH proxmox-backup v2 7/8] bin/proxmox-tape: add restore-single command to proxmox-tape X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 May 2021 10:09:54 -0000 Signed-off-by: Dominik Csapak --- 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'," + }, + }, + "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) -- 2.20.1