You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2026-05-22 10:15:16 +02:00
Restore errors when no backup matches the current version of PostgreSQL.
It is probably not a good idea to restore the latest backup when it was not made from the current PostgreSQL version. If there is no backup after a stanza-upgrade then replicas might be built with a prior version leading to failures. Add an error in this case if the latest backup would be used, i.e. --set or --type=time/lsn is not specified.
This commit is contained in:
@@ -28,6 +28,19 @@
|
||||
<p>Remove support for <proper>PostgreSQL</proper> <id>9.0</id>/<id>9.1</id>/<id>9.2</id>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<github-issue id="1942"/>
|
||||
<github-pull-request id="1967"/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="soulou"/>
|
||||
<release-item-contributor id="stefan.fercot"/>
|
||||
<release-item-reviewer id="david.steele"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Restore errors when no backup matches the current version of <postgres/>.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
<github-issue id="1216"/>
|
||||
<github-issue id="1931"/>
|
||||
|
||||
@@ -340,6 +340,19 @@ restoreBackupSet(void)
|
||||
// Else use backup set found
|
||||
else
|
||||
{
|
||||
// Is this backup part of the latest pg history?
|
||||
InfoPgData backupInfoPg = infoPgData(infoBackupPg(infoBackup), infoPgDataCurrentId(infoBackupPg(infoBackup)));
|
||||
|
||||
if (latestBackup.backupPgId < backupInfoPg.id)
|
||||
{
|
||||
THROW_FMT(BackupSetInvalidError,
|
||||
"the latest backup set found '%s' is from a prior version of " PG_NAME "\n"
|
||||
"HINT: was a backup created after the stanza-upgrade?\n"
|
||||
"HINT: specify --" CFGOPT_SET " or --" CFGOPT_TYPE "=time/lsn to restore from a prior version of "
|
||||
PG_NAME ".",
|
||||
strZ(latestBackup.backupLabel));
|
||||
}
|
||||
|
||||
result = restoreBackupData(latestBackup.backupLabel, repoIdx, infoPgCipherPass(infoBackupPg(infoBackup)));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -342,6 +342,38 @@ testRun(void)
|
||||
|
||||
TEST_ERROR(restoreBackupSet(), BackupSetInvalidError, "backup set BOGUS is not valid");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("Fail restore when no backup found in the latest db history");
|
||||
|
||||
HRN_INFO_PUT(
|
||||
storageRepoWrite(), INFO_BACKUP_PATH_FILE,
|
||||
TEST_RESTORE_BACKUP_INFO
|
||||
"\n"
|
||||
"[db]\n"
|
||||
"db-catalog-version=201707211\n"
|
||||
"db-control-version=1002\n"
|
||||
"db-id=2\n"
|
||||
"db-system-id=6626363367545678089\n"
|
||||
"db-version=\"10\"\n"
|
||||
"\n"
|
||||
"[db:history]\n"
|
||||
"1={\"db-catalog-version\":201409291,\"db-control-version\":942,\"db-system-id\":6569239123849665679,"
|
||||
"\"db-version\":\"9.4\"}\n"
|
||||
"2={\"db-catalog-version\":201707211,\"db-control-version\":1002,\"db-system-id\":6626363367545678089,"
|
||||
"\"db-version\":\"10\"}\n");
|
||||
|
||||
argList = strLstNew();
|
||||
hrnCfgArgRawZ(argList, cfgOptStanza, "test1");
|
||||
hrnCfgArgRaw(argList, cfgOptRepoPath, repoPath);
|
||||
hrnCfgArgRaw(argList, cfgOptPgPath, pgPath);
|
||||
HRN_CFG_LOAD(cfgCmdRestore, argList);
|
||||
|
||||
TEST_ERROR(
|
||||
restoreBackupSet(), BackupSetInvalidError,
|
||||
"the latest backup set found '20161219-212741F_20161219-212918I' is from a prior version of PostgreSQL\n"
|
||||
"HINT: was a backup created after the stanza-upgrade?\n"
|
||||
"HINT: specify --set or --type=time/lsn to restore from a prior version of PostgreSQL.");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("target time");
|
||||
setenv("TZ", "UTC", true);
|
||||
|
||||
Reference in New Issue
Block a user