[pve-devel] [PATCH v2 container] vzdump: move include logic for mountpoints to method

Fabian Grünbichler f.gruenbichler at proxmox.com
Mon Mar 16 13:16:17 CET 2020


needs a rebase (please always rebase before sending - the last commit on 
src/PVE/VZDump/LXC.pm was done before you sent this patch out!)

On February 27, 2020 11:01 am, Aaron Lauterer wrote:
> Move the logic which mountpoints are included in the backup job to its
> own method and adapt the VZDump code accordingly. This makes it possible
> to develop other features around backup jobs.
> 
> Signed-off-by: Aaron Lauterer <a.lauterer at proxmox.com>
> ---
> 
> v1 -> v2: implemented the suggestions from Fabian [0]
> 
> [0] https://pve.proxmox.com/pipermail/pve-devel/2020-January/041359.html
> 
>  src/PVE/LXC/Config.pm | 24 ++++++++++++++++++++++++
>  src/PVE/VZDump/LXC.pm | 31 ++++++++++++++++---------------
>  2 files changed, 40 insertions(+), 15 deletions(-)
> 
> diff --git a/src/PVE/LXC/Config.pm b/src/PVE/LXC/Config.pm
> index 00f4884..af728a8 100644
> --- a/src/PVE/LXC/Config.pm
> +++ b/src/PVE/LXC/Config.pm
> @@ -1576,4 +1576,28 @@ sub get_replicatable_volumes {
>      return $volhash;
>  }
>  
> +sub get_backup_volumes {
> +    my ($class, $conf) = @_;
> +
> +    my $ret_volumes = [];
> +
> +    my $test_mountpoint = sub {
> +	my ($key, $volume) = @_;
> +
> +	my $data = {};
> +	my ($included, $reason) = $class->mountpoint_backup_enabled($key, $volume);
> +
> +	$data->{key} = $key;
> +	$data->{included} = $included;
> +	$data->{reason} = $reason;
> +	$data->{data} = $volume;
> +
> +	push @$ret_volumes, $data;
> +    };
> +
> +    PVE::LXC::Config->foreach_mountpoint($conf, $test_mountpoint);
> +
> +    return $ret_volumes;
> +}
> +
>  1;
> diff --git a/src/PVE/VZDump/LXC.pm b/src/PVE/VZDump/LXC.pm
> index 7d6aefd..f36e6d8 100644
> --- a/src/PVE/VZDump/LXC.pm
> +++ b/src/PVE/VZDump/LXC.pm
> @@ -120,24 +120,25 @@ sub prepare {
>      $task->{rootgid} = $rootgid;
>  
>      my $volids = $task->{volids} = [];
> -    PVE::LXC::Config->foreach_mountpoint($conf, sub {
> -	my ($name, $data) = @_;
> -	my $volid = $data->{volume};
> -	my $mount = $data->{mp};
> -	my $type = $data->{type};
> -
> -	return if !$volid || !$mount;
> -
> -	if (!PVE::LXC::Config->mountpoint_backup_enabled($name, $data)) {
> -	    push @$exclude_dirs, $mount;
> -	    $self->loginfo("excluding $type mount point $name ('$mount') from backup");
> -	    return;
> +
> +    my $mountpoint_info = PVE::LXC::Config->get_backup_volumes($conf);
> +
> +    foreach my $mp (@{$mountpoint_info}) {
> +	my $name = $mp->{key};
> +	my $data = $mp->{data};
> +
> +	next if !$data->{volume} || !$data->{mp};
> +
> +	if (!$mp->{included}) {
> +	    push @$exclude_dirs, $data->{mp};
> +	    $self->loginfo("excluding $data->{type} mount point $name ('$data->{mp}') from backup");
> +	    next;
>  	}
>  
> +	$self->loginfo("including mount point $name ('$data->{mp}') in backup");
>  	push @$disks, $data;
> -	push @$volids, $volid
> -	    if $type eq 'volume';
> -    });
> +	push @$volids, $data->{volume} if $mp->{included};
> +    }
>  
>      if ($mode eq 'snapshot') {
>  	if (!PVE::LXC::Config->has_feature('snapshot', $conf, $storage_cfg, undef, undef, 1)) {
> -- 
> 2.20.1
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel at pve.proxmox.com
> https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 




More information about the pve-devel mailing list