diff --git a/CHANGELIST b/CHANGELIST index 95ae8c6..0357c0e 100644 --- a/CHANGELIST +++ b/CHANGELIST @@ -1,3 +1,5 @@ +1.4.3 added SSH persistence to syncoid - using socket speeds up SSH overhead 300%! =) + 1.4.2 removed -r flag for zfs destroy of pruned snapshots in sanoid, which unintentionally caused same-name child snapshots to be deleted - thank you Lenz Weber! 1.4.1 updated check_zpool() in sanoid to parse zpool list properly both pre- and post- ZoL v0.6.4 diff --git a/VERSION b/VERSION index 9df886c..428b770 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -1.4.2 +1.4.3 diff --git a/findoid b/findoid index 560eefc..98d4fb7 100755 --- a/findoid +++ b/findoid @@ -11,7 +11,7 @@ use warnings; my $zfs = '/sbin/zfs'; my %args = getargs(@ARGV); -my $progversion = '1.4.2'; +my $progversion = '1.4.3'; if ($args{'version'}) { print "$progversion\n"; exit 0; } diff --git a/sanoid b/sanoid index dfaaf01..1c43e47 100755 --- a/sanoid +++ b/sanoid @@ -4,7 +4,7 @@ # from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this # project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE. -my $version = '1.4.2'; +my $version = '1.4.3'; use strict; use Config::IniFiles; # read samba-style conf file diff --git a/syncoid b/syncoid index 9d91c32..632acda 100755 --- a/syncoid +++ b/syncoid @@ -4,7 +4,7 @@ # from http://www.gnu.org/licenses/gpl-3.0.html on 2014-11-17. A copy should also be available in this # project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE. -my $version = '1.4.2'; +my $version = '1.4.3'; use strict; use Data::Dumper; @@ -35,6 +35,7 @@ my $mbufferoptions = '-q -s 128k -m 16M 2>/dev/null'; my $lscmd = '/bin/ls'; # figure out if source and/or target are remote. +$sshcmd = "$sshcmd $sshcipher"; my ($sourcehost,$sourcefs,$sourceisroot) = getssh($rawsourcefs); my ($targethost,$targetfs,$targetisroot) = getssh($rawtargetfs); @@ -47,7 +48,6 @@ if ($targetisroot) { $targetsudocmd = ''; } else { $targetsudocmd = $sudocmd; } # are available on source, target, local machines. # warn user of anything missing, then continue with sync. my %avail = checkcommands(); -$sshcmd = "$sshcmd $sshcipher"; my %snaps; @@ -68,6 +68,16 @@ if (! $args{'recursive'}) { } } +# close SSH sockets for master connections as applicable +if ($sourcehost ne '') { + open FH, "$sshcmd $sourcehost -O exit |"; + close FH; +} +if ($targethost ne '') { + open FH, "$sshcmd $targethost -O exit |"; + close FH; +} + exit 0; ############################################################################## @@ -674,6 +684,8 @@ sub getssh { my $rhost; my $isroot; + my $socket; + # if we got passed something with an @ in it, we assume it's an ssh connection, eg root@myotherbox if ($fs =~ /\@/) { $rhost = $fs; $fs =~ s/^\S*\@\S*://; @@ -681,6 +693,11 @@ sub getssh { my $remoteuser = $rhost; $remoteuser =~ s/\@.*$//; if ($remoteuser eq 'root') { $isroot = 1; } else { $isroot = 0; } + # now we need to establish a persistent master SSH connection + $socket = "/tmp/syncoid-$remoteuser-$rhost-" . time(); + open FH, "$sshcmd -M -S $socket -o ControlPersist=yes $rhost exit |"; + close FH; + $rhost = "-S $socket $rhost"; } else { my $localuid = $<; if ($localuid == 0) { $isroot = 1; } else { $isroot = 0; }