]> git.proxmox.com Git - pve-manager.git/commitdiff
Fix #2124: Add support for zstd
authorAlwin Antreich <a.antreich@proxmox.com>
Tue, 28 Apr 2020 13:58:09 +0000 (15:58 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 4 May 2020 08:41:59 +0000 (10:41 +0200)
This patch adds the zstd to the compression selection for backup on the
GUI and add .zst to the backup file filter. Including zstd as package
install dependency.

Signed-off-by: Alwin Antreich <a.antreich@proxmox.com>
PVE/VZDump.pm
debian/control
www/manager6/form/CompressionSelector.js

index f32741963d742532c29791c11345c74922e08a7f..80f4734c77e189052e8e5eb276a8844d7d7d47c3 100644 (file)
@@ -609,6 +609,13 @@ sub compressor_info {
        } else {
            return ('gzip --rsyncable', 'gz');
        }
+    } elsif ($opt_compress eq 'zstd') {
+       my $zstd_threads = $opts->{zstd} // 1;
+       if ($zstd_threads == 0) {
+           my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
+           $zstd_threads = int(($cpuinfo->{cpus} + 1)/2);
+       }
+       return ("zstd --threads=${zstd_threads}", 'zst');
     } else {
        die "internal error - unknown compression option '$opt_compress'";
     }
@@ -620,7 +627,7 @@ sub get_backup_file_list {
     my $bklist = [];
     foreach my $fn (<$dir/${bkname}-*>) {
        next if $exclude_fn && $fn eq $exclude_fn;
-       if ($fn =~ m!/(${bkname}-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|((tar|vma)(\.(gz|lzo))?)))$!) {
+       if ($fn =~ m!/(${bkname}-(\d{4})_(\d{2})_(\d{2})-(\d{2})_(\d{2})_(\d{2})\.(tgz|((tar|vma)(\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?)))$!) {
            $fn = "$dir/$1"; # untaint
            my $t = timelocal ($7, $6, $5, $4, $3 - 1, $2);
            push @$bklist, [$fn, $t];
@@ -928,7 +935,7 @@ sub exec_backup_task {
                    debugmsg ('info', "delete old backup '$d->[0]'", $logfd);
                    unlink $d->[0];
                    my $logfn = $d->[0];
-                   $logfn =~ s/\.(tgz|((tar|vma)(\.(gz|lzo))?))$/\.log/;
+                   $logfn =~ s/\.(tgz|((tar|vma)(\.(${\PVE::Storage::Plugin::COMPRESSOR_RE}))?))$/\.log/;
                    unlink $logfn;
                }
            }
index 435a6aa0a36be2989ac133898f31f66f73df16ea..fa480ba6b3aa49fbd5d556842ce8210a5dc0e6b3 100644 (file)
@@ -62,6 +62,7 @@ Depends: apt-transport-https | apt (>= 1.5~),
          logrotate,
          lsb-base,
          lzop,
+         zstd,
          novnc-pve,
          pciutils,
          perl (>= 5.10.0-19),
index 8938fc0e06a4000c881882e38076d49e7a241233..842b7710574ba95dd2deac42e0173391190644b1 100644 (file)
@@ -4,6 +4,7 @@ Ext.define('PVE.form.CompressionSelector', {
     comboItems: [
                 ['0', Proxmox.Utils.noneText],
                 ['lzo', 'LZO (' + gettext('fast') + ')'],
-                ['gzip', 'GZIP (' + gettext('good') + ')']
+                ['gzip', 'GZIP (' + gettext('good') + ')'],
+                ['zstd', 'ZSTD (' + gettext('better') + ')'],
     ]
 });