1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-01-18 04:58:51 +02:00

Closed #213: Archive command should not be validate when archive-check=n

This commit is contained in:
David Steele 2016-07-02 09:02:55 -04:00
parent 0f2eb424bb
commit 418039027b
7 changed files with 62 additions and 46 deletions

View File

@ -547,6 +547,18 @@
<example>main</example>
</option>
<!-- OPERATION - GENERAL - ONLINE OPTION -->
<option id="online" name="Online">
<summary>Perform an online backup.</summary>
<text>Specifying --no-online prevents <backrest/> from running <code>pg_start_backup()</code> and <code>pg_stop_backup()</code> on the database cluster. In order for this to work <postgres/> should be shut down and <backrest/> will generate an error if it is not.
The purpose of this option is to allow offline backups. The <path>pg_xlog</path> directory is copied as-is and <setting>archive-check</setting> is automatically disabled for the backup.</text>
<example>n</example>
</option>
</option-list>
</operation-general>
@ -572,17 +584,6 @@
<example>full</example>
</option>
<!-- OPERATION - BACKUP COMMAND - ONLINE OPTION -->
<option id="online" name="Online">
<summary>Perform an online backup.</summary>
<text>Specifying --no-online prevents <backrest/> from running <code>pg_start_backup()</code> and <code>pg_stop_backup()</code> on the database cluster. In order for this to work <postgres/> should be shut down and <backrest/> will generate an error if it is not.
The purpose of this option is to allow offline backups. The <path>pg_xlog</path> directory is copied as-is and <setting>archive-check</setting> is automatically disabled for the backup.</text>
<example>n</example>
</option>
<!-- OPERATION - BACKUP COMMAND - FORCE OPTION -->
<option id="force" name="Force">
<summary>Force an offline backup.</summary>

View File

@ -113,6 +113,10 @@
<p>Fixed an issue where the <cmd>expire</cmd> command would refuse to run when explicitly called from the command line if the <br-option>db-host</br-option> option was set. This was not an issue when <cmd>expire</cmd> was run after a <cmd>backup</cmd>, which is the usual case.</p>
</release-item>
<release-item>
<p>Fixed an issue where validation was being running on <pg-setting>archive_command</pg-setting> even when the <br-option>archive-check</br-option> option was disabled.</p>
</release-item>
</release-bug-list>
<release-feature-list>

View File

@ -605,12 +605,11 @@ my %oOptionRule =
{
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
&OPTION_RULE_NEGATE => true,
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_ONLINE,
&OPTION_RULE_COMMAND =>
{
&CMD_BACKUP =>
{
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_ONLINE
}
&CMD_BACKUP => true,
&CMD_CHECK => true,
}
},
@ -1258,17 +1257,16 @@ my %oOptionRule =
&OPTION_RULE_SECTION => CONFIG_SECTION_GLOBAL,
&OPTION_RULE_TYPE => OPTION_TYPE_BOOLEAN,
&OPTION_RULE_DEFAULT => OPTION_DEFAULT_BACKUP_ARCHIVE_CHECK,
&OPTION_RULE_DEPEND =>
{
&OPTION_RULE_DEPEND_OPTION => OPTION_ONLINE,
&OPTION_RULE_DEPEND_VALUE => true,
},
&OPTION_RULE_COMMAND =>
{
&CMD_BACKUP =>
{
&OPTION_RULE_DEPEND =>
{
&OPTION_RULE_DEPEND_OPTION => OPTION_ONLINE,
&OPTION_RULE_DEPEND_VALUE => true
}
}
}
&CMD_BACKUP => true,
&CMD_CHECK => true,
},
},
&OPTION_BACKUP_ARCHIVE_COPY =>

View File

