1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2024-12-14 10:13:05 +02:00

Generate an error when archive-check=y but archive_command does not execute pg_backrest.

This commit is contained in:
Jason O'Donnell 2016-01-11 09:50:45 -05:00 committed by David Steele
parent 81a2fde21f
commit c7502f341b
6 changed files with 53 additions and 23 deletions

View File

@ -5,6 +5,8 @@ __No Release Date Set__
* Fixed an issue where specifying `--no-archive-check` would throw a configuration error. _Reported by Jason O'Donnell_.
* Generate an error when `archive-check=y` but `archive_command` does not execute `pg_backrest`. _Contributed by Jason O'Donnell_
* Provisional support for PostgreSQL 9.5 including partial WAL segments. The `archive_mode = 'always'` setting is not yet supported.
## v0.89: Timeout Bug Fix and Restore Read-Only Repositories

View File

@ -11,6 +11,9 @@
<release-feature>
<text>Fixed an issue where specifying <setting>--no-archive-check</setting> would throw a configuration error. <i>Reported by Jason O'Donnell</i>.</text>
</release-feature>
<release-feature>
<text>Generate an error when <setting>archive-check=y</setting> but <setting>archive_command</setting> does not execute <file>pg_backrest</file>. <i>Contributed by Jason O'Donnell</i></text>
</release-feature>
<release-feature>
<text>Provisional support for <postgres/> 9.5 including partial WAL segments. The <setting>archive_mode = 'always'</setting> setting is not yet supported.</text>
</release-feature>

View File

@ -104,6 +104,8 @@ use constant ERROR_PROTOCOL_TIMEOUT => ERROR_MIN
push @EXPORT, qw(ERROR_PROTOCOL_TIMEOUT);
use constant ERROR_FEATURE_NOT_SUPPORTED => ERROR_MINIMUM + 42;
push @EXPORT, qw(ERROR_FEATURE_NOT_SUPPORTED);
use constant ERROR_ARCHIVE_COMMAND_INVALID => ERROR_MINIMUM + 43;
push @EXPORT, qw(ERROR_ARCHIVE_COMMAND_INVALID);
use constant ERROR_INVALID_VALUE => ERROR_MAXIMUM - 1;
push @EXPORT, qw(ERROR_INVALID_VALUE);

View File

@ -619,6 +619,14 @@ sub backupStart
confess &log(ERROR, "archive_mode=always not supported", ERROR_FEATURE_NOT_SUPPORTED);
}
# Check if archive_command is set
my $strArchiveCommand = $self->executeSql('show archive_command');
if (index($strArchiveCommand, BACKREST_EXE) == -1)
{
confess &log(ERROR, "archive_command must be set", ERROR_ARCHIVE_COMMAND_INVALID);
}
# Acquire the backup advisory lock to make sure that backups are not running from multiple backup servers against the same
# database cluster. This lock helps make the stop-auto option safe.
if (!$self->executeSqlOne('select pg_try_advisory_lock(' . DB_BACKUP_ADVISORY_LOCK . ')'))

View File

@ -309,35 +309,35 @@ sub BackRestTestBackup_ClusterStart
my $strCommand = BackRestTestCommon_PgSqlBinPathGet() . "/pg_ctl start -o \"-c port=${iPort}" .
(BackRestTestCommon_DbVersion() < 9.5 ? ' -c checkpoint_segments=1' : '');
if (BackRestTestCommon_DbVersion() >= '8.3')
{
if (BackRestTestCommon_DbVersion() >= '9.5' && $bArchiveAlways)
{
$strCommand .= " -c archive_mode=always";
}
else
{
$strCommand .= " -c archive_mode=on";
}
}
if ($bArchive)
{
if (BackRestTestCommon_DbVersion() >= '8.3')
{
if (BackRestTestCommon_DbVersion() >= '9.5' && $bArchiveAlways)
{
$strCommand .= " -c archive_mode=always";
}
else
{
$strCommand .= " -c archive_mode=on";
}
}
$strCommand .= " -c archive_command='${strArchive}'";
if (BackRestTestCommon_DbVersion() >= '9.0')
{
$strCommand .= " -c wal_level=hot_standby";
if ($bHotStandby)
{
$strCommand .= ' -c hot_standby=on';
}
}
}
else
{
$strCommand .= " -c archive_mode=on -c wal_level=archive -c archive_command=true";
$strCommand .= " -c archive_command=true";
}
if (BackRestTestCommon_DbVersion() >= '9.0')
{
$strCommand .= " -c wal_level=hot_standby";
if ($bHotStandby)
{
$strCommand .= ' -c hot_standby=on';
}
}
$strCommand .= " -c log_error_verbosity=verbose" .

View File

@ -1399,6 +1399,21 @@ sub BackRestTestBackup_Test
my $strNameMessage = 'name';
my $strTimelineMessage = 'timeline3';
# Test invalid archive command
#-----------------------------------------------------------------------------------------------------------------------
$strType = BACKUP_TYPE_FULL;
$strComment = 'archive_command invalid';
# Check archive_command_not_set error
BackRestTestBackup_ClusterStop();
BackRestTestBackup_ClusterStart(undef, undef, undef, false);
BackRestTestBackup_Backup($strType, $strStanza, $strComment, {iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
# Reset the cluster to a normal state so the next test will work
BackRestTestBackup_ClusterStop();
BackRestTestBackup_ClusterStart();
# Full backup
#-----------------------------------------------------------------------------------------------------------------------
$strType = BACKUP_TYPE_FULL;