From owner-svn-ports-all@freebsd.org Sun May 3 02:46:03 2020 Return-Path: Delivered-To: svn-ports-all@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 98AD62D0393; Sun, 3 May 2020 02:46:03 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 49F9NC3WfMz456T; Sun, 3 May 2020 02:46:03 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 7426440C9; Sun, 3 May 2020 02:46:03 +0000 (UTC) (envelope-from cy@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 0432k3jd092336; Sun, 3 May 2020 02:46:03 GMT (envelope-from cy@FreeBSD.org) Received: (from cy@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 0432k2Ei092333; Sun, 3 May 2020 02:46:02 GMT (envelope-from cy@FreeBSD.org) Message-Id: <202005030246.0432k2Ei092333@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cy set sender to cy@FreeBSD.org using -f From: Cy Schubert Date: Sun, 3 May 2020 02:46:02 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r533736 - in head/sysutils/zetaback: . files X-SVN-Group: ports-head X-SVN-Commit-Author: cy X-SVN-Commit-Paths: in head/sysutils/zetaback: . files X-SVN-Commit-Revision: 533736 X-SVN-Commit-Repository: ports MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 03 May 2020 02:46:03 -0000 Author: cy Date: Sun May 3 02:46:02 2020 New Revision: 533736 URL: https://svnweb.freebsd.org/changeset/ports/533736 Log: Add compression program and output to localhost options PR 246132 Mostly by: Armin Gruner MFH: 2020Q2 Added: head/sysutils/zetaback/files/ head/sysutils/zetaback/files/opt-compression.in (contents, props changed) head/sysutils/zetaback/files/opt-localhost.in (contents, props changed) head/sysutils/zetaback/files/patch-zetaback.in (contents, props changed) Modified: head/sysutils/zetaback/Makefile (contents, props changed) Modified: head/sysutils/zetaback/Makefile ============================================================================== --- head/sysutils/zetaback/Makefile Sun May 3 02:45:26 2020 (r533735) +++ head/sysutils/zetaback/Makefile Sun May 3 02:46:02 2020 (r533736) @@ -14,6 +14,13 @@ GH_ACCOUNT= omniti-labs LICENSE= BSD3CLAUSE LICENSE_FILE= ${WRKSRC}/LICENSE +OPTIONS_DEFINE= LOCAL BETTER_COMPRESSION +LOCAL_DESC= Avoid ssh for localhoost backup +BETTER_COMPRESSION_DESC= Allow different compressions for snapshots + +LOCAL_EXTRA_PATCHES= ${PATCHDIR}/opt-localhost.in +BETTER_COMPRESSION_EXTRA_PATCHES= ${PATCHDIR}/opt-compression.in + USES= autoreconf perl5 USE_PERL5= run GNU_CONFIGURE= yes Added: head/sysutils/zetaback/files/opt-compression.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/zetaback/files/opt-compression.in Sun May 3 02:46:02 2020 (r533736) @@ -0,0 +1,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"; ++ } else ($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 |"); + } Added: head/sysutils/zetaback/files/opt-localhost.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/zetaback/files/opt-localhost.in Sun May 3 02:46:02 2020 (r533736) @@ -0,0 +1,56 @@ +--- zetaback.in.orig 2020-05-02 21:18:03 UTC ++++ zetaback.in +@@ -769,7 +769,11 @@ sub zfs_remove_snap($$$) { + } + return unless($snap); + print "Dropping $snap on $fs\n" if($DEBUG); +- `ssh $ssh_config $host $agent -z $fs -d $snap`; ++ if ($host eq "localhost") { ++ `$agent -z $fs -d $snap`; ++ } else { ++ `ssh $ssh_config $host $agent -z $fs -d $snap`; ++ } + } + + # Lots of args.. internally called. +@@ -832,7 +836,12 @@ sub zfs_do_backup($$$$$$;$) { + die "Child exit value: $ev" if ($ev); + } + else { +- my @cmd = ('ssh', split(/ /, $ssh_config), $host, $agent, '-z', $fs); ++ my @cmd; ++ if ($host eq "localhost") { ++ @cmd = ($agent, '-z', $fs); ++ } else { ++ @cmd = ('ssh', split(/ /, $ssh_config), $host, $agent, '-z', $fs); ++ } + if ($type eq "i" || ($type eq "s" && $base)) { + push @cmd, ("-i", $base); + } +@@ -1346,7 +1359,11 @@ sub zfs_restore_part($$$$;$) { + open(DUMP, "__ZFS__ send $dataset |"); + } + eval { +- open(RECEIVER, "| ssh $ssh_config $host $command"); ++ if ($host eq "localhost") { ++ open(RECEIVER, "| $command"); ++ } else { ++ open(RECEIVER, "| ssh $ssh_config $host $command"); ++ } + my $buffer; + while(my $len = sysread(DUMP, $buffer, $BLOCKSIZE)) { + if(syswrite(RECEIVER, $buffer, $len) != $len) { +@@ -1573,7 +1590,12 @@ sub plan_and_run($$) { + # Get list of zfs filesystems from the agent + open(SILENT, ">&", \*STDERR); + close(STDERR); +- my $rv = open(ZFSLIST, "ssh $ssh_config $host $agent -l |"); ++ my $rv; ++ if ($host eq "localhost") { ++ $rv = open(ZFSLIST, "$agent -l |"); ++ } else { ++ $rv = open(ZFSLIST, "ssh $ssh_config $host $agent -l |"); ++ } + open(STDERR, ">&", \*SILENT); + close(SILENT); + next unless $rv; Added: head/sysutils/zetaback/files/patch-zetaback.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/zetaback/files/patch-zetaback.in Sun May 3 02:46:02 2020 (r533736) @@ -0,0 +1,11 @@ +--- zetaback.in.orig 2019-01-31 22:04:38 UTC ++++ zetaback.in +@@ -1585,7 +1585,7 @@ sub plan_and_run($$) { + + foreach my $diskline (@disklist) { + chomp($diskline); +- next unless($diskline =~ /^(\S+) \[([^\]]*)\](?: {([^}]*)})?/); ++ next unless($diskline =~ /^(\S+) \[([^\]]*)\](?: \{([^}]*)\})?/); + my $diskname = $1; + my %snaps; + map { $snaps{$_} = 1 } (split(/,/, $2));