mirror of
git://git.proxmox.com/git/pve-storage.git
synced 2025-01-10 01:18:05 +03:00
pbs: prune: avoid getting all snapshots for group assembly if fixed anyway
If both type and vmid is defined we don't need to list the current snapshots, we simply can derive the single backup group from that and let the PBS client handle the rest. Should be a not so small speedup for most setups using PBS backup and pruning configured on PVE side, as vzdump calls this separately for every vmid on backup jobs with multiple guests included. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
parent
e6d7728171
commit
0bcfafa471
@ -403,19 +403,25 @@ sub prune_backups {
|
||||
|
||||
$logfunc //= sub { print "$_[1]\n" };
|
||||
|
||||
my $backups = eval { $class->list_volumes($storeid, $scfg, $vmid, ['backup']) };
|
||||
die "failed to get list of all backups to prune - $@" if $@;
|
||||
|
||||
$type = 'vm' if defined($type) && $type eq 'qemu';
|
||||
$type = 'ct' if defined($type) && $type eq 'lxc';
|
||||
|
||||
my $backup_groups = {};
|
||||
foreach my $backup (@{$backups}) {
|
||||
(my $backup_type = $backup->{format}) =~ s/^pbs-//;
|
||||
next if defined($type) && $backup_type ne $type;
|
||||
|
||||
my $backup_group = "$backup_type/$backup->{vmid}";
|
||||
$backup_groups->{$backup_group} = 1;
|
||||
if (defined($vmid) && defined($type)) {
|
||||
# no need to get the list of volumes, we only got a single backup group anyway
|
||||
$backup_groups->{"$type/$vmid"} = 1;
|
||||
} else {
|
||||
my $backups = eval { $class->list_volumes($storeid, $scfg, $vmid, ['backup']) };
|
||||
die "failed to get list of all backups to prune - $@" if $@;
|
||||
|
||||
foreach my $backup (@{$backups}) {
|
||||
(my $backup_type = $backup->{format}) =~ s/^pbs-//;
|
||||
next if defined($type) && $backup_type ne $type;
|
||||
|
||||
my $backup_group = "$backup_type/$backup->{vmid}";
|
||||
$backup_groups->{$backup_group} = 1;
|
||||
}
|
||||
}
|
||||
|
||||
my @param;
|
||||
|
Loading…
Reference in New Issue
Block a user