From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id 5AC6F1FF292 for ; Mon, 13 Apr 2026 14:10:42 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 4279821C2F; Mon, 13 Apr 2026 14:11:13 +0200 (CEST) From: Lukas Wagner To: pbs-devel@lists.proxmox.com, pve-devel@lists.proxmox.com Subject: [PATCH proxmox-backup 4/7] client: add 'instance-id' sub-command Date: Mon, 13 Apr 2026 14:10:54 +0200 Message-ID: <20260413121057.371772-5-l.wagner@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260413121057.371772-1-l.wagner@proxmox.com> References: <20260413121057.371772-1-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1776082191767 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.055 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy 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 Message-ID-Hash: AVQEOEZJ7M6QR5V6O6JUSALXEHK6ZLKN X-Message-ID-Hash: AVQEOEZJ7M6QR5V6O6JUSALXEHK6ZLKN X-MailFrom: l.wagner@proxmox.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Proxmox Backup Server development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: This allows users to query the instance-id from the proxmox-backup-client tool. This will also be used by the PBS client in PVE to lookup the instance-id from a yet to be introduced API endpoint that returns the instance-id for a given PBS storage. Signed-off-by: Lukas Wagner --- proxmox-backup-client/src/main.rs | 41 +++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/proxmox-backup-client/src/main.rs b/proxmox-backup-client/src/main.rs index 2ada87bdd..9f4a82e26 100644 --- a/proxmox-backup-client/src/main.rs +++ b/proxmox-backup-client/src/main.rs @@ -25,8 +25,8 @@ use pxar::accessor::{MaybeReady, ReadAt, ReadAtOperation}; use pbs_api_types::{ ArchiveType, Authid, BackupArchiveName, BackupDir, BackupGroup, BackupNamespace, BackupPart, - BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, PathPattern, - PruneJobOptions, PruneListItem, RateLimitConfig, SnapshotListItem, StorageStatus, + BackupType, ClientRateLimitConfig, CryptMode, Fingerprint, GroupListItem, InstanceId, + PathPattern, PruneJobOptions, PruneListItem, RateLimitConfig, SnapshotListItem, StorageStatus, BACKUP_ID_SCHEMA, BACKUP_NAMESPACE_SCHEMA, BACKUP_TIME_SCHEMA, BACKUP_TYPE_SCHEMA, CATALOG_NAME, ENCRYPTED_KEY_BLOB_NAME, MANIFEST_BLOB_NAME, }; @@ -139,6 +139,39 @@ fn record_repository(repo: &BackupRepository) { ); } +#[api( + input: { + properties: { + repository: { + schema: REPO_URL_SCHEMA, + optional: true, + }, + "output-format": { + schema: OUTPUT_FORMAT, + optional: true, + }, + }, + }, +)] +/// Start garbage collection for a specific repository. +async fn get_instance_id(param: Value) -> Result { + let repo = extract_repository_from_value(¶m)?; + let output_format = get_output_format(¶m); + let client = connect(&repo)?; + + let path = format!("api2/json/nodes/localhost/instance-id"); + let mut result = client.get(&path, None).await?; + + let id: InstanceId = serde_json::from_value(result["data"].take())?; + + if output_format == "text" { + println!("instance-id: {}", id.instance_id); + } else { + format_and_print_result(&id, &output_format); + } + Ok(Value::Null) +} + async fn api_datastore_list_snapshots( client: &HttpClient, store: &str, @@ -2076,6 +2109,9 @@ fn main() { let version_cmd_def = CliCommand::new(&API_METHOD_API_VERSION).completion_cb("repository", complete_repository); + let instance_id_cmd_def = CliCommand::new(&API_METHOD_GET_INSTANCE_ID) + .completion_cb("repository", complete_repository); + let change_owner_cmd_def = CliCommand::new(&API_METHOD_CHANGE_BACKUP_OWNER) .arg_param(&["group", "new-owner"]) .completion_cb("ns", complete_namespace) @@ -2086,6 +2122,7 @@ fn main() { let cmd_def = CliCommandMap::new() .insert("backup", backup_cmd_def) .insert("garbage-collect", garbage_collect_cmd_def) + .insert("instance-id", instance_id_cmd_def) .insert("list", list_cmd_def) .insert("login", login_cmd_def) .insert("logout", logout_cmd_def) -- 2.47.3