You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-15 01:04:37 +02:00
Code cleanup in preparation for improved stanza-create command.
Contributed by Cynthia Shang.
This commit is contained in:
committed by
David Steele
parent
005fc08795
commit
b7f1738200
@ -169,8 +169,18 @@ local $EVAL_ERROR = undef; eval
|
||||
exitSafe(new pgBackRest::Info()->process());
|
||||
}
|
||||
|
||||
################################################################################################################################
|
||||
# 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
|
||||
################################################################################################################################
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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
|
||||
@ -1168,28 +1162,28 @@ sub check
|
||||
# Wait for the archive.info to be written. If it does not get written within the timout period then report the last error.
|
||||
do
|
||||
{
|
||||
eval
|
||||
{
|
||||
eval
|
||||
{
|
||||
# check that the archive info file is written and is valid for the current database of the stanza
|
||||
$strArchiveId = $self->getCheck($oFile);
|
||||
|
||||
# Clear any previous errors if we've found the archive.info
|
||||
$iResult = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
or do
|
||||
{
|
||||
# Confess unhandled errors
|
||||
if (!isException($EVAL_ERROR))
|
||||
{
|
||||
confess $EVAL_ERROR;
|
||||
return true;
|
||||
}
|
||||
or do
|
||||
{
|
||||
# Confess unhandled errors
|
||||
if (!isException($EVAL_ERROR))
|
||||
{
|
||||
confess $EVAL_ERROR;
|
||||
}
|
||||
|
||||
# If this is a backrest error then capture the last code and message
|
||||
$iResult = $EVAL_ERROR->code();
|
||||
$strResultMessage = $EVAL_ERROR->message();
|
||||
};
|
||||
# If this is a backrest error then capture the last code and message
|
||||
$iResult = $EVAL_ERROR->code();
|
||||
$strResultMessage = $EVAL_ERROR->message();
|
||||
};
|
||||
} while (!defined($strArchiveId) && waitMore($oWait));
|
||||
|
||||
# If able to get the archive id then check the archived WAL file with the time remaining
|
||||
|
@ -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
|
||||
#
|
||||
|
@ -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);
|
||||
|
@ -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());
|
||||
|
@ -51,13 +51,13 @@ use constant INFO_BACKUP_KEY_ARCHIVE_STOP => MANIFEST_
|
||||
use constant INFO_BACKUP_KEY_BACKUP_STANDBY => MANIFEST_KEY_BACKUP_STANDBY;
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_STANDBY);
|
||||
use constant INFO_BACKUP_KEY_BACKUP_REPO_SIZE => 'backup-info-repo-size';
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_REPO_SIZE);
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_REPO_SIZE);
|
||||
use constant INFO_BACKUP_KEY_BACKUP_REPO_SIZE_DELTA => 'backup-info-repo-size-delta';
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_REPO_SIZE_DELTA);
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_REPO_SIZE_DELTA);
|
||||
use constant INFO_BACKUP_KEY_BACKUP_SIZE => 'backup-info-size';
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_SIZE);
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_SIZE);
|
||||
use constant INFO_BACKUP_KEY_BACKUP_SIZE_DELTA => 'backup-info-size-delta';
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_SIZE_DELTA);
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_BACKUP_SIZE_DELTA);
|
||||
use constant INFO_BACKUP_KEY_CATALOG => MANIFEST_KEY_CATALOG;
|
||||
push @EXPORT, qw(INFO_BACKUP_KEY_CATALOG);
|
||||
use constant INFO_BACKUP_KEY_CONTROL => MANIFEST_KEY_CONTROL;
|
||||
|
@ -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,
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
@ -76,7 +76,7 @@ use constant HOST_PROTOCOL_TIMEOUT => 10;
|
||||
####################################################################################################################################
|
||||
# Cached data sections
|
||||
####################################################################################################################################
|
||||
use constant SECTION_FILE_NAME => 'strFileName';
|
||||
use constant SECTION_FILE_NAME => 'strFileName';
|
||||
push @EXPORT, qw(SECTION_FILE_NAME);
|
||||
|
||||
####################################################################################################################################
|
||||
|
Reference in New Issue
Block a user