summaryrefslogtreecommitdiff
path: root/sysutils/zetaback-devel/files/opt-compression.in
blob: 476225e8cb32b4afc88e7ee8bed076ab74be0d76 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
--- zetaback.in.orig	2019-01-31 14:04:38.000000000 -0800
+++ zetaback.in	2020-05-02 16:38:22.402137000 -0700
@@ -434,11 +434,15 @@
 
 This value defaults to (14 * 86400), or two weeks.
 
+=item compressionprogram
+
+Compress files using gzip, bzip2, or xz. Defaults to gzip.
+
 =item compressionlevel
 
-Compress files using gzip at the specified compression level. 0 means no
-compression. Accepted values are 1-9. Defaults to 1 (fastest/minimal
-compression.)
+Compress files using gzip, bzip2, or xz at the specified compression level.
+0 means no compression. Accepted values are 1-9. Defaults to 1
+(fastest/minimal compression.)
 
 =item ssh_config
 
@@ -781,9 +785,18 @@
 
   # compression is meaningless for dataset backups
   if ($type ne "s") {
+    my $cp = config_get($host, 'compressionprogram');
+    if ($cp ne "xz" && $cp ne "bzip2" && $cp ne "gzip" && $cp ne "") {
+	die "zfs_full_backup: unsupported compression program specified\n";
+    } elsif ($cp eq "") {
+	$cp = "gzip";
+	my $cl = 1;
+    } else {
+	my $cl = 1;
+    }
     my $cl = config_get($host, 'compressionlevel');
     if ($cl >= 1 && $cl <= 9) {
-        open(LBACKUP, "|gzip -$cl >$store/.$dumpname") ||
+        open(LBACKUP, "|$cp -$cl >$store/.$dumpname") ||
         die "zfs_do_backup $host:$fs $type: cannot create dump\n";
     } else {
         open(LBACKUP, ">$store/.$dumpname") ||
@@ -1319,16 +1332,22 @@
   else {
     $command = "__ZFS__ recv $fs";
   }
+  my $cp = config_get($host, 'compressionprogram');
+  if ($cp ne "xz" && $cp ne "bzip2" && $cp ne "gzip" && $cp ne "") {
+      die "zfs_full_backup: unsupported compression program specified\n";
+  } elsif ($cp eq "") {
+      $cp = "gzip";
+  }
   if ($file) {
     print " => piping $file to $command\n" if($DEBUG);
-    print "gzip -dfc $file | ssh $ssh_config $host $command\n" if ($DEBUG && $NEUTERED);
+    print "$cp -dfc $file | ssh $ssh_config $host $command\n" if ($DEBUG);
   } elsif ($dataset) {
     print " => piping $dataset to $command using zfs send\n" if ($DEBUG);
     print "zfs send $dataset | ssh $ssh_config $host $command\n" if ($DEBUG && $NEUTERED);
   }
   unless($NEUTERED) {
     if ($file) {
-      open(DUMP, "gzip -dfc $file |");
+      open(DUMP, "$cp -dfc $file |");
     } elsif ($dataset) {
       open(DUMP, "__ZFS__ send $dataset |");
     }