[pve-devel] [RFC container v2 23/25] backup: implement restore for external providers

Fiona Ebner f.ebner at proxmox.com
Thu Sep 12 15:56:35 CEST 2024


Am 12.09.24 um 14:43 schrieb Fabian Grünbichler:
> On August 13, 2024 3:28 pm, Fiona Ebner wrote:
>> @@ -118,6 +136,55 @@ sub restore_tar_archive {
>>      die $err if $err && !$no_unpack_error;
>>  }
>>  
>> +sub restore_external_archive {
>> +    my ($backup_provider, $storeid, $volname, $rootdir, $conf, $no_unpack_error, $bwlimit) = @_;
>> +
>> +    my ($mechanism, $vmtype) = $backup_provider->restore_get_mechanism($volname, $storeid);
>> +    die "cannot restore non-LXC guest of type '$vmtype'\n" if $vmtype ne 'lxc';
>> +
>> +    my $info = $backup_provider->restore_container_init($volname, $storeid, {});
>> +    eval {
>> +	if ($mechanism eq 'tar') {
>> +	    my $tar_path = $info->{'tar-path'}
>> +		or die "did not get path to tar file from backup provider\n";
>> +	    die "not a regular file '$tar_path'" if !-f $tar_path;
>> +	    restore_tar_archive($tar_path, $rootdir, $conf, $no_unpack_error, $bwlimit);
> 
> shouldn't this be `lxc-userns-exec`-ed?
> 

The restore_tar_archive() function does that AFAICS.

>> +	} elsif ($mechanism eq 'directory') {
>> +	    my $directory = $info->{'archive-directory'}
>> +		or die "did not get path to archive directory from backup provider\n";
>> +	    die "not a directory '$directory'" if !-d $directory;
>> +
>> +	    my $rsync = ['rsync', '--stats', '-h', '-X', '-A', '--numeric-ids', '-aH', '--delete',
>> +		'--no-whole-file', '--sparse', '--one-file-system', '--relative'];
>> +	    push $rsync->@*, '--bwlimit', $bwlimit if $bwlimit;
>> +	    push $rsync->@*, "${directory}/./", $rootdir;
> 
> and this as well?
> 

Good catch, will fix!

> also, for both tar and rsync we probably need to think about how to
> prevent bogus input here (which might be user-creatable if they have
> write access to the backup storage) from violating our assumptions..
> 
What assumptions do you mean exactly?




More information about the pve-devel mailing list