You've already forked pgbackrest
mirror of
https://github.com/pgbackrest/pgbackrest.git
synced 2025-07-03 00:26:59 +02:00
Fix options being ignored by asynchronous commands.
The local, remote, archive-get-async, and archive-push-async commands were used to run functionality that was not directly available to the user. Unfortunately that meant they would not pick up options from the command that the user expected, e.g. backup, archive-get, etc. Remove the internal commands and add roles which allow pgBackRest to determine what functionality is required without implementing special commands. This way the options are loaded from the expected command section. Since remote is no longer a specific command with its own options, more manipulation is required when calling remote. This might be something we can improve in the config system but it may be worth leaving as is because it is a one-off, for now at least.
This commit is contained in:
@ -150,13 +150,14 @@ testRun(void)
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--" CFGOPT_PG1_PATH "=/path/to/bogus");
|
||||
strLstAddZ(argList, "--pg7-path=/path/to");
|
||||
strLstAddZ(argList, "--pg7-host=test1");
|
||||
strLstAddZ(argList, "--host-id=7");
|
||||
strLstAddZ(argList, "--command=backup");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
|
||||
strLstAddZ(argList, "--process=0");
|
||||
strLstAddZ(argList, "local");
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
|
||||
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_BOOL(pgIsLocal(7), false, "pg is remote");
|
||||
@ -173,8 +174,8 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolLocalParam(protocolStorageTypeRepo, 1, 0), "|"),
|
||||
"--command=archive-get|--host-id=1|--log-level-file=off|--log-level-stderr=error|--process=0|--remote-type=repo"
|
||||
"|--stanza=test1|local",
|
||||
"--host-id=1|--log-level-console=off|--log-level-file=off|--log-level-stderr=error|--process=0|--remote-type=repo"
|
||||
"|--stanza=test1|archive-get:local",
|
||||
"local repo protocol params");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -189,8 +190,8 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolLocalParam(protocolStorageTypePg, 2, 1), "|"),
|
||||
"--command=backup|--host-id=2|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg"
|
||||
"|--process=1|--remote-type=pg|--stanza=test1|local",
|
||||
"--host-id=2|--log-level-console=off|--log-level-file=info|--log-level-stderr=error|--log-subprocess|--pg1-path=/pg"
|
||||
"|--process=1|--remote-type=pg|--repo1-retention-full=1|--stanza=test1|backup:local",
|
||||
"local pg protocol params");
|
||||
}
|
||||
|
||||
@ -214,8 +215,8 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 0, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|repo-host-user@repo-host"
|
||||
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=0"
|
||||
" --remote-type=repo --stanza=test1 remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --process=0 --remote-type=repo"
|
||||
" --stanza=test1 archive-get:remote",
|
||||
"remote protocol params");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -235,28 +236,27 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 1, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|-p|444|repo-host-user@repo-host"
|
||||
"|pgbackrest --command=archive-get --config=/path/pgbackrest.conf --config-include-path=/path/include"
|
||||
" --config-path=/path/config --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
|
||||
" --remote-type=repo --stanza=test1 remote",
|
||||
"|pgbackrest --config=/path/pgbackrest.conf --config-include-path=/path/include --config-path=/path/config"
|
||||
" --log-level-console=off --log-level-file=info --log-level-stderr=error --log-subprocess --process=1"
|
||||
" --remote-type=repo --stanza=test1 archive-get:remote",
|
||||
"remote protocol params with replacements");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--command=archive-get");
|
||||
strLstAddZ(argList, "--process=3");
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_REPO);
|
||||
strLstAddZ(argList, "--repo1-host=repo-host");
|
||||
strLstAddZ(argList, "local");
|
||||
strLstAddZ(argList, CFGCMD_ARCHIVE_GET ":" CONFIG_COMMAND_ROLE_LOCAL);
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypeRepo, 66, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|pgbackrest@repo-host"
|
||||
"|pgbackrest --command=archive-get --log-level-file=off --log-level-stderr=error --process=3"
|
||||
" --remote-type=repo --stanza=test1 remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --process=3 --remote-type=repo"
|
||||
" --stanza=test1 archive-get:remote",
|
||||
"remote protocol params for backup local");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
@ -272,15 +272,14 @@ testRun(void)
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 0), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg1-host"
|
||||
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/1"
|
||||
" --process=1 --remote-type=pg --stanza=test1 remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/1"
|
||||
" --process=1 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"remote protocol params for db backup");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--command=backup");
|
||||
strLstAddZ(argList, "--process=4");
|
||||
strLstAddZ(argList, "--host-id=2");
|
||||
strLstAddZ(argList, "--pg1-path=/path/to/1");
|
||||
@ -289,21 +288,21 @@ testRun(void)
|
||||
strLstAddZ(argList, "--pg2-path=/path/to/2");
|
||||
strLstAddZ(argList, "--pg2-host=pg2-host");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
|
||||
strLstAddZ(argList, "local");
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
|
||||
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 1), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg2-host"
|
||||
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/2"
|
||||
" --process=4 --remote-type=pg --stanza=test1 remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/2"
|
||||
" --process=4 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"remote protocol params for db local");
|
||||
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "pgbackrest");
|
||||
strLstAddZ(argList, "--stanza=test1");
|
||||
strLstAddZ(argList, "--command=backup");
|
||||
strLstAddZ(argList, "--process=4");
|
||||
strLstAddZ(argList, "--host-id=3");
|
||||
strLstAddZ(argList, "--pg1-path=/path/to/1");
|
||||
@ -312,14 +311,15 @@ testRun(void)
|
||||
strLstAddZ(argList, "--pg3-socket-path=/socket3");
|
||||
strLstAddZ(argList, "--pg3-port=3333");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
|
||||
strLstAddZ(argList, "local");
|
||||
strLstAddZ(argList, "--" CFGOPT_REPO1_RETENTION_FULL "=1");
|
||||
strLstAddZ(argList, CFGCMD_BACKUP ":" CONFIG_COMMAND_ROLE_LOCAL);
|
||||
harnessCfgLoadRaw(strLstSize(argList), strLstPtr(argList));
|
||||
|
||||
TEST_RESULT_STR_Z(
|
||||
strLstJoin(protocolRemoteParam(protocolStorageTypePg, 1, 2), "|"),
|
||||
"-o|LogLevel=error|-o|Compression=no|-o|PasswordAuthentication=no|postgres@pg3-host"
|
||||
"|pgbackrest --command=backup --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/3"
|
||||
" --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1 remote",
|
||||
"|pgbackrest --log-level-console=off --log-level-file=off --log-level-stderr=error --pg1-path=/path/to/3"
|
||||
" --pg1-port=3333 --pg1-socket-path=/socket3 --process=4 --remote-type=pg --stanza=test1 backup:remote",
|
||||
"remote protocol params for db local");
|
||||
}
|
||||
|
||||
@ -872,10 +872,9 @@ testRun(void)
|
||||
strLstAdd(argList, strNewFmt("--repo1-host-user=%s", testUser()));
|
||||
strLstAdd(argList, strNewFmt("--repo1-path=%s", testPath()));
|
||||
strLstAddZ(argList, "--process=999");
|
||||
strLstAddZ(argList, "--command=archive-get");
|
||||
strLstAddZ(argList, "--host-id=1");
|
||||
strLstAddZ(argList, "--" CFGOPT_REMOTE_TYPE "=" PROTOCOL_REMOTE_TYPE_PG);
|
||||
harnessCfgLoad(cfgCmdLocal, argList);
|
||||
harnessCfgLoadRole(cfgCmdArchiveGet, cfgCmdRoleLocal, argList);
|
||||
|
||||
TEST_RESULT_STR_Z(cfgOptionStr(cfgOptRepoCipherPass), "acbd", "check cipher pass before");
|
||||
TEST_ASSIGN(client, protocolRemoteGet(protocolStorageTypeRepo, 1), "get remote protocol");
|
||||
@ -908,7 +907,7 @@ testRun(void)
|
||||
|
||||
TEST_RESULT_VOID(protocolFree(), "free remote protocol objects");
|
||||
|
||||
// Start db protocol
|
||||
// Start remote protocol
|
||||
// -------------------------------------------------------------------------------------------------------------------------
|
||||
argList = strLstNew();
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
@ -927,7 +926,7 @@ testRun(void)
|
||||
strLstAddZ(argList, "--stanza=db");
|
||||
strLstAddZ(argList, "--protocol-timeout=10");
|
||||
strLstAddZ(argList, "--process-max=2");
|
||||
harnessCfgLoad(cfgCmdArchiveGetAsync, argList);
|
||||
harnessCfgLoad(cfgCmdArchiveGet, argList);
|
||||
|
||||
TEST_ASSIGN(client, protocolLocalGet(protocolStorageTypeRepo, 1, 1), "get local protocol");
|
||||
TEST_RESULT_PTR(protocolLocalGet(protocolStorageTypeRepo, 1, 1), client, "get local cached protocol");
|
||||
|
Reference in New Issue
Block a user