[pve-devel] [RFC container 20/23] backup: implement backup for external providers
Fiona Ebner
f.ebner at proxmox.com
Tue Jul 23 11:56:21 CEST 2024
The filesystem structure is made available as a directory in a
consistent manner (with details depending on the vzdump backup mode)
just like for regular backup via tar.
The backup provider needs to back up the guest and firewall
configuration and then the filesystem structure, honoring the ID maps
(for unprivileged containers) as well as file exclusions and the
bandwidth limit.
Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
src/PVE/VZDump/LXC.pm | 20 +++++++++++++++++++-
1 file changed, 19 insertions(+), 1 deletion(-)
diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
index 67d13db..f2ccd11 100644
--- a/src/PVE/VZDump/LXC.pm
+++ b/src/PVE/VZDump/LXC.pm
@@ -373,7 +373,25 @@ sub archive {
my $userns_cmd = $task->{userns_cmd};
my $findexcl = $self->{vzdump}->{findexcl};
- if ($self->{vzdump}->{opts}->{pbs}) {
+ if (my $backup_provider = $self->{vzdump}->{'backup-provider'}) {
+ $self->loginfo("starting external backup via " . $backup_provider->provider_name());
+
+ my ($mechanism) = $backup_provider->backup_get_mechanism($vmid, 'lxc');
+ die "mechanism '$mechanism' requested by backup provider is not supported for containers\n"
+ if $mechanism ne 'directory';
+
+ my $config_file = "$tmpdir/etc/vzdump/pct.conf";
+ my $firewall_file = "$tmpdir/etc/vzdump/pct.fw";
+
+ $backup_provider->backup_guest_config($vmid, $config_file);
+ $backup_provider->backup_firewall_config($vmid, $firewall_file) if -e $firewall_file;
+
+ my $conf = PVE::LXC::Config->load_config($vmid);
+ my ($id_map, undef, undef) = PVE::LXC::parse_id_maps($conf);
+ my $bandwidth_limit = $opts->{bwlimit} ? $opts->{bwlimit} * 1024 : undef;
+ $backup_provider->backup_directory(
+ $vmid, $snapdir, $id_map, $findexcl, [@sources], $bandwidth_limit);
+ } elsif ($self->{vzdump}->{opts}->{pbs}) {
my $param = [];
push @$param, "pct.conf:$tmpdir/etc/vzdump/pct.conf";
--
2.39.2
More information about the pve-devel
mailing list