* [RFC PATCH guest-common 1/1] close #4186: vzdump: add 'tags' option to select guests by tag
2026-12-03 9:27 [RFC PATCH guest-common/manager 0/4] vzdump: support tag based guest selection in backup jobs POYEN Alexis
@ 2026-12-03 9:27 ` POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH manager 1/3] close #4186: vzdump: " POYEN Alexis
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: POYEN Alexis @ 2026-12-03 9:27 UTC (permalink / raw)
To: pve-devel; +Cc: POYEN Alexis
Add a new optional 'tags' parameter to the vzdump configuration schema.
It allows selecting all guest systems that have at least one of the
specified tags, complementing the existing 'vmid', 'all'/'exclude' and
'pool' selection modes.
The value is validated as a list of tags (pve-tag-list), consistent with
the 'tags' option of the guest configuration.
Signed-off-by: POYEN Alexis <alexis.poyen@groupe-cyllene.com>
---
src/PVE/VZDump/Common.pm | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/src/PVE/VZDump/Common.pm b/src/PVE/VZDump/Common.pm
index 1f66b85..7dc32fc 100644
--- a/src/PVE/VZDump/Common.pm
+++ b/src/PVE/VZDump/Common.pm
@@ -360,6 +360,13 @@ my $confdesc = {
description => 'Backup all known guest systems included in the specified pool.',
optional => 1,
},
+ tags => {
+ type => 'string',
+ format => 'pve-tag-list',
+ description =>
+ 'Backup all known guest systems that have at least one of the specified tags.',
+ optional => 1,
+ },
'notes-template' => {
type => 'string',
description => "Template string for generating notes for the backup(s). It can contain"
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [RFC PATCH manager 1/3] close #4186: vzdump: select guests by tag
2026-12-03 9:27 [RFC PATCH guest-common/manager 0/4] vzdump: support tag based guest selection in backup jobs POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH guest-common 1/1] close #4186: vzdump: add 'tags' option to select guests by tag POYEN Alexis
@ 2026-12-03 9:27 ` POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH manager 2/3] close #4186: api: backup: support tag based guest selection in jobs POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH manager 3/3] close #4186: ui: backup: add tag based selection mode POYEN Alexis
3 siblings, 0 replies; 5+ messages in thread
From: POYEN Alexis @ 2026-12-03 9:27 UTC (permalink / raw)
To: pve-devel; +Cc: POYEN Alexis
Allow vzdump backup jobs to select the guests to back up by tag: all
guests having at least one of the given tags are included. The new
'tags' option is mutually exclusive with the existing 'vmid', 'all',
'exclude' and 'pool' selection modes.
Add unit tests covering tag selection, tag selection combined with a
node limit, multiple tags, and a tag without any match.
Signed-off-by: POYEN Alexis <alexis.poyen@groupe-cyllene.com>
---
PVE/VZDump.pm | 31 ++++++++++++-
test/vzdump_guest_included_test.pl | 71 +++++++++++++++++++++++++++++-
2 files changed, 100 insertions(+), 2 deletions(-)
diff --git a/PVE/VZDump.pm b/PVE/VZDump.pm
index 5b9397cd..c4675449 100644
--- a/PVE/VZDump.pm
+++ b/PVE/VZDump.pm
@@ -1533,6 +1533,18 @@ sub verify_vzdump_parameters {
raise_param_exc({ pool => "option conflicts with option 'vmid'" })
if $param->{pool} && $param->{vmid};
+ raise_param_exc({ tags => "option conflicts with option 'vmid'" })
+ if $param->{tags} && $param->{vmid};
+
+ raise_param_exc({ tags => "option conflicts with option 'all'" })
+ if $param->{tags} && $param->{all};
+
+ raise_param_exc({ tags => "option conflicts with option 'exclude'" })
+ if $param->{tags} && $param->{exclude};
+
+ raise_param_exc({ tags => "option conflicts with option 'pool'" })
+ if $param->{tags} && $param->{pool};
+
$parse_prune_backups->($param, 'CLI parameters');
parse_fleecing($param);
parse_performance($param);
@@ -1547,7 +1559,8 @@ sub verify_vzdump_parameters {
return if !$check_missing;
raise_param_exc({ vmid => "property is missing" })
- if !($param->{all} || $param->{stop} || $param->{pool}) && !$param->{vmid};
+ if !($param->{all} || $param->{stop} || $param->{pool} || $param->{tags})
+ && !$param->{vmid};
}
@@ -1584,6 +1597,22 @@ sub get_included_guests {
if ($job->{pool}) {
$vmids = PVE::API2Tools::get_resource_pool_guest_members($job->{pool});
+ } elsif ($job->{tags}) {
+ # select guests by tags
+ my $tags = { map { $_ => 1 } split_list($job->{tags}) };
+ my $props = PVE::Cluster::get_guest_config_properties(['tags']);
+
+ for my $id (keys %{ $vmlist->{ids} }) {
+ my $guest_tags = $props->{$id}->{tags} // '';
+ my $has_tag = 0;
+ for my $tag (split_list($guest_tags)) {
+ if ($tags->{$tag}) {
+ $has_tag = 1;
+ last;
+ }
+ }
+ push @$vmids, $id if $has_tag;
+ }
} elsif ($job->{vmid}) {
$vmids = [split_list($job->{vmid})];
} elsif ($job->{all}) {
diff --git a/test/vzdump_guest_included_test.pl b/test/vzdump_guest_included_test.pl
index be42e9ab..de9db6e5 100755
--- a/test/vzdump_guest_included_test.pl
+++ b/test/vzdump_guest_included_test.pl
@@ -5,7 +5,7 @@ use warnings;
use lib '..';
-use Test::More tests => 10;
+use Test::More tests => 14;
use Test::MockModule;
use PVE::VZDump;
@@ -53,12 +53,32 @@ my $pools = {
testpool => [100, 101, 200, 201],
};
+my $guest_tags = {
+ 100 => 'prod,web',
+ 101 => 'prod',
+ 112 => 'dev',
+ 200 => 'prod,db',
+ 201 => 'dev',
+ 212 => 'db',
+ 213 => 'prod',
+};
+
my $pve_cluster_module = Test::MockModule->new('PVE::Cluster');
$pve_cluster_module->mock(
get_vmlist => sub {
return $vmlist;
},
);
+$pve_cluster_module->mock(
+ get_guest_config_properties => sub {
+ my ($prop_list) = @_;
+ my $res = {};
+ for my $id (keys %{ $vmlist->{ids} }) {
+ $res->{$id}->{tags} = $guest_tags->{$id} // '';
+ }
+ return $res;
+ },
+);
my $pve_inotify = Test::MockModule->new('PVE::INotify');
$pve_inotify->mock(
@@ -215,6 +235,55 @@ $addtest->(
},
);
+$addtest->(
+ 'Test guests by tag',
+ {
+ expected => {
+ node1 => [100, 101],
+ node2 => [200, 213],
+ },
+ param => {
+ tags => 'prod',
+ },
+ },
+);
+
+$addtest->(
+ 'Test guests by tag with node limit',
+ {
+ expected => {
+ node2 => [200, 213],
+ },
+ param => {
+ tags => 'prod',
+ node => 'node2',
+ },
+ },
+);
+
+$addtest->(
+ 'Test guests by multiple tags',
+ {
+ expected => {
+ node1 => [100, 101, 112],
+ node2 => [200, 201, 213],
+ },
+ param => {
+ tags => 'prod,dev',
+ },
+ },
+);
+
+$addtest->(
+ 'Test guests by tag with no matches',
+ {
+ expected => {},
+ param => {
+ tags => 'nonexistent',
+ },
+ },
+);
+
for my $test (@{$tests}) {
my $testname = $test->{name};
my $testdata = $test->{test};
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [RFC PATCH manager 2/3] close #4186: api: backup: support tag based guest selection in jobs
2026-12-03 9:27 [RFC PATCH guest-common/manager 0/4] vzdump: support tag based guest selection in backup jobs POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH guest-common 1/1] close #4186: vzdump: add 'tags' option to select guests by tag POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH manager 1/3] close #4186: vzdump: " POYEN Alexis
@ 2026-12-03 9:27 ` POYEN Alexis
2026-12-03 9:27 ` [RFC PATCH manager 3/3] close #4186: ui: backup: add tag based selection mode POYEN Alexis
3 siblings, 0 replies; 5+ messages in thread
From: POYEN Alexis @ 2026-12-03 9:27 UTC (permalink / raw)
To: pve-devel; +Cc: POYEN Alexis
Allow creating and updating vzdump backup jobs with the new 'tags'
option. Keep the selection options mutually exclusive: setting 'vmid',
'all' or 'pool' removes 'tags' and vice versa.
When switching a job to the 'tags' mode, the previously configured
selection (e.g. a pool) is dropped, so the new mode takes effect.
Signed-off-by: POYEN Alexis <alexis.poyen@groupe-cyllene.com>
---
PVE/API2/Backup.pm | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/PVE/API2/Backup.pm b/PVE/API2/Backup.pm
index 7e1173bf..1b3208c9 100644
--- a/PVE/API2/Backup.pm
+++ b/PVE/API2/Backup.pm
@@ -622,13 +622,21 @@ __PACKAGE__->register_method({
delete $job->{all};
delete $job->{exclude};
delete $job->{pool};
+ delete $job->{tags};
} elsif ($param->{all}) {
delete $job->{vmid};
delete $job->{pool};
+ delete $job->{tags};
+ } elsif ($param->{tags}) {
+ delete $job->{vmid};
+ delete $job->{all};
+ delete $job->{exclude};
+ delete $job->{pool};
} elsif ($job->{pool}) {
delete $job->{vmid};
delete $job->{all};
delete $job->{exclude};
+ delete $job->{tags};
}
PVE::VZDump::verify_vzdump_parameters($job, 1);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread* [RFC PATCH manager 3/3] close #4186: ui: backup: add tag based selection mode
2026-12-03 9:27 [RFC PATCH guest-common/manager 0/4] vzdump: support tag based guest selection in backup jobs POYEN Alexis
` (2 preceding siblings ...)
2026-12-03 9:27 ` [RFC PATCH manager 2/3] close #4186: api: backup: support tag based guest selection in jobs POYEN Alexis
@ 2026-12-03 9:27 ` POYEN Alexis
3 siblings, 0 replies; 5+ messages in thread
From: POYEN Alexis @ 2026-12-03 9:27 UTC (permalink / raw)
To: pve-devel; +Cc: POYEN Alexis
Add a 'Tag based' mode to the backup job edit window, with a tag field
to select the guests to back up. Show the tags of a job in the backup
job list.
Signed-off-by: POYEN Alexis <alexis.poyen@groupe-cyllene.com>
---
www/manager6/Utils.js | 4 ++++
www/manager6/dc/Backup.js | 21 +++++++++++++++++++++
2 files changed, 25 insertions(+)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index fc3667f5..a6e401de 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -425,6 +425,10 @@ Ext.define('PVE.Utils', {
return "Pool '" + record.data.pool + "'";
}
+ if (record.data.tags) {
+ return gettext('Tags') + ": " + record.data.tags;
+ }
+
return '-';
},
diff --git a/www/manager6/dc/Backup.js b/www/manager6/dc/Backup.js
index d3db9d9c..fbb5fa4a 100644
--- a/www/manager6/dc/Backup.js
+++ b/www/manager6/dc/Backup.js
@@ -50,11 +50,16 @@ Ext.define('PVE.dc.BackupEdit', {
delete values.vmid;
} else if (selMode === 'pool') {
delete values.vmid;
+ } else if (selMode === 'tag') {
+ delete values.vmid;
}
if (selMode !== 'pool') {
delete values.pool;
}
+ if (selMode !== 'tag') {
+ delete values.tags;
+ }
return values;
},
@@ -181,6 +186,8 @@ Ext.define('PVE.dc.BackupEdit', {
} else if (data.pool) {
data.selMode = 'pool';
data.selPool = data.pool;
+ } else if (data.tags) {
+ data.selMode = 'tag';
} else {
data.selMode = 'include';
}
@@ -276,6 +283,7 @@ Ext.define('PVE.dc.BackupEdit', {
formulas: {
poolMode: (get) => get('selMode') === 'pool',
+ tagMode: (get) => get('selMode') === 'tag',
disableVMSelection: (get) =>
get('selMode') !== 'include' && get('selMode') !== 'exclude',
selectionLabel: function (get) {
@@ -340,6 +348,7 @@ Ext.define('PVE.dc.BackupEdit', {
['all', gettext('All')],
['exclude', gettext('Exclude selected VMs')],
['pool', gettext('Pool based')],
+ ['tag', gettext('Tag based')],
],
fieldLabel: gettext('Selection mode'),
name: 'selMode',
@@ -351,6 +360,17 @@ Ext.define('PVE.dc.BackupEdit', {
change: 'modeChange',
},
},
+ {
+ xtype: 'pveTagFieldSet',
+ reference: 'tagSelector',
+ title: gettext('Tags to backup'),
+ name: 'tags',
+ hidden: true,
+ bind: {
+ hidden: '{!tagMode}',
+ disabled: '{!tagMode}',
+ },
+ },
{
xtype: 'pvePoolSelector',
reference: 'poolSelector',
@@ -971,6 +991,7 @@ Ext.define(
'prune-backups',
'starttime',
'storage',
+ 'tags',
'vmid',
{ name: 'enabled', type: 'boolean' },
{ name: 'all', type: 'boolean' },
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread