1
0
mirror of https://github.com/pgbackrest/pgbackrest.git synced 2025-07-05 00:28:52 +02:00

Strip extensions from history manifest before showing in error message.

In cases where clock skew or timezone issues are preventing backup label generation the user could see an error like this:

new backup label '20220504-152308F' is not later than latest backup label '20220504-222042F_20220504-222141I.manifest.gz'

This will happen if the most recent label is drawn from the history. It is cleaner (and probably less confusing) to strip off the extensions so the user sees:

new backup label '20220504-152308F' is not later than latest backup label '20220504-222042F_20220504-222141I'
This commit is contained in:
David Steele
2022-05-05 09:20:49 -04:00
committed by GitHub
parent ef672c74ad
commit b6bfd9f99d
4 changed files with 33 additions and 3 deletions

View File

@ -184,6 +184,17 @@
<p>Add hint to check the log on <cmd>archive-get</cmd>/<cmd>archive-push</cmd> async error.</p> <p>Add hint to check the log on <cmd>archive-get</cmd>/<cmd>archive-push</cmd> async error.</p>
</release-item> </release-item>
<release-item>
<github-pull-request id="1738"/>
<release-item-contributor-list>
<release-item-contributor id="david.steele"/>
<release-item-reviewer id="stefan.fercot"/>
</release-item-contributor-list>
<p>Strip extensions from history manifest before showing in error message.</p>
</release-item>
<release-item> <release-item>
<github-issue id="1722"/> <github-issue id="1722"/>

View File

@ -88,10 +88,14 @@ backupLabelCreate(BackupType type, const String *backupLabelPrior, time_t timest
if (!strLstEmpty(historyList)) if (!strLstEmpty(historyList))
{ {
const String *historyLabelLatest = strLstGet(historyList, 0); const String *const historyLabelLatest = strLstGet(historyList, 0);
if (backupLabelLatest == NULL || strCmp(historyLabelLatest, backupLabelLatest) > 0) if (backupLabelLatest == NULL || strCmp(historyLabelLatest, backupLabelLatest) > 0)
backupLabelLatest = historyLabelLatest; {
// Strip off the compression and manifest extensions in case this ends up in an error message
backupLabelLatest = compressExtStrip(historyLabelLatest, compressTypeFromName(historyLabelLatest));
backupLabelLatest = strSubN(backupLabelLatest, 0, strSize(backupLabelLatest) - sizeof(BACKUP_MANIFEST_EXT) + 1);
}
} }
} }

View File

@ -13,7 +13,8 @@ nothing is missing or corrupt. It is also useful for reporting, e.g. size of ba
/*********************************************************************************************************************************** /***********************************************************************************************************************************
Constants Constants
***********************************************************************************************************************************/ ***********************************************************************************************************************************/
#define BACKUP_MANIFEST_FILE "backup.manifest" #define BACKUP_MANIFEST_EXT ".manifest"
#define BACKUP_MANIFEST_FILE "backup" BACKUP_MANIFEST_EXT
STRING_DECLARE(BACKUP_MANIFEST_FILE_STR); STRING_DECLARE(BACKUP_MANIFEST_FILE_STR);
#define MANIFEST_PATH_BUNDLE "bundle" #define MANIFEST_PATH_BUNDLE "bundle"

View File

@ -1462,6 +1462,20 @@ testRun(void)
"new backup label '20191203-193413F' is not later than latest backup label '20191203-193413F'\n" "new backup label '20191203-193413F' is not later than latest backup label '20191203-193413F'\n"
"HINT: has the timezone changed?\n" "HINT: has the timezone changed?\n"
"HINT: is there clock skew?"); "HINT: is there clock skew?");
// -------------------------------------------------------------------------------------------------------------------------
TEST_TITLE("error when new label is in the past even with advanced time (from history)");
HRN_STORAGE_PUT_EMPTY(
storageRepoWrite(), strZ(
strNewFmt(STORAGE_REPO_BACKUP "/backup.history/2019/%s.manifest.gz",
strZ(backupLabelFormat(backupTypeFull, NULL, timestamp + 3600)))));
TEST_ERROR(
backupLabelCreate(backupTypeFull, NULL, timestamp), FormatError,
"new backup label '20191203-193413F' is not later than latest backup label '20191203-203412F'\n"
"HINT: has the timezone changed?\n"
"HINT: is there clock skew?");
} }
// ***************************************************************************************************************************** // *****************************************************************************************************************************