2015-04-01 21:58:33 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# ARCHIVE MODULE
|
|
|
|
####################################################################################################################################
|
2017-01-11 02:51:20 +02:00
|
|
|
package pgBackRest::Archive::Archive;
|
2015-04-01 21:58:33 +02:00
|
|
|
|
|
|
|
use strict;
|
|
|
|
use warnings FATAL => qw(all);
|
|
|
|
use Carp qw(confess);
|
|
|
|
|
|
|
|
use Exporter qw(import);
|
2015-08-29 20:20:46 +02:00
|
|
|
our @EXPORT = qw();
|
2017-01-11 02:59:32 +02:00
|
|
|
use File::Basename qw(dirname);
|
2015-04-01 21:58:33 +02:00
|
|
|
|
2017-01-11 02:59:32 +02:00
|
|
|
use pgBackRest::Archive::ArchiveInfo;
|
|
|
|
use pgBackRest::Db;
|
|
|
|
use pgBackRest::DbVersion;
|
2016-04-14 15:30:54 +02:00
|
|
|
use pgBackRest::Common::Exception;
|
|
|
|
use pgBackRest::Common::Log;
|
|
|
|
use pgBackRest::Common::Wait;
|
|
|
|
use pgBackRest::Config::Config;
|
|
|
|
use pgBackRest::File;
|
2016-08-24 18:39:27 +02:00
|
|
|
use pgBackRest::Protocol::Common;
|
2016-05-14 16:33:12 +02:00
|
|
|
|
2015-04-01 21:58:33 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# constructor
|
|
|
|
####################################################################################################################################
|
|
|
|
sub new
|
|
|
|
{
|
|
|
|
my $class = shift; # Class name
|
|
|
|
|
2015-08-29 20:20:46 +02:00
|
|
|
# Assign function parameters, defaults, and log debug info
|
2016-08-11 23:32:28 +02:00
|
|
|
my ($strOperation) = logDebugParam(__PACKAGE__ . '->new');
|
2015-08-29 20:20:46 +02:00
|
|
|
|
2015-04-01 21:58:33 +02:00
|
|
|
# Create the class hash
|
|
|
|
my $self = {};
|
|
|
|
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-04-01 21:58:33 +02:00
|
|
|
}
|
|
|
|
|
2015-06-14 00:25:49 +02:00
|
|
|
####################################################################################################################################
|
|
|
|
# getCheck
|
|
|
|
####################################################################################################################################
|
|
|
|
sub getCheck
|
2016-07-29 20:02:11 +02:00
|
|
|
{
|
|
|
|
my $self = shift;
|
|
|
|
|
|
|
|
# Assign function parameters, defaults, and log debug info
|
|
|
|
my
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
$oFile,
|
|
|
|
$strDbVersion,
|
|
|
|
$ullDbSysId
|
|
|
|
) =
|
|
|
|
logDebugParam
|
|
|
|
(
|
2016-08-11 23:32:28 +02:00
|
|
|
__PACKAGE__ . '->getCheck', \@_,
|
2016-07-29 20:02:11 +02:00
|
|
|
{name => 'oFile'},
|
|
|
|
{name => 'strDbVersion', required => false},
|
|
|
|
{name => 'ullDbSysId', required => false}
|
|
|
|
);
|
|
|
|
|
|
|
|
my $strArchiveId;
|
|
|
|
|
|
|
|
# If the dbVersion/dbSysId are not passed, then we need to retrieve the database information
|
|
|
|
if (!defined($strDbVersion) || !defined($ullDbSysId) )
|
|
|
|
{
|
|
|
|
# get DB info for comparison
|
2016-11-30 21:15:11 +02:00
|
|
|
($strDbVersion, my $iControlVersion, my $iCatalogVersion, $ullDbSysId) = dbMasterGet()->info();
|
2016-07-29 20:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if ($oFile->isRemote(PATH_BACKUP_ARCHIVE))
|
|
|
|
{
|
2016-12-04 00:34:51 +02:00
|
|
|
$strArchiveId = $oFile->{oProtocol}->cmdExecute(OP_ARCHIVE_GET_CHECK, [$strDbVersion, $ullDbSysId], true);
|
2016-07-29 20:02:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-12-20 23:52:20 +02:00
|
|
|
# check that the archive info is compatible with the database
|
2016-07-29 20:02:11 +02:00
|
|
|
$strArchiveId =
|
2017-01-11 02:51:20 +02:00
|
|
|
(new pgBackRest::Archive::ArchiveInfo($oFile->pathGet(PATH_BACKUP_ARCHIVE), true))->check($strDbVersion, $ullDbSysId);
|
2016-07-29 20:02:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
# Return from function and log return values if any
|
|
|
|
return logDebugReturn
|
|
|
|
(
|
|
|
|
$strOperation,
|
|
|
|
{name => 'strArchiveId', value => $strArchiveId, trace => true}
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2015-04-01 21:58:33 +02:00
|
|
|
1;
|