mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2024-12-14 10:13:05 +02:00
Add path expression for repository backup to the storage helper.
This is the counterpart to the archive path expression and constructs paths into the backup part of the repository. Contributed by Cynthia Shang.
This commit is contained in:
parent
4f539db8d9
commit
e3435ec386
@ -104,7 +104,7 @@
|
||||
<release-item-contributor id="cynthia.shang"/>
|
||||
</release-item-contributor-list>
|
||||
|
||||
<p>Allow <code>NULL</code> stanza in storage helper.</p>
|
||||
<p>Storage helper improvements. Allow <code>NULL</code> stanza in storage helper. Add path expression for repository backup.</p>
|
||||
</release-item>
|
||||
|
||||
<release-item>
|
||||
|
@ -18,6 +18,7 @@ STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_IN_STR, STORAGE_SPOO
|
||||
STRING_EXTERN(STORAGE_SPOOL_ARCHIVE_OUT_STR, STORAGE_SPOOL_ARCHIVE_OUT);
|
||||
|
||||
#define STORAGE_PATH_ARCHIVE "archive"
|
||||
#define STORAGE_PATH_BACKUP "backup"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Local variables
|
||||
@ -173,6 +174,18 @@ storageRepoPathExpression(const String *expression, const String *path)
|
||||
strCatFmt(result, "/%s", strPtr(path));
|
||||
}
|
||||
}
|
||||
else if (strEqZ(expression, STORAGE_REPO_BACKUP))
|
||||
{
|
||||
// Contruct the base path
|
||||
if (storageHelper.stanza != NULL)
|
||||
result = strNewFmt(STORAGE_PATH_BACKUP "/%s", strPtr(storageHelper.stanza));
|
||||
else
|
||||
result = strNew(STORAGE_PATH_BACKUP);
|
||||
|
||||
// Append subpath if provided
|
||||
if (path != NULL)
|
||||
strCatFmt(result, "/%s", strPtr(path));
|
||||
}
|
||||
else
|
||||
THROW_FMT(AssertError, "invalid expression '%s'", strPtr(expression));
|
||||
|
||||
|
@ -15,6 +15,7 @@ Storage path constants
|
||||
STRING_DECLARE(STORAGE_SPOOL_ARCHIVE_OUT_STR);
|
||||
|
||||
#define STORAGE_REPO_ARCHIVE "<REPO:ARCHIVE>"
|
||||
#define STORAGE_REPO_BACKUP "<REPO:BACKUP>"
|
||||
|
||||
/***********************************************************************************************************************************
|
||||
Repository storage types
|
||||
|
@ -962,6 +962,9 @@ testRun(void)
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_ARCHIVE "/9.4-1/000000010000014C0000001A.00000028.backup"))),
|
||||
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())),
|
||||
"check backup path");
|
||||
|
||||
// Change the stanza name and make sure helper fails
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -1012,6 +1015,12 @@ testRun(void)
|
||||
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())),
|
||||
"check backup path - NULL stanza");
|
||||
TEST_RESULT_STR(
|
||||
strPtr(storagePathNP(storage, strNew(STORAGE_REPO_BACKUP "/simple"))),
|
||||
strPtr(strNewFmt("%s/backup/simple", testPath())), "check simple backup path - NULL stanza");
|
||||
|
||||
// Reset init flag
|
||||
storageHelper.stanzaInit = false;
|
||||
|
Loading…
Reference in New Issue
Block a user