1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-15 01:04:37 +02:00

Closed #131: Offline backups make expire command fail.

This commit is contained in:
David Steele
2016-01-15 23:37:17 -05:00
parent fce7261536
commit 65cce69dcc
13 changed files with 125 additions and 1001 deletions

View File

@ -1550,16 +1550,20 @@ push @EXPORT, qw(BackRestTestBackup_Expire);
sub BackRestTestBackup_Expire
{
my $strStanza = shift;
my $strComment = shift;
my $oFile = shift;
my $stryBackupExpectedRef = shift;
my $stryArchiveExpectedRef = shift;
my $iExpireFull = shift;
my $iExpireDiff = shift;
my $strExpireArchiveType = shift;
my $iExpireArchive = shift;
$strComment = 'expire' .
(defined($iExpireFull) ? " full=$iExpireFull" : '') .
(defined($iExpireDiff) ? " diff=$iExpireDiff" : '') .
(defined($strComment) ? " (${strComment})" : '');
&log(INFO, " ${strComment}");
my $strCommand = BackRestTestCommon_CommandMainGet() . ' --config=' . BackRestTestCommon_DbPathGet() .
"/pg_backrest.conf --stanza=${strStanza} expire";
"/pg_backrest.conf --stanza=${strStanza} expire --log-level-console=info";
if (defined($iExpireFull))
{
@ -1571,37 +1575,8 @@ sub BackRestTestBackup_Expire
$strCommand .= ' --retention-diff=' . $iExpireDiff;
}
if (defined($strExpireArchiveType))
{
$strCommand .= ' --retention-archive-type=' . $strExpireArchiveType .
' --retention-archive=' . $iExpireArchive;
}
executeTest($strCommand);
# Check that the correct backups were expired
my @stryBackupActual = $oFile->list(PATH_BACKUP_CLUSTER);
if (join(",", @stryBackupActual) ne join(",", @{$stryBackupExpectedRef}))
{
confess "expected backup list:\n " . join("\n ", @{$stryBackupExpectedRef}) .
"\n\nbut actual was:\n " . join("\n ", @stryBackupActual) . "\n";
}
# Check that the correct archive logs were expired
my @stryArchiveActual = $oFile->list(PATH_BACKUP_ARCHIVE, BackRestTestCommon_DbVersion() . '-1/0000000100000000');
if (join(",", @stryArchiveActual) ne join(",", @{$stryArchiveExpectedRef}))
{
confess "expected archive list:\n " . join("\n ", @{$stryArchiveExpectedRef}) .
"\n\nbut actual was:\n " . join("\n ", @stryArchiveActual) . "\n";
}
if (defined($oBackupLogTest))
{
$oBackupLogTest->supplementalAdd(BackRestTestCommon_RepoPathGet() .
"/backup/${strStanza}/backup.info");
}
executeTest($strCommand, {oLogTest => $oBackupLogTest,
iExpectedExitStatus => $bBackupRemote ? ERROR_HOST_INVALID : undef});
}
1;