mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-12 10:04:14 +02:00
Add Strings for STORAGE_REPO_ARCHIVE and STORAGE_REPO_BACKUP.
These constants are used often enough that they deserve to have String constants rather than repeatedly calling STRDEF().
This commit is contained in:
parent
10c8eeaf6c
commit
a44c5d0315
@ -167,7 +167,7 @@ archiveGetFile(
|
||||
// Copy the file
|
||||
storageCopyNP(
|
||||
storageNewReadP(
|
||||
storageRepo(), strNewFmt("%s/%s", STORAGE_REPO_ARCHIVE, strPtr(archiveGetCheckResult.archiveFileActual)),
|
||||
storageRepo(), strNewFmt(STORAGE_REPO_ARCHIVE "/%s", strPtr(archiveGetCheckResult.archiveFileActual)),
|
||||
.compressible = compressible),
|
||||
destination);
|
||||
|
||||
|
@ -274,8 +274,7 @@ removeExpiredArchive(InfoBackup *infoBackup)
|
||||
// Get a list of archive directories (e.g. 9.4-1, 10-2, etc) sorted by the db-id (number after the dash).
|
||||
StringList *listArchiveDisk = strLstSort(
|
||||
strLstComparatorSet(
|
||||
storageListP(
|
||||
storageRepo(), STRDEF(STORAGE_REPO_ARCHIVE), .expression = STRDEF(REGEX_ARCHIVE_DIR_DB_VERSION)),
|
||||
storageListP(storageRepo(), STORAGE_REPO_ARCHIVE_STR, .expression = STRDEF(REGEX_ARCHIVE_DIR_DB_VERSION)),
|
||||
archiveIdComparator),
|
||||
sortOrderAsc);
|
||||
|
||||
@ -598,8 +597,8 @@ removeExpiredBackup(InfoBackup *infoBackup)
|
||||
StringList *currentBackupList = strLstSort(infoBackupDataLabelList(infoBackup, NULL), sortOrderDesc);
|
||||
StringList *backupList = strLstSort(
|
||||
storageListP(
|
||||
storageRepo(), STRDEF(STORAGE_REPO_BACKUP), .expression = backupRegExpP(.full = true, .differential = true,
|
||||
.incremental = true)),
|
||||
storageRepo(), STORAGE_REPO_BACKUP_STR,
|
||||
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)),
|
||||
sortOrderDesc);
|
||||
|
||||
// Remove non-current backups from disk
|
||||
|
@ -57,10 +57,8 @@ cmdStanzaCreate(void)
|
||||
// then create the stanza
|
||||
if (!archiveInfoFileExists && !archiveInfoFileCopyExists && !backupInfoFileExists && !backupInfoFileCopyExists)
|
||||
{
|
||||
bool archiveNotEmpty = strLstSize(
|
||||
storageListNP(storageRepoReadStanza, STRDEF(STORAGE_REPO_ARCHIVE))) > 0 ? true : false;
|
||||
bool backupNotEmpty = strLstSize(
|
||||
storageListNP(storageRepoReadStanza, STRDEF(STORAGE_REPO_BACKUP))) > 0 ? true : false;
|
||||
bool archiveNotEmpty = strLstSize(storageListNP(storageRepoReadStanza, STORAGE_REPO_ARCHIVE_STR)) > 0 ? true : false;
|
||||
bool backupNotEmpty = strLstSize(storageListNP(storageRepoReadStanza, STORAGE_REPO_BACKUP_STR)) > 0 ? true : false;
|
||||
|
||||
// If something else exists in the backup or archive directories for this stanza, then error
|
||||
if (archiveNotEmpty || backupNotEmpty)
|
||||
|
@ -31,8 +31,10 @@ manifestDelete(const Storage *storageRepoWriteStanza)
|
||||
// Get the list of backup directories from newest to oldest since don't want to invalidate a backup before
|
||||
// invalidating any backups that depend on it.
|
||||
StringList *backupList = strLstSort(
|
||||
storageListP(storageRepo(), STRDEF(STORAGE_REPO_BACKUP), .expression = backupRegExpP(.full = true,
|
||||
.differential = true, .incremental = true)), sortOrderDesc);
|
||||
storageListP(
|
||||
storageRepo(), STORAGE_REPO_BACKUP_STR,
|
||||
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)),
|
||||
sortOrderDesc);
|
||||
|
||||
// Delete all manifest files
|
||||
for (unsigned int idx = 0; idx < strLstSize(backupList); idx++)
|
||||
@ -108,10 +110,10 @@ stanzaDelete(const Storage *storageRepoWriteStanza, const StringList *archiveLis
|
||||
|
||||
// Recursively remove the entire stanza repo if exists. S3 will attempt to remove even if not.
|
||||
if (archiveList != NULL)
|
||||
storagePathRemoveP(storageRepoWriteStanza, STRDEF(STORAGE_REPO_ARCHIVE), .recurse = true);
|
||||
storagePathRemoveP(storageRepoWriteStanza, STORAGE_REPO_ARCHIVE_STR, .recurse = true);
|
||||
|
||||
if (backupList != NULL)
|
||||
storagePathRemoveP(storageRepoWriteStanza, STRDEF(STORAGE_REPO_BACKUP), .recurse = true);
|
||||
storagePathRemoveP(storageRepoWriteStanza, STORAGE_REPO_BACKUP_STR, .recurse = true);
|
||||
|
||||
// Remove the stop file - this will not error if the stop file does not exist. If the stanza directories existed but nothing
|
||||
// was in them, then no pgbackrest commands can be in progress without the info files so a stop is technically not necessary
|
||||
@ -141,9 +143,8 @@ cmdStanzaDelete(void)
|
||||
const Storage *storageRepoReadStanza = storageRepo();
|
||||
|
||||
stanzaDelete(
|
||||
storageRepoWrite(),
|
||||
storageListP(storageRepoReadStanza, STRDEF(STORAGE_REPO_ARCHIVE), .nullOnMissing = true),
|
||||
storageListP(storageRepoReadStanza, STRDEF(STORAGE_REPO_BACKUP), .nullOnMissing = true));
|
||||
storageRepoWrite(), storageListP(storageRepoReadStanza, STORAGE_REPO_ARCHIVE_STR, .nullOnMissing = true),
|
||||
storageListP(storageRepoReadStanza, STORAGE_REPO_BACKUP_STR, .nullOnMissing = true));
|
||||
}
|
||||
MEM_CONTEXT_TEMP_END();
|
||||
|
||||
|
@ -634,8 +634,8 @@ infoBackupLoadFileReconstruct(const Storage *storage, const String *fileName, Ci
|
||||
// Get a list of backups in the repo
|
||||
StringList *backupList = strLstSort(
|
||||
storageListP(
|
||||
storage, STRDEF(STORAGE_REPO_BACKUP), .expression = backupRegExpP(.full = true, .differential = true,
|
||||
.incremental = true)),
|
||||
storage, STORAGE_REPO_BACKUP_STR,
|
||||
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)),
|
||||
sortOrderAsc);
|
||||
|
||||
// Get the current list of backups from backup.info
|
||||
|
@ -23,6 +23,9 @@ Storage path constants
|
||||
STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_IN_STR, STORAGE_SPOOL_ARCHIVE_IN);
|
||||
STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_OUT_STR, STORAGE_SPOOL_ARCHIVE_OUT);
|
||||
|
||||
STRING_EXTERN(STORAGE_REPO_ARCHIVE_STR, STORAGE_REPO_ARCHIVE);
|
||||
STRING_EXTERN(STORAGE_REPO_BACKUP_STR, STORAGE_REPO_BACKUP);
|
||||
|
||||
STRING_EXTERN(STORAGE_PATH_ARCHIVE_STR, STORAGE_PATH_ARCHIVE);
|
||||
STRING_EXTERN(STORAGE_PATH_BACKUP_STR, STORAGE_PATH_BACKUP);
|
||||
|
||||
@ -278,7 +281,7 @@ storageRepoPathExpression(const String *expression, const String *path)
|
||||
|
||||
String *result = NULL;
|
||||
|
||||
if (strEqZ(expression, STORAGE_REPO_ARCHIVE))
|
||||
if (strEq(expression, STORAGE_REPO_ARCHIVE_STR))
|
||||
{
|
||||
// Construct the base path
|
||||
if (storageHelper.stanza != NULL)
|
||||
@ -298,7 +301,7 @@ storageRepoPathExpression(const String *expression, const String *path)
|
||||
strCatFmt(result, "/%s", strPtr(path));
|
||||
}
|
||||
}
|
||||
else if (strEqZ(expression, STORAGE_REPO_BACKUP))
|
||||
else if (strEq(expression, STORAGE_REPO_BACKUP_STR))
|
||||
{
|
||||
// Construct the base path
|
||||
if (storageHelper.stanza != NULL)
|
||||
|
@ -15,7 +15,9 @@ Storage path constants
|
||||
STRING_DECLARE(STORAGE_SPOOL_ARCHIVE_OUT_STR);
|
||||
|
||||
#define STORAGE_REPO_ARCHIVE "<REPO:ARCHIVE>"
|
||||
STRING_DECLARE(STORAGE_REPO_ARCHIVE_STR);
|
||||
#define STORAGE_REPO_BACKUP "<REPO:BACKUP>"
|
||||
STRING_DECLARE(STORAGE_REPO_BACKUP_STR);
|
||||
|
||||
#define STORAGE_PATH_ARCHIVE "archive"
|
||||
STRING_DECLARE(STORAGE_PATH_ARCHIVE_STR);
|
||||
|
@ -669,7 +669,7 @@ testRun(void)
|
||||
"create backup on disk that is in current but no manifest");
|
||||
|
||||
TEST_RESULT_STR(
|
||||
strPtr(strLstJoin(strLstSort(storageListP(storageRepo(), STRDEF(STORAGE_REPO_BACKUP),
|
||||
strPtr(strLstJoin(strLstSort(storageListP(storageRepo(), STORAGE_REPO_BACKUP_STR,
|
||||
.expression = backupRegExpP(.full = true, .differential = true, .incremental = true)), sortOrderAsc), ", ")),
|
||||
"20190818-084444F, 20190818-084502F, 20190818-084555F, 20190818-084666F, 20190818-084777F, 20190923-164324F",
|
||||
"confirm backups on disk");
|
||||
|
@ -1079,7 +1079,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR(strPtr(storagePathNP(storage, NULL)), testPath(), "check base path");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE))), strPtr(strNewFmt("%s/archive/db", testPath())),
|
||||
strPtr(storagePathNP(storage, STORAGE_REPO_ARCHIVE_STR)), strPtr(strNewFmt("%s/archive/db", testPath())),
|
||||
"check archive path");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple"))),
|
||||
@ -1095,7 +1095,7 @@ testRun(void)
|
||||
strPtr(strNewFmt("%s/archive/db/9.4-1/000000010000014C/000000010000014C0000001A.00000028.backup", testPath())),
|
||||
"check archive backup path");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP))), strPtr(strNewFmt("%s/backup/db", testPath())),
|
||||
strPtr(storagePathNP(storage, STORAGE_REPO_BACKUP_STR)), strPtr(strNewFmt("%s/backup/db", testPath())),
|
||||
"check backup path");
|
||||
|
||||
// Change the stanza to NULL with the stanzaInit flag still true, make sure helper does not fail when stanza option not set
|
||||
@ -1108,13 +1108,13 @@ testRun(void)
|
||||
TEST_RESULT_PTR(storageHelper.stanza, NULL, "stanza NULL");
|
||||
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE))), strPtr(strNewFmt("%s/archive", testPath())),
|
||||
strPtr(storagePathNP(storage, STORAGE_REPO_ARCHIVE_STR)), strPtr(strNewFmt("%s/archive", testPath())),
|
||||
"check archive path - NULL stanza");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE "/simple"))),
|
||||
strPtr(strNewFmt("%s/archive/simple", testPath())), "check simple archive path - NULL stanza");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP))), strPtr(strNewFmt("%s/backup", testPath())),
|
||||
strPtr(storagePathNP(storage, STORAGE_REPO_BACKUP_STR)), strPtr(strNewFmt("%s/backup", testPath())),
|
||||
"check backup path - NULL stanza");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP "/simple"))),
|
||||
|
Loading…
Reference in New Issue
Block a user