mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Removed moose from File object.
This commit is contained in:
parent
c1d6890c60
commit
2c173ba53e
@ -398,12 +398,12 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
|||||||
my $bCompress = $bCompressAsync ? false : config_key_load($strSection, CONFIG_KEY_COMPRESS, true, 'y') eq 'y' ? true : false;
|
my $bCompress = $bCompressAsync ? false : config_key_load($strSection, CONFIG_KEY_COMPRESS, true, 'y') eq 'y' ? true : false;
|
||||||
|
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strRemote => $bArchiveLocal ? REMOTE_NONE : $strRemote,
|
config_key_load($strSection, CONFIG_KEY_PATH, true),
|
||||||
oRemote => $bArchiveLocal ? undef : remote_get(),
|
$bArchiveLocal ? REMOTE_NONE : $strRemote,
|
||||||
strBackupPath => config_key_load($strSection, CONFIG_KEY_PATH, true)
|
$bArchiveLocal ? undef : remote_get()
|
||||||
);
|
);
|
||||||
|
|
||||||
# Init backup
|
# Init backup
|
||||||
@ -469,12 +469,12 @@ if ($strOperation eq OP_ARCHIVE_PUSH)
|
|||||||
# eval
|
# eval
|
||||||
# {
|
# {
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strRemote => $strRemote,
|
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true),
|
||||||
oRemote => remote_get(),
|
$strRemote,
|
||||||
strBackupPath => config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true)
|
remote_get()
|
||||||
);
|
);
|
||||||
|
|
||||||
# Init backup
|
# Init backup
|
||||||
@ -572,12 +572,12 @@ if ($strOperation eq OP_ARCHIVE_GET)
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Init the file object
|
# Init the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strRemote => $strRemote,
|
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true),
|
||||||
oRemote => remote_get(),
|
$strRemote,
|
||||||
strBackupPath => config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true)
|
remote_get()
|
||||||
);
|
);
|
||||||
|
|
||||||
# Init the backup object
|
# Init the backup object
|
||||||
@ -645,12 +645,12 @@ if (!lock_file_create($strLockPath))
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Initialize the default file object
|
# Initialize the default file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strRemote => $strRemote,
|
config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true),
|
||||||
oRemote => remote_get(),
|
$strRemote,
|
||||||
strBackupPath => config_key_load(CONFIG_SECTION_BACKUP, CONFIG_KEY_PATH, true)
|
remote_get()
|
||||||
);
|
);
|
||||||
|
|
||||||
# Initialize the db object
|
# Initialize the db object
|
||||||
|
@ -54,12 +54,15 @@ sub param_get
|
|||||||
log_level_set(OFF, OFF);
|
log_level_set(OFF, OFF);
|
||||||
|
|
||||||
# Create the remote object
|
# Create the remote object
|
||||||
my $oRemote = BackRest::Remote->new();
|
my $oRemote = new BackRest::Remote();
|
||||||
|
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
oRemote => $oRemote
|
undef,
|
||||||
|
undef,
|
||||||
|
undef,
|
||||||
|
$oRemote
|
||||||
);
|
);
|
||||||
|
|
||||||
# Write the greeting so remote process knows who we are
|
# Write the greeting so remote process knows who we are
|
||||||
|
@ -1143,7 +1143,7 @@ sub backup_file
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
# End each thread queue and start the backu_file threads
|
# End each thread queue and start the backup_file threads
|
||||||
for (my $iThreadIdx = 0; $iThreadIdx < $iThreadLocalMax; $iThreadIdx++)
|
for (my $iThreadIdx = 0; $iThreadIdx < $iThreadLocalMax; $iThreadIdx++)
|
||||||
{
|
{
|
||||||
# Output info about how much work each thread is going to do
|
# Output info about how much work each thread is going to do
|
||||||
|
@ -48,4 +48,4 @@ sub message
|
|||||||
return $self->{strMessage};
|
return $self->{strMessage};
|
||||||
}
|
}
|
||||||
|
|
||||||
return 1;
|
1;
|
||||||
|
@ -8,7 +8,6 @@ use strict;
|
|||||||
use warnings;
|
use warnings;
|
||||||
use Carp;
|
use Carp;
|
||||||
|
|
||||||
use Moose;
|
|
||||||
use Net::OpenSSH;
|
use Net::OpenSSH;
|
||||||
use File::Basename;
|
use File::Basename;
|
||||||
use File::Copy qw(cp);
|
use File::Copy qw(cp);
|
||||||
@ -41,24 +40,6 @@ our @EXPORT = qw(PATH_ABSOLUTE PATH_DB PATH_DB_ABSOLUTE PATH_BACKUP PATH_BACKUP_
|
|||||||
OP_FILE_LIST OP_FILE_EXISTS OP_FILE_HASH OP_FILE_REMOVE OP_FILE_MANIFEST OP_FILE_COMPRESS
|
OP_FILE_LIST OP_FILE_EXISTS OP_FILE_HASH OP_FILE_REMOVE OP_FILE_MANIFEST OP_FILE_COMPRESS
|
||||||
OP_FILE_MOVE OP_FILE_COPY OP_FILE_COPY_OUT OP_FILE_COPY_IN OP_FILE_PATH_CREATE);
|
OP_FILE_MOVE OP_FILE_COPY OP_FILE_COPY_OUT OP_FILE_COPY_IN OP_FILE_PATH_CREATE);
|
||||||
|
|
||||||
# Extension and permissions
|
|
||||||
has strCompressExtension => (is => 'ro', default => 'gz');
|
|
||||||
has strDefaultPathPermission => (is => 'bare', default => '0750');
|
|
||||||
has strDefaultFilePermission => (is => 'ro', default => '0640');
|
|
||||||
|
|
||||||
# Command strings
|
|
||||||
has strCommand => (is => 'bare');
|
|
||||||
|
|
||||||
# Module variables
|
|
||||||
has strRemote => (is => 'bare'); # Remote type (db or backup)
|
|
||||||
has oRemote => (is => 'bare'); # Remote object
|
|
||||||
|
|
||||||
has strBackupPath => (is => 'bare'); # Backup base path
|
|
||||||
|
|
||||||
# Process flags
|
|
||||||
has strStanza => (is => 'bare');
|
|
||||||
has iThreadIdx => (is => 'bare');
|
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# COMMAND Error Constants
|
# COMMAND Error Constants
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
@ -130,9 +111,34 @@ use constant
|
|||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
# CONSTRUCTOR
|
# CONSTRUCTOR
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
sub BUILD
|
sub new
|
||||||
{
|
{
|
||||||
my $self = shift;
|
my $class = shift;
|
||||||
|
my $strStanza = shift;
|
||||||
|
my $strBackupPath = shift;
|
||||||
|
my $strRemote = shift;
|
||||||
|
my $oRemote = shift;
|
||||||
|
my $strDefaultPathPermission = shift;
|
||||||
|
my $strDefaultFilePermission = shift;
|
||||||
|
my $iThreadIdx = shift;
|
||||||
|
|
||||||
|
# Create the class hash
|
||||||
|
my $self = {};
|
||||||
|
bless $self, $class;
|
||||||
|
|
||||||
|
# Default compression extension to gz
|
||||||
|
$self->{strCompressExtension} = 'gz';
|
||||||
|
|
||||||
|
# Default file and path permissions
|
||||||
|
$self->{strDefaultPathPermission} = defined($strDefaultPathPermission) ? $strDefaultPathPermission : '0750';
|
||||||
|
$self->{strDefaultFilePermission} = defined($strDefaultFilePermission) ? $strDefaultFilePermission : '0640';
|
||||||
|
|
||||||
|
# Initialize other variables
|
||||||
|
$self->{strStanza} = $strStanza;
|
||||||
|
$self->{strBackupPath} = $strBackupPath;
|
||||||
|
$self->{strRemote} = $strRemote;
|
||||||
|
$self->{oRemote} = $oRemote;
|
||||||
|
$self->{iThreadIdx} = $iThreadIdx;
|
||||||
|
|
||||||
# If remote is defined check parameters and open session
|
# If remote is defined check parameters and open session
|
||||||
if (defined($self->{strRemote}) && $self->{strRemote} ne REMOTE_NONE)
|
if (defined($self->{strRemote}) && $self->{strRemote} ne REMOTE_NONE)
|
||||||
@ -140,7 +146,8 @@ sub BUILD
|
|||||||
# Make sure remote is valid
|
# Make sure remote is valid
|
||||||
if ($self->{strRemote} ne REMOTE_DB && $self->{strRemote} ne REMOTE_BACKUP)
|
if ($self->{strRemote} ne REMOTE_DB && $self->{strRemote} ne REMOTE_BACKUP)
|
||||||
{
|
{
|
||||||
confess &log(ASSERT, 'strRemote must be "' . REMOTE_DB . '" or "' . REMOTE_BACKUP . '"');
|
confess &log(ASSERT, 'strRemote must be "' . REMOTE_DB . '" or "' . REMOTE_BACKUP .
|
||||||
|
"\", $self->{strRemote} was passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Remote object must be set
|
# Remote object must be set
|
||||||
@ -149,6 +156,8 @@ sub BUILD
|
|||||||
confess &log(ASSERT, 'oRemote must be defined');
|
confess &log(ASSERT, 'oRemote must be defined');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $self;
|
||||||
}
|
}
|
||||||
|
|
||||||
####################################################################################################################################
|
####################################################################################################################################
|
||||||
@ -179,12 +188,13 @@ sub clone
|
|||||||
|
|
||||||
return BackRest::File->new
|
return BackRest::File->new
|
||||||
(
|
(
|
||||||
strCommand => $self->{strCommand},
|
$self->{strStanza},
|
||||||
strRemote => $self->{strRemote},
|
$self->{strBackupPath},
|
||||||
oRemote => defined($self->{oRemote}) ? $self->{oRemote}->clone($iThreadIdx) : undef,
|
$self->{strRemote},
|
||||||
strBackupPath => $self->{strBackupPath},
|
defined($self->{oRemote}) ? $self->{oRemote}->clone() : undef,
|
||||||
strStanza => $self->{strStanza},
|
$self->{strDefaultPathPermission},
|
||||||
iThreadIdx => $iThreadIdx
|
$self->{strDefaultFilePermission},
|
||||||
|
$iThreadIdx
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1467,5 +1477,4 @@ sub copy
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
no Moose;
|
1;
|
||||||
__PACKAGE__->meta->make_immutable;
|
|
||||||
|
@ -216,4 +216,4 @@ sub process_end
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
true;
|
1;
|
||||||
|
@ -718,4 +718,4 @@ sub command_execute
|
|||||||
return $self->output_read($bOutputRequired, $strErrorPrefix);
|
return $self->output_read($bOutputRequired, $strErrorPrefix);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
1;
|
||||||
|
@ -294,12 +294,12 @@ sub BackRestTestBackup_Test
|
|||||||
if ($bCreate)
|
if ($bCreate)
|
||||||
{
|
{
|
||||||
# Create the file object
|
# Create the file object
|
||||||
$oFile = (BackRest::File->new
|
$oFile = (new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => BackRestTestCommon_BackupPathGet(),
|
BackRestTestCommon_BackupPathGet(),
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
))->clone();
|
))->clone();
|
||||||
|
|
||||||
BackRestTestBackup_Create($bRemote, false);
|
BackRestTestBackup_Create($bRemote, false);
|
||||||
@ -426,10 +426,10 @@ sub BackRestTestBackup_Test
|
|||||||
# Create the file object
|
# Create the file object
|
||||||
$oFile = (BackRest::File->new
|
$oFile = (BackRest::File->new
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => BackRestTestCommon_BackupPathGet(),
|
BackRestTestCommon_BackupPathGet(),
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
))->clone();
|
))->clone();
|
||||||
|
|
||||||
BackRestTestBackup_Create($bRemote, false);
|
BackRestTestBackup_Create($bRemote, false);
|
||||||
|
@ -109,13 +109,13 @@ sub BackRestTestFile_Test
|
|||||||
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
||||||
{
|
{
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = (BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
))->clone();
|
);
|
||||||
|
|
||||||
# Loop through error
|
# Loop through error
|
||||||
for (my $bError = 0; $bError <= 1; $bError++)
|
for (my $bError = 0; $bError <= 1; $bError++)
|
||||||
@ -217,13 +217,13 @@ sub BackRestTestFile_Test
|
|||||||
for (my $bRemote = 0; $bRemote <= 0; $bRemote++)
|
for (my $bRemote = 0; $bRemote <= 0; $bRemote++)
|
||||||
{
|
{
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = (new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
))->clone(1);
|
||||||
|
|
||||||
# Loop through source exists
|
# Loop through source exists
|
||||||
for (my $bSourceExists = 0; $bSourceExists <= 1; $bSourceExists++)
|
for (my $bSourceExists = 0; $bSourceExists <= 1; $bSourceExists++)
|
||||||
@ -316,12 +316,12 @@ sub BackRestTestFile_Test
|
|||||||
for (my $bRemote = 0; $bRemote <= 0; $bRemote++)
|
for (my $bRemote = 0; $bRemote <= 0; $bRemote++)
|
||||||
{
|
{
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
# Loop through exists
|
# Loop through exists
|
||||||
@ -419,12 +419,12 @@ sub BackRestTestFile_Test
|
|||||||
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
||||||
{
|
{
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
for (my $bError = 0; $bError <= 1; $bError++)
|
for (my $bError = 0; $bError <= 1; $bError++)
|
||||||
@ -561,12 +561,12 @@ sub BackRestTestFile_Test
|
|||||||
for (my $bRemote = false; $bRemote <= true; $bRemote++)
|
for (my $bRemote = false; $bRemote <= true; $bRemote++)
|
||||||
{
|
{
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
for (my $bSort = false; $bSort <= true; $bSort++)
|
for (my $bSort = false; $bSort <= true; $bSort++)
|
||||||
@ -687,12 +687,12 @@ sub BackRestTestFile_Test
|
|||||||
|
|
||||||
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
||||||
{
|
{
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
# Loop through exists
|
# Loop through exists
|
||||||
@ -790,12 +790,12 @@ sub BackRestTestFile_Test
|
|||||||
|
|
||||||
for (my $bRemote = false; $bRemote <= true; $bRemote++)
|
for (my $bRemote = false; $bRemote <= true; $bRemote++)
|
||||||
{
|
{
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
# Loop through error
|
# Loop through error
|
||||||
@ -880,12 +880,12 @@ sub BackRestTestFile_Test
|
|||||||
|
|
||||||
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
for (my $bRemote = 0; $bRemote <= 1; $bRemote++)
|
||||||
{
|
{
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $bRemote ? 'backup' : undef,
|
$bRemote ? 'backup' : undef,
|
||||||
oRemote => $bRemote ? $oRemote : undef
|
$bRemote ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
# Loop through exists
|
# Loop through exists
|
||||||
@ -978,12 +978,12 @@ sub BackRestTestFile_Test
|
|||||||
my $strRemote = $bBackupRemote ? 'backup' : $bDbRemote ? 'db' : undef;
|
my $strRemote = $bBackupRemote ? 'backup' : $bDbRemote ? 'db' : undef;
|
||||||
|
|
||||||
# Create the file object
|
# Create the file object
|
||||||
my $oFile = BackRest::File->new
|
my $oFile = new BackRest::File
|
||||||
(
|
(
|
||||||
strStanza => $strStanza,
|
$strStanza,
|
||||||
strBackupPath => $strTestPath,
|
$strTestPath,
|
||||||
strRemote => $strRemote,
|
$strRemote,
|
||||||
oRemote => defined($strRemote) ? $oRemote : undef
|
defined($strRemote) ? $oRemote : undef
|
||||||
);
|
);
|
||||||
|
|
||||||
# Loop through source compression
|
# Loop through source compression
|
||||||
|
Loading…
Reference in New Issue
Block a user