@ -439,6 +439,21 @@ my $oConfigHelpData =
"the command line."
},
# ONLINE Option Help
#---------------------------------------------------------------------------------------------------------------------------
'online' =>
{
summary =>
"Perform an online backup.",
description =>
"Specifying --no-online prevents pgBackRest from running pg_start_backup() and pg_stop_backup() on the database " .
"cluster. In order for this to work PostgreSQL should be shut down and pgBackRest will generate an error if " .
"it is not.\n" .
"\n" .
"The purpose of this option is to allow offline backups. The pg_xlog directory is copied as-is and " .
"archive-check is automatically disabled for the backup."
},
# PROTOCOL-TIMEOUT Option Help
#---------------------------------------------------------------------------------------------------------------------------
'protocol-timeout' =>
@ -800,22 +815,7 @@ my $oConfigHelpData =
'log-path' => 'section',
'manifest-save-threshold' => 'section',
'neutral-umask' => 'section',
# ONLINE Option Help
#-------------------------------------------------------------------------------------------------------------------
'online' =>
{
summary =>
"Perform an online backup.",
description =>
"Specifying --no-online prevents pgBackRest from running pg_start_backup() and pg_stop_backup() on the " .
"database cluster. In order for this to work PostgreSQL should be shut down and pgBackRest will " .
"generate an error if it is not.\n" .
"\n" .
"The purpose of this option is to allow offline backups. The pg_xlog directory is copied as-is and " .
"archive-check is automatically disabled for the backup."
},
'online' => 'default',
'protocol-timeout' => 'section',
'repo-path' => 'section',
'resume' => 'section',
@ -864,6 +864,7 @@ my $oConfigHelpData =
option =>
{
'archive-check' => 'section',
'archive-timeout' => 'section',
'backup-host' => 'section',
'backup-user' => 'section',
@ -883,6 +884,7 @@ my $oConfigHelpData =
'log-level-file' => 'section',
'log-path' => 'section',
'neutral-umask' => 'section',
'online' => 'default',
'protocol-timeout' => 'section',
'repo-path' => 'section',
'stanza' => 'default'

View File

@ -772,17 +772,21 @@ sub configValidate
}
# Error if archive_mode = always (support has not been added yet)
if ($self->executeSql('show archive_mode') eq 'always')
if (optionGet(OPTION_BACKUP_ARCHIVE_CHECK) && $self->executeSql('show archive_mode') eq 'always')
{
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)
if (optionGet(OPTION_BACKUP_ARCHIVE_CHECK))
{
confess &log(ERROR, 'archive_command must contain \'' . BACKREST_EXE . '\'', ERROR_ARCHIVE_COMMAND_INVALID);
my $strArchiveCommand = $self->executeSql('show archive_command');
if (index($strArchiveCommand, BACKREST_EXE) == -1)
{
confess &log(ERROR,
'archive_command \'${strArchiveCommand}\' must contain \'' . BACKREST_EXE . '\'', ERROR_ARCHIVE_COMMAND_INVALID);
}
}
return logDebugReturn

View File

@ -1604,7 +1604,7 @@ sub backupTestRun
# Stop the cluster ignoring any errors in the postgresql log
$oHostDbMaster->clusterStop({bIgnoreLogError => true});
# Check archive_command_not_set error
# Check ERROR_ARCHIVE_COMMAND_INVALID error
$strComment = 'fail on invalid archive_command';
$oHostDbMaster->clusterStart({bArchive => false});
@ -1618,6 +1618,12 @@ sub backupTestRun
$oHostBackup->check($strComment, {iTimeout => 0.1, iExpectedExitStatus => ERROR_ARCHIVE_COMMAND_INVALID});
}
# When archive-check=n then ERROR_FILE_MISSING will be raised instead of ERROR_ARCHIVE_COMMAND_INVALID
$strComment = 'fail on file missing when archive-check=n';
$oHostDbMaster->check(
$strComment,
{iTimeout => 0.1, iExpectedExitStatus => ERROR_FILE_MISSING, strOptionalParam => '--no-archive-check'});
# Stop the cluster ignoring any errors in the postgresql log
$oHostDbMaster->clusterStop({bIgnoreLogError => true});

View File

@ -511,6 +511,7 @@ sub check
' --config=' . $self->backrestConfig() .
' --log-level-console=detail' .
(defined($$oParam{iTimeout}) ? " --archive-timeout=$$oParam{iTimeout}" : '') .
(defined($$oParam{strOptionalParam}) ? " $$oParam{strOptionalParam}" : '') .
' --stanza=' . $self->stanza() . ' check',
{strComment => $strComment, iExpectedExitStatus => $$oParam{iExpectedExitStatus}, oLogTest => $self->{oLogTest}});