From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gate001.proxmox.com (gate001.proxmox.com [45.144.208.40]) by lore.proxmox.com (Postfix) with ESMTPS id 34D4D1FF0DF for ; Fri, 28 Aug 2026 15:31:56 +0200 (CEST) Received: from gate001.proxmox.com (localhost.localdomain [127.0.0.1]) by gate001.proxmox.com (Proxmox) with ESMTP id E320A21668; Fri, 28 Aug 2026 15:31:12 +0200 (CEST) From: Shannon Sterz To: pve-devel@lists.proxmox.com Subject: [PATCH manager 09/21] api: node: add endpoints for listing backups for a node Date: Fri, 28 Aug 2026 15:30:18 +0200 Message-ID: <20260828133030.351140-10-s.sterz@proxmox.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20260828133030.351140-1-s.sterz@proxmox.com> References: <20260828133030.351140-1-s.sterz@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Bm-Milter-Handled: 55990f41-d878-4baa-be0a-ee34c49e34d2 X-Bm-Transport-Timestamp: 1787923824569 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.746 Adjusted score from AWL reputation of From: address DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment (newer systems) POISEN_SPAM_PILL 0.1 Meta: its spam POISEN_SPAM_PILL_1 0.1 random spam to be learned in bayes POISEN_SPAM_PILL_3 0.1 random spam to be learned in bayes RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust 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: UJMH5MUTUS4AZFOYSXNXKXVZ33BPKK3M X-Message-ID-Hash: UJMH5MUTUS4AZFOYSXNXKXVZ33BPKK3M X-MailFrom: s.sterz@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 VE development discussion List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: GET /nodes/{node}/host-backup now lists backups of a host Signed-off-by: Shannon Sterz --- PVE/API2/HostBackup.pm | 140 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) diff --git a/PVE/API2/HostBackup.pm b/PVE/API2/HostBackup.pm index 9a0b0dc1d..fe1263a85 100644 --- a/PVE/API2/HostBackup.pm +++ b/PVE/API2/HostBackup.pm @@ -18,6 +18,7 @@ use PVE::PBSClient; use PVE::Storage::PBSPlugin; use PVE::Storage; use PVE::Systemd; +use PVE::Tools qw(extract_param); use PVE::VZDump; use PVE::pvecfg; @@ -316,6 +317,145 @@ sub complete_proxmox_backup_storage(@) { return $res; } +__PACKAGE__->register_method({ + name => 'index', + path => '', + method => 'GET', + proxyto => 'node', + protected => 1, + description => "List backups for specified node.", + permissions => { + check => [ + 'and', + ['perm', '/', ['Sys.Audit']], + [ + 'perm', + '/storage/{storage}', + ['Datastore.Audit', 'Datastore.AllocateSpace'], + any => 1, + ], + ], + + }, + parameters => { + additionalProperties => 0, + properties => { + node => get_standard_option('pve-node'), + storage => get_standard_option( + 'pve-storage-id', + { + description => + "The Proxmox Backup Server storage to scan for host backups.", + completion => \&complete_proxmox_backup_storage, + optional => 0, + }, + ), + }, + }, + returns => { + type => 'array', + items => { + type => 'object', + properties => { + volid => { + description => "Volume identifier.", + type => 'string', + }, + 'format' => { + description => "Always 'pbs-host'.", + type => 'string', + }, + size => { + description => + "Volume size in bytes. 0 if the size couldn't be determined.", + type => 'integer', + renderer => 'bytes', + }, + ctime => { + description => "Creation time (seconds since the UNIX Epoch).", + type => 'integer', + minimum => 0, + optional => 1, + }, + notes => { + description => + "Optional notes. If they are multiple lines long, only the first line will " + . "be returned.", + type => 'string', + optional => 1, + }, + encrypted => { + description => "Fingerprint of the encrypted backup if it is encrypted.", + type => 'string', + optional => 1, + }, + verification => { + description => "Last backup verification result.", + type => 'object', + properties => { + state => { + description => "Last backup verification state.", + type => 'string', + }, + upid => { + description => "Last backup verification UPID.", + type => 'string', + }, + }, + optional => 1, + }, + protected => { + description => "Protection status.", + type => 'boolean', + optional => 1, + }, + }, + }, + links => [{ rel => 'child', href => "{backup-time}" }], + }, + code => sub($param) { + my $storeid = extract_param($param, 'storage'); + my $cfg = PVE::Storage::config(); + my $scfg = PVE::Storage::storage_check_enabled($cfg, $storeid, undef, 1); + + croak "storage is not enabled or not available on this host\n" if !defined($scfg); + croak "currently only proxmox backup server is supported for host backups\n" + if $scfg->{type} ne PVE::Storage::PBSPlugin::type(); + + my $pbs = PVE::PBSClient->new($scfg, $storeid); + + my $nodename = extract_param($param, 'node'); + my $snapshots = $pbs->get_snapshots("host/$nodename"); + + my $res = []; + + foreach my $item (@$snapshots) { + my ($type, $id, $time) = $item->@{qw(backup-type backup-id backup-time)}; + next if $type ne 'host'; + + my @pxar = grep { $_->{filename} eq 'pve-backup.pxar.didx' } @{ $item->{files} }; + next if (scalar(@pxar) != 1); + + my $info = { + volid => PVE::Storage::PBSPlugin::print_volid($storeid, $type, $id, $time), + format => "pbs-$type", + size => int($item->{size}), + content => 'backup', + ctime => $time, + subtype => 'host', + }; + + $info->{verification} = $item->{verification} if defined($item->{verification}); + $info->{notes} = $item->{comment} if defined($item->{comment}); + $info->{protected} = 1 if $item->{protected}; + + push @$res, $info; + } + + return $res; + }, +}); + __PACKAGE__->register_method({ name => 'create_backup', path => '', -- 2.47.3