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

Fixed some issues with remote backups after restore (unit test bugs only).

This commit is contained in:
David Steele 2015-01-22 20:55:16 -05:00
parent 21c715b25c
commit a3b3f98f66
2 changed files with 32 additions and 8 deletions

View File

@ -790,6 +790,7 @@ sub BackRestTestBackup_Restore
my $oFile = shift;
my $strBackup = shift;
my $strStanza = shift;
my $bRemote = shift;
my $oExpectedManifestRef = shift;
my $oRemapHashRef = shift;
my $bDelta = shift;
@ -800,15 +801,15 @@ sub BackRestTestBackup_Restore
$bDelta = defined($bDelta) ? $bDelta : false;
$bForce = defined($bForce) ? $bForce : false;
if (defined($oRemapHashRef))
{
BackRestTestCommon_ConfigRemap($oRemapHashRef, $oExpectedManifestRef);
}
&log(INFO, ' ' . ($bDelta ? 'delta ' : '') . ($bForce ? 'force ' : '') .
(defined($oRemapHashRef) ? 'remap ' : '') . 'restore' .
(defined($strComment) ? " (${strComment})" : ''));
if (defined($oRemapHashRef))
{
BackRestTestCommon_ConfigRemap($oRemapHashRef, $oExpectedManifestRef, $bRemote);
}
# Create the backup command
BackRestTestCommon_Execute(BackRestTestCommon_CommandMainGet() . ' --config=' . BackRestTestCommon_DbPathGet() .
'/pg_backrest.conf' . (defined($bDelta) && $bDelta ? ' --delta' : '') .
@ -1249,7 +1250,7 @@ sub BackRestTestBackup_Test
# Remove a file
BackRestTestBackup_FileRemove(\%oManifest, 'base', 'PG_VERSION');
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, \%oManifest, undef, $bDelta, $bForce,
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, \%oManifest, undef, $bDelta, $bForce,
'add and delete files');
# Incr backup - add a tablespace
@ -1299,9 +1300,9 @@ sub BackRestTestBackup_Test
# Remap the base path
my %oRemapHash;
$oRemapHash{base} = BackRestTestCommon_DbCommonPathGet(2);
# $oRemapHash{1} = BackRestTestCommon_DbTablespacePathGet(1, 2);
$oRemapHash{1} = BackRestTestCommon_DbTablespacePathGet(1, 2);
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, \%oManifest, \%oRemapHash, $bDelta, $bForce,
BackRestTestBackup_Restore($oFile, $strFullBackup, $strStanza, $bRemote, \%oManifest, \%oRemapHash, $bDelta, $bForce,
'remap base path');
# Incr Backup

View File

@ -418,6 +418,7 @@ sub BackRestTestCommon_ConfigRemap
{
my $oRemapHashRef = shift;
my $oManifestRef = shift;
my $bRemote = shift;
# Create config filename
my $strConfigFile = BackRestTestCommon_DbPathGet() . '/pg_backrest.conf';
@ -427,6 +428,16 @@ sub BackRestTestCommon_ConfigRemap
my %oConfig;
ini_load($strConfigFile, \%oConfig);
# Load remote config file
my %oRemoteConfig;
my $strRemoteConfigFile = BackRestTestCommon_TestPathGet() . '/pg_backrest.conf.remote';
if ($bRemote)
{
BackRestTestCommon_Execute("mv " . BackRestTestCommon_BackupPathGet() . "/pg_backrest.conf ${strRemoteConfigFile}", true);
ini_load($strRemoteConfigFile, \%oRemoteConfig);
}
# Rewrite remap section
delete($oConfig{"${strStanza}:tablespace:map"});
@ -438,6 +449,11 @@ sub BackRestTestCommon_ConfigRemap
{
$oConfig{$strStanza}{path} = $strRemapPath;
${$oManifestRef}{'backup:path'}{base} = $strRemapPath;
if ($bRemote)
{
$oRemoteConfig{$strStanza}{path} = $strRemapPath;
}
}
else
{
@ -451,6 +467,13 @@ sub BackRestTestCommon_ConfigRemap
# Resave the config file
ini_save($strConfigFile, \%oConfig);
# Load remote config file
if ($bRemote)
{
ini_save($strRemoteConfigFile, \%oRemoteConfig);
BackRestTestCommon_Execute("mv ${strRemoteConfigFile} " . BackRestTestCommon_BackupPathGet() . '/pg_backrest.conf', true);
}
}
####################################################################################################################################