allow to select gzip or lzop in vzdump
lzop is much faster, and we use that by default now.
This commit is contained in:
parent
5b9ae5b7da
commit
d7550e095e
@ -643,6 +643,20 @@ sub run_hook_script {
|
||||
run_command ($logfd, $cmd);
|
||||
}
|
||||
|
||||
sub compressor_info {
|
||||
my ($opt_compress) = @_;
|
||||
|
||||
if (!$opt_compress || $opt_compress eq '0') {
|
||||
return undef;
|
||||
} elsif ($opt_compress eq '1' || $opt_compress eq 'lzo') {
|
||||
return ('lzop', 'lzo');
|
||||
} elsif ($opt_compress eq 'gzip') {
|
||||
return ('gzip', 'gz');
|
||||
} else {
|
||||
die "internal error - unknown compression option '$opt_compress'";
|
||||
}
|
||||
}
|
||||
|
||||
sub exec_backup_task {
|
||||
my ($self, $task) = @_;
|
||||
|
||||
@ -675,7 +689,11 @@ sub exec_backup_task {
|
||||
|
||||
my $logfile = $task->{logfile} = "$opts->{dumpdir}/$basename.log";
|
||||
|
||||
my $ext = $opts->{compress} ? '.tgz' : '.tar';
|
||||
my $ext = '.tar';
|
||||
my ($comp, $comp_ext) = compressor_info($opts->{compress});
|
||||
if ($comp && $comp_ext) {
|
||||
$ext .= ".${comp_ext}";
|
||||
}
|
||||
|
||||
if ($opts->{stdout}) {
|
||||
$task->{tarfile} = '-';
|
||||
@ -836,13 +854,13 @@ sub exec_backup_task {
|
||||
|
||||
if ($opts->{stdout}) {
|
||||
debugmsg ('info', "sending archive to stdout", $logfd);
|
||||
$plugin->archive($task, $vmid, $task->{tmptar});
|
||||
$plugin->archive($task, $vmid, $task->{tmptar}, $comp);
|
||||
$self->run_hook_script ('backup-end', $task, $logfd);
|
||||
return;
|
||||
}
|
||||
|
||||
debugmsg ('info', "creating archive '$task->{tarfile}'", $logfd);
|
||||
$plugin->archive ($task, $vmid, $task->{tmptar});
|
||||
$plugin->archive($task, $vmid, $task->{tmptar}, $comp);
|
||||
|
||||
rename ($task->{tmptar}, $task->{tarfile}) ||
|
||||
die "unable to rename '$task->{tmptar}' to '$task->{tarfile}'\n";
|
||||
@ -861,7 +879,7 @@ sub exec_backup_task {
|
||||
my $dir = $opts->{dumpdir};
|
||||
foreach my $fn (<$dir/${bkname}-*>) {
|
||||
next if $fn eq $task->{tarfile};
|
||||
if ($fn =~ m!/(${bkname}-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|tar))$!) {
|
||||
if ($fn =~ m!/(${bkname}-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|(tar(\.(gz|lzo))?)))$!) {
|
||||
$fn = "$dir/$1"; # untaint
|
||||
my $t = timelocal ($7, $6, $5, $4, $3 - 1, $2 - 1900);
|
||||
push @bklist, [$fn, $t];
|
||||
@ -877,7 +895,7 @@ sub exec_backup_task {
|
||||
debugmsg ('info', "delete old backup '$d->[0]'", $logfd);
|
||||
unlink $d->[0];
|
||||
my $logfn = $d->[0];
|
||||
$logfn =~ s/\.(tgz|tar)$/\.log/;
|
||||
$logfn =~ s/\.(tgz|(tar(\.(gz|lzo))?))$/\.log/;
|
||||
unlink $logfn;
|
||||
}
|
||||
}
|
||||
@ -954,7 +972,7 @@ sub exec_backup_task {
|
||||
}
|
||||
|
||||
sub exec_backup {
|
||||
my ($rpcenv, $authuser, $self) = @_;
|
||||
my ($self, $rpcenv, $authuser) = @_;
|
||||
|
||||
my $opts = $self->{opts};
|
||||
|
||||
@ -1048,10 +1066,11 @@ my $confdesc = {
|
||||
default => 1,
|
||||
},
|
||||
compress => {
|
||||
type => 'boolean',
|
||||
description => "Compress dump file (gzip).",
|
||||
type => 'string',
|
||||
description => "Compress dump file.",
|
||||
optional => 1,
|
||||
default => 0,
|
||||
enum => ['0', '1', 'gzip', 'lzo'],
|
||||
default => 'lzo',
|
||||
},
|
||||
quiet => {
|
||||
type => 'boolean',
|
||||
|
@ -231,7 +231,7 @@ sub assemble {
|
||||
}
|
||||
|
||||
sub archive {
|
||||
my ($self, $task, $vmid, $filename) = @_;
|
||||
my ($self, $task, $vmid, $filename, $comp) = @_;
|
||||
|
||||
my $findexcl = $self->{vzdump}->{findexcl};
|
||||
my $findargs = join (' ', @$findexcl) . ' -print0';
|
||||
@ -240,8 +240,6 @@ sub archive {
|
||||
my $srcdir = $self->{vmlist}->{$vmid}->{dir};
|
||||
my $snapdir = $task->{snapdir};
|
||||
|
||||
my $zflag = $opts->{compress} ? 'z' : '';
|
||||
|
||||
my $taropts = "--totals --sparse --numeric-owner --no-recursion --ignore-failed-read --one-file-system";
|
||||
|
||||
# note: --remove-files does not work because we do not
|
||||
@ -253,13 +251,12 @@ sub archive {
|
||||
#}
|
||||
|
||||
my $cmd = "(";
|
||||
$cmd .= "cd $snapdir;find . $findargs|sed 's/\\\\/\\\\\\\\/g'|";
|
||||
$cmd .= "tar c${zflag}pf - $taropts --null -T -";
|
||||
|
||||
if ($opts->{bwlimit}) {
|
||||
my $bwl = $opts->{bwlimit}*1024; # bandwidth limit for cstream
|
||||
$cmd .= "|cstream -t $bwl";
|
||||
}
|
||||
$cmd .= "cd $snapdir;find . $findargs|sed 's/\\\\/\\\\\\\\/g'|";
|
||||
$cmd .= "tar cpf - $taropts --null -T -";
|
||||
my $bwl = $opts->{bwlimit}*1024; # bandwidth limit for cstream
|
||||
$cmd .= "|cstream -t $bwl" if $opts->{bwlimit};
|
||||
$cmd .= "|$comp" if $comp;
|
||||
|
||||
$cmd .= ")";
|
||||
|
||||
|
@ -116,7 +116,7 @@ sub assemble {
|
||||
}
|
||||
|
||||
sub archive {
|
||||
my ($self, $task, $vmid, $filename) = @_;
|
||||
my ($self, $task, $vmid, $filename, $comp) = @_;
|
||||
|
||||
die "internal error"; # implement in subclass
|
||||
}
|
||||
|
2
debian/control.in
vendored
2
debian/control.in
vendored
@ -3,7 +3,7 @@ Version: @VERSION@-@PACKAGERELEASE@
|
||||
Section: admin
|
||||
Priority: optional
|
||||
Architecture: all
|
||||
Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, libdigest-sha1-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster, libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, mail-transport-agent, libxml-parser-perl, perl-suid
|
||||
Depends: perl5, libtimedate-perl, apache2-mpm-prefork, libauthen-pam-perl, libintl-perl, rsync, libapache2-request-perl, libjson-perl, libdigest-sha1-perl, liblockfile-simple-perl, vncterm, qemu-server (>= 1.1-1), libwww-perl, wget, libnet-dns-perl, vlan, ifenslave-2.6 (>= 1.1.0-10), liblinux-inotify2-perl, debconf (>= 0.5) | debconf-2.0, netcat-traditional, pve-cluster, libpve-common-perl, libpve-storage-perl, libterm-readline-gnu-perl, libpve-access-control, libio-socket-ssl-perl, libfilesys-df-perl, libfile-readbackwards-perl, libfile-sync-perl, redhat-cluster-pve, resource-agents-pve, fence-agents-pve, cstream, mail-transport-agent, libxml-parser-perl, perl-suid, lzop
|
||||
Conflicts: netcat-openbsd, vzdump
|
||||
Replaces: vzdump
|
||||
Provides: vzdump
|
||||
|
Loading…
Reference in New Issue
Block a user