1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-17 01:12:23 +02:00

Code cleanup in preparation for improved stanza-create command.

Contributed by Cynthia Shang.
This commit is contained in:
Cynthia Shang
2016-12-03 10:28:08 -05:00
committed by David Steele
parent 005fc08795
commit b7f1738200
11 changed files with 66 additions and 47 deletions

View File

@ -170,7 +170,17 @@ local $EVAL_ERROR = undef; eval
}
################################################################################################################################
# Process stanza-upgrade command
# Acquire the command lock
################################################################################################################################
lockAcquire(commandGet());
################################################################################################################################
# Open the log file
################################################################################################################################
logFileSet(optionGet(OPTION_LOG_PATH) . '/' . optionGet(OPTION_STANZA) . '-' . lc(commandGet()));
################################################################################################################################
# Process stanza-create command
################################################################################################################################
if (commandTest(CMD_STANZA_CREATE))
{
@ -186,16 +196,6 @@ local $EVAL_ERROR = undef; eval
exitSafe(new pgBackRest::Stanza()->process());
}
################################################################################################################################
# Acquire the command lock
################################################################################################################################
lockAcquire(commandGet());
################################################################################################################################
# Open the log file
################################################################################################################################
logFileSet(optionGet(OPTION_LOG_PATH) . '/' . optionGet(OPTION_STANZA) . '-' . lc(commandGet()));
################################################################################################################################
# RESTORE
################################################################################################################################

View File

@ -167,6 +167,14 @@
<release-item>
<p>Simplified the result hash of <code>File->manifest()</code>, <code>Db->tablespaceMapGet()</code>, and <code>Db->databaseMapGet()</code>.</p>
</release-item>
<release-item>
<release-item-contributor-list>
<release-item-contributor id="shang.cynthia"/>
</release-item-contributor-list>
<p>Code cleanup in preparation for improved <cmd>stanza-create</cmd> command.</p>
</release-item>
</release-refactor-list>
</release-core-list>

View File

@ -45,12 +45,6 @@ my $oWalMagicHash =
hex('0xD093') => PG_VERSION_96,
};
####################################################################################################################################
# PostgreSQL WAL system id offset
####################################################################################################################################
use constant PG_WAL_SYSTEM_ID_OFFSET_GTE_93 => 20;
use constant PG_WAL_SYSTEM_ID_OFFSET_LT_93 => 12;
####################################################################################################################################
# constructor
####################################################################################################################################
@ -130,7 +124,7 @@ sub getProcess
# Make sure the destination file is defined
if (!defined($ARGV[2]))
{
confess &log(ERROR, 'WAL segment destination no provided', ERROR_PARAM_REQUIRED);
confess &log(ERROR, 'WAL segment destination not provided', ERROR_PARAM_REQUIRED);
}
# Info for the Postgres log

View File

@ -13,6 +13,23 @@ use Exporter qw(import);
use pgBackRest::DbVersion;
use pgBackRest::Common::Log;
####################################################################################################################################
# RegEx constants
####################################################################################################################################
use constant REGEX_ARCHIVE_DIR_DB_VERSION => '^[0-9]+\.[0-9]+-[0-9]+$';
push @EXPORT, qw(REGEX_ARCHIVE_DIR_DB_VERSION);
use constant REGEX_ARCHIVE_DIR_WAL => '^[0-F]{16}$';
push @EXPORT, qw(REGEX_ARCHIVE_DIR_WAL);
####################################################################################################################################
# PostgreSQL WAL system id offset
####################################################################################################################################
use constant PG_WAL_SYSTEM_ID_OFFSET_GTE_93 => 20;
push @EXPORT, qw(PG_WAL_SYSTEM_ID_OFFSET_GTE_93);
use constant PG_WAL_SYSTEM_ID_OFFSET_LT_93 => 12;
push @EXPORT, qw(PG_WAL_SYSTEM_ID_OFFSET_LT_93);
####################################################################################################################################
# lsnNormalize
#

