2015-08-05 14:43:41 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# PROTOCOL REMOTE MASTER MODULE
|
|
|
|
####################################################################################################################################
|
|
|
|
package BackRest::Protocol::RemoteMaster;
|
|
|
|
use parent 'BackRest::Protocol::CommonMaster';
|
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use File::Basename qw(dirname);
|
|
|
|
|
|
|
|
use lib dirname($0) . '/../lib';
|
2015-08-29 20:20:46 +02:00
|
|
|
use BackRest::Common::Log;
|
2015-09-08 13:31:24 +02:00
|
|
|
use BackRest::Config::Config;
|
2015-08-05 14:43:41 +02:00
|
|
|
use BackRest::Protocol::CommonMaster;
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# Operation constants
|
|
|
|
####################################################################################################################################
|
|
|
|
use constant OP_PROTOCOL_REMOTE_MASTER => 'Protocol::RemoteMaster';
|
|
|
|
|
|
|
|
use constant OP_PROTOCOL_REMOTE_MASTER_NEW => OP_PROTOCOL_REMOTE_MASTER . "->new";
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# CONSTRUCTOR
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
2015-08-29 20:20:46 +02:00
|
|
|
my $class = shift;
|
2015-08-05 14:43:41 +02:00
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$strCommand, # Command to execute on local/remote
|
|
|
|
$iBlockSize, # Buffer size
|
|
|
|
$iCompressLevel, # Set compression level
|
|
|
|
$iCompressLevelNetwork, # Set compression level for network only compression
|
|
|
|
$strHost, # Host to connect to for remote (optional as this can also be used for local)
|
|
|
|
$strUser # User to connect to for remote (must be set if strHost is set)
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
|
|
|
OP_PROTOCOL_REMOTE_MASTER_NEW, \@_,
|
|
|
|
{name => 'strCommand'},
|
|
|
|
{name => 'iBlockSize'},
|
|
|
|
{name => 'iCompressLevel'},
|
|
|
|
{name => 'iCompressLevelNetwork'},
|
|
|
|
{name => 'strHost'},
|
|
|
|
{name => 'strUser'}
|
|
|
|
);
|
2015-08-05 14:43:41 +02:00
|
|
|
|
|
|
|
# Create SSH command
|
|
|
|
$strCommand = "ssh -o Compression=no -o PasswordAuthentication=no ${strUser}\@${strHost} '${strCommand}'";
|
|
|
|
|
|
|
|
# Init object and store variables
|
|
|
|
my $self = $class->SUPER::new('remote', $strCommand, $iBlockSize, $iCompressLevel, $iCompressLevelNetwork);
|
|
|
|
bless $self, $class;
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'self', value => $self}
|
|
|
|
);
|
2015-08-05 14:43:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
####################################################################################################################################
|
|
|
|
# CLONE
|
|
|
|
####################################################################################################################################
|
|
|
|
sub clone
|
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
return BackRest::Protocol::RemoteMaster->new
|
|
|
|
(
|
|
|
|
$self->{strCommand},
|
|
|
|
$self->{iBlockSize},
|
|
|
|
$self->{iCompressLevel},
|
|
|
|
$self->{iCompressLevelNetwork},
|
|
|
|
$self->{strHost},
|
|
|
|
$self->{strUser}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
1;
|