Errors in migration of Plesk website backup

I confirm there's a bug of Virtualmin; I spent many hours searching for it and, more precisely, the bug lies in the sub extract_plesk_dir of migration-plesk.pl file which reads the Plesk backup file and extracts the files contained corrupting them (e.g. web pages are not imported because they are contained in a tar file that gets corrupted); since a Plesk backup is a MIME encoded file, I suspect that the problem is the use of the mail MIME function from the Read User Mail module, which I think were not written to deal with files containing binary streams.

I'm not a perl developer so I cannot easily find a "dirty" solution (AND your MIME decoder code is not easy anyway), but I found a patch with the help of an external command (described [url=http://kb.swsoft.com/en/1757]here[/url]) that proves the bug is in the MIME code; if you want to patch your VM, you have to install mpack and add the following sub to the file (renaming the existing one):

[code]
#--DC
sub extract_plesk_dir
{
local ($file) = @_;
if ($main::plesk_dir_cache{$file} && -d $main::plesk_dir_cache{$file}) {
# Use cached extract from this session
return (1, $main::plesk_dir_cache{$file});
}
local $dir = &transname();
&make_dir($dir, 0700);

# Is this compressed?
local $cf = &compression_format($file);
if ($cf != 0 && $cf != 1) {
return (0, "Unknown compression format");
}

local $cmd = "";
if ($cf == 0) {
$cmd="cat $file | munpack -q -C $dir";
}
else {
$cmd="zcat $file | munpack -q -C $dir";
}

local $res = system $cmd;

#system "rm -rf /tmp/20p";
#system "mv $dir /tmp/20p";
#die "$res: $dir";

return (0, "No attachments found in MIME data") if ($res);

$main::plesk_dir_cache{$file} = $dir;
return (1, $dir);
}
#--DC
[/code]

Status: 
Closed (fixed)