mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-01-04 03:49:14 +02:00
Throw user-friendly error if expire is not run on repository host.
Running the expire command on a non-repository host threw an assertion because the command is not yet configured for remote execution.
This commit is contained in:
parent
987df62ec0
commit
a5b2630d7c
@ -23,6 +23,16 @@
|
|||||||
<p>Add <cmd>backup</cmd>/<cmd>expire</cmd> running status to the <cmd>info</cmd> command.</p>
|
<p>Add <cmd>backup</cmd>/<cmd>expire</cmd> running status to the <cmd>info</cmd> command.</p>
|
||||||
</release-item>
|
</release-item>
|
||||||
</release-feature-list>
|
</release-feature-list>
|
||||||
|
|
||||||
|
<release-improvement-list>
|
||||||
|
<release-item>
|
||||||
|
<release-item-contributor-list>
|
||||||
|
<release-item-contributor id="cynthia.shang"/>
|
||||||
|
</release-item-contributor-list>
|
||||||
|
|
||||||
|
<p>Throw user-friendly error if <cmd>expire</cmd> is not run on repository host.</p>
|
||||||
|
</release-item>
|
||||||
|
</release-improvement-list>
|
||||||
</release-core-list>
|
</release-core-list>
|
||||||
</release>
|
</release>
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ Expire Command
|
|||||||
#include "info/infoArchive.h"
|
#include "info/infoArchive.h"
|
||||||
#include "info/infoBackup.h"
|
#include "info/infoBackup.h"
|
||||||
#include "info/manifest.h"
|
#include "info/manifest.h"
|
||||||
|
#include "protocol/helper.h"
|
||||||
#include "storage/helper.h"
|
#include "storage/helper.h"
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -640,11 +641,11 @@ cmdExpire(void)
|
|||||||
{
|
{
|
||||||
FUNCTION_LOG_VOID(logLevelDebug);
|
FUNCTION_LOG_VOID(logLevelDebug);
|
||||||
|
|
||||||
|
// Verify the repo is local
|
||||||
|
repoIsLocalVerify();
|
||||||
|
|
||||||
MEM_CONTEXT_TEMP_BEGIN()
|
MEM_CONTEXT_TEMP_BEGIN()
|
||||||
{
|
{
|
||||||
// Get the repo storage in case it is remote and encryption settings need to be pulled down
|
|
||||||
storageRepo();
|
|
||||||
|
|
||||||
// Load the backup.info
|
// Load the backup.info
|
||||||
InfoBackup *infoBackup = infoBackupLoadFileReconstruct(
|
InfoBackup *infoBackup = infoBackupLoadFileReconstruct(
|
||||||
storageRepo(), INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionStr(cfgOptRepoCipherType)),
|
storageRepo(), INFO_BACKUP_PATH_FILE_STR, cipherType(cfgOptionStr(cfgOptRepoCipherType)),
|
||||||
|
@ -477,11 +477,23 @@ testRun(void)
|
|||||||
// *****************************************************************************************************************************
|
// *****************************************************************************************************************************
|
||||||
if (testBegin("removeExpiredArchive() & cmdExpire()"))
|
if (testBegin("removeExpiredArchive() & cmdExpire()"))
|
||||||
{
|
{
|
||||||
|
TEST_TITLE("check repo local");
|
||||||
|
|
||||||
|
// Load Parameters
|
||||||
|
StringList *argList = strLstNew();
|
||||||
|
strLstAddZ(argList, "--stanza=db");
|
||||||
|
strLstAddZ(argList, "--repo1-retention-full=1"); // avoid warning
|
||||||
|
strLstAddZ(argList, "--repo1-host=/repo/not/local");
|
||||||
|
harnessCfgLoad(cfgCmdExpire, argList);
|
||||||
|
|
||||||
|
TEST_ERROR_FMT(
|
||||||
|
cmdExpire(), HostInvalidError, "expire command must be run on the repository host");
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------------------------------
|
||||||
TEST_TITLE("retention-archive not set");
|
TEST_TITLE("retention-archive not set");
|
||||||
|
|
||||||
// Load Parameters
|
// Load Parameters
|
||||||
StringList *argList = strLstDup(argListBase);
|
argList = strLstDup(argListBase);
|
||||||
harnessCfgLoad(cfgCmdExpire, argList);
|
harnessCfgLoad(cfgCmdExpire, argList);
|
||||||
|
|
||||||
// Create backup.info without current backups
|
// Create backup.info without current backups
|
||||||
|
Loading…
Reference in New Issue
Block a user