mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-03-29 21:47:21 +02:00
Fix incorrect time expiration being used for non-default repositories.
If a repo is not specified for the expire command then the lowest repo becomes the default. The repo-retention-full value for time was being retrieved from the default rather than a specific repo which led to an incorrect expiration being applied. Get the value from the specific repo and add a test. It would be better if the default repo could not be queried in this case but it is not clear how to do that since the repo option is valid for expire (unlike, e.g., archive-push).
This commit is contained in:
parent
f1cb848591
commit
eda7f81ee4
@ -16,6 +16,21 @@
|
||||
<release-list>
|
||||
<release date="XXXX-XX-XX" version="2.41dev" title="UNDER DEVELOPMENT">
|
||||
<release-core-list>
|
||||
<release-bug-list>
|
||||
<release-item>
|
||||
<github-issue id="1852"/>
|
||||
<github-pull-request id="1854"/>
|
||||
|
||||
<release-item-contributor-list>
|
||||
<release-item-ideator id="adam.brusselback"/>
|
||||
<release-item-contributor id="david.steele"/>
|
||||
<release-item-reviewer id="stefan.fercot"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Fix incorrect time expiration being used for non-default repos.</p>
|
||||
</release-item>
|
||||
</release-bug-list>
|
||||
|
||||
<release-feature-list>
|
||||
<release-item>
|
||||
<github-issue id="1709"/>
|
||||
|
@ -1044,7 +1044,8 @@ cmdExpire(void)
|
||||
if (cfgOptionIdxTest(cfgOptRepoRetentionFull, repoIdx))
|
||||
{
|
||||
expireTimeBasedBackup(
|
||||
infoBackup, time(NULL) - (time_t)(cfgOptionUInt(cfgOptRepoRetentionFull) * SEC_PER_DAY), repoIdx);
|
||||
infoBackup, time(NULL) - (time_t)(cfgOptionIdxUInt(cfgOptRepoRetentionFull, repoIdx) * SEC_PER_DAY),
|
||||
repoIdx);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -2474,6 +2474,50 @@ testRun(void)
|
||||
"P00 DETAIL: repo1: 9.4-1 archive retention on backup 20181119-152900F, start = 000000010000000000000009\n"
|
||||
"P00 INFO: repo1: 9.4-1 remove archive, start = 000000010000000000000004, stop = 000000010000000000000008");
|
||||
|
||||
//--------------------------------------------------------------------------------------------------------------------------
|
||||
TEST_TITLE("add repo2 to ensure options are applied correctly");
|
||||
|
||||
argList = strLstDup(argListTime);
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 1, "1");
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptRepoPath, 2, TEST_PATH "/repo2");
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFullType, 2, "time");
|
||||
hrnCfgArgKeyRawZ(argList, cfgOptRepoRetentionFull, 2, "30");
|
||||
HRN_CFG_LOAD(cfgCmdExpire, argList);
|
||||
|
||||
// Create backup.info and archive.info for repo2
|
||||
HRN_INFO_PUT(storageRepoIdxWrite(1), INFO_BACKUP_PATH_FILE, strZ(backupInfoContent));
|
||||
HRN_INFO_PUT(
|
||||
storageRepoIdxWrite(1), INFO_ARCHIVE_PATH_FILE,
|
||||
"[db]\n"
|
||||
"db-id=1\n"
|
||||
"db-system-id=6625592122879095702\n"
|
||||
"db-version=\"9.4\"\n"
|
||||
"\n"
|
||||
"[db:history]\n"
|
||||
"1={\"db-id\":6625592122879095702,\"db-version\":\"9.4\"}");
|
||||
|
||||
// Write backup.manifest for repo2 so infoBackup reconstruct produces same results as backup.info on disk
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoIdxWrite(1), STORAGE_REPO_BACKUP "/20181119-152138F/" BACKUP_MANIFEST_FILE);
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoIdxWrite(1), STORAGE_REPO_BACKUP "/20181119-152800F/" BACKUP_MANIFEST_FILE);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoIdxWrite(1), STORAGE_REPO_BACKUP "/20181119-152800F_20181119-152152D/" BACKUP_MANIFEST_FILE);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoIdxWrite(1), STORAGE_REPO_BACKUP "/20181119-152800F_20181119-152155I/" BACKUP_MANIFEST_FILE);
|
||||
HRN_STORAGE_PUT_EMPTY(storageRepoIdxWrite(1), STORAGE_REPO_BACKUP "/20181119-152900F/" BACKUP_MANIFEST_FILE);
|
||||
HRN_STORAGE_PUT_EMPTY(
|
||||
storageRepoIdxWrite(1), STORAGE_REPO_BACKUP "/20181119-152900F_20181119-152600D/" BACKUP_MANIFEST_FILE);
|
||||
|
||||
// Generate archive for backups in backup.info in repo2
|
||||
archiveGenerate(storageRepoIdxWrite(1), STORAGE_REPO_ARCHIVE, 1, 11, "9.4-1", "0000000100000000");
|
||||
|
||||
TEST_RESULT_VOID(cmdExpire(), "expire all but newest");
|
||||
TEST_RESULT_LOG(
|
||||
"P00 INFO: repo1: time-based archive retention not met - archive logs will not be expired\n"
|
||||
"P00 INFO: repo2: expire time-based backup 20181119-152138F\n"
|
||||
"P00 INFO: repo2: remove expired backup 20181119-152138F\n"
|
||||
"P00 DETAIL: repo2: 9.4-1 archive retention on backup 20181119-152800F, start = 000000010000000000000004\n"
|
||||
"P00 INFO: repo2: 9.4-1 remove archive, start = 000000010000000000000001, stop = 000000010000000000000003");
|
||||
|
||||
harnessLogLevelReset();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user