View File

@ -32,7 +32,7 @@ use constant ARCHIVE_INFO_FILE => 'archive.
our @EXPORT = qw(ARCHIVE_INFO_FILE);
####################################################################################################################################
# Backup info Constants
# Archive info constants
####################################################################################################################################
use constant INFO_ARCHIVE_SECTION_DB => INFO_BACKUP_SECTION_DB;
push @EXPORT, qw(INFO_ARCHIVE_SECTION_DB);

View File

@ -880,7 +880,7 @@ sub process
fileList($oFileLocal->pathGet(PATH_BACKUP_CLUSTER, PATH_BACKUP_HISTORY . '/' . timestampFormat('%4d', $lTimestampStop)),
($strType eq BACKUP_TYPE_FULL ? '^' : '_') .
timestampFileFormat(undef, $lTimestampStop) .
($strType eq BACKUP_TYPE_FULL ? 'F' : '(D|I)\.manifest\.gz$'), undef, true))
($strType eq BACKUP_TYPE_FULL ? 'F' : '(D|I)\.manifest\.' . $oFileLocal->{strCompressExtension}), undef, true))
{
waitRemainder();
$strBackupLabel = backupLabelFormat($strType, $strBackupLastPath, time());

View File

@ -550,6 +550,8 @@ use constant OPTION_DEFAULT_DB_USER => 'postgres
# &CMD_CHECK => true,
# false - used in conjuntion with OPTION_RULE_DEFAULT so the user cannot override this option. If the option is provided for the
# command by the user, it will be ignored and the default will be used.
# NOTE: If the option (A) has a dependency on another option (B) then the CMD_ must also be specified in the other option (B),
# else it will still error on the option (A).
#
# OPTION_RULE_REQUIRED:
# In global section:
@ -573,7 +575,8 @@ use constant OPTION_DEFAULT_DB_USER => 'postgres
# The option can be negated with "no" e.g. --no-lock.
#
# OPTION_RULE_DEPEND:
# Specify the dependencies this option has on another option.
# Specify the dependencies this option has on another option. All commands listed for this option must also be listed in the
# dependent option(s).
# OPTION_RULE_DEPEND_LIST further defines the allowable settings for the depended option.
#
# OPTION_RULE_ALLOW_LIST:
@ -1149,6 +1152,7 @@ my %oOptionRule =
{
&CMD_ARCHIVE_GET => true,
&CMD_ARCHIVE_PUSH => true,
&CMD_STANZA_CREATE => true,
&CMD_BACKUP => true,
&CMD_INFO => true,
&CMD_LOCAL => true,

View File

@ -14,6 +14,7 @@ use Scalar::Util qw(looks_like_number);
use pgBackRest::Common::Exception;
use pgBackRest::Common::Log;
use pgBackRest::ArchiveCommon;
use pgBackRest::BackupCommon;
use pgBackRest::BackupInfo;
use pgBackRest::Config::Config;
@ -317,7 +318,7 @@ sub process
}
# Get all major archive paths (timeline and first 64 bits of LSN)
foreach my $strPath ($oFile->list(PATH_BACKUP_ARCHIVE, $strArchiveId, "^[0-F]{16}\$"))
foreach my $strPath ($oFile->list(PATH_BACKUP_ARCHIVE, $strArchiveId, REGEX_ARCHIVE_DIR_WAL))
{
logDebugMisc($strOperation, "found major WAL path: ${strPath}");
$bRemove = true;

View File

@ -10,13 +10,8 @@ use strict;
use warnings FATAL => qw(all);
use Carp qw(confess);
use DBI;
use Exporter qw(import);
use Fcntl ':mode';
use File::Basename qw(dirname);
use File::Copy 'cp';
use File::stat;
use Time::HiRes qw(gettimeofday);
use pgBackRest::Archive;
use pgBackRest::ArchiveInfo;