!329 gs_probackup修改

Merge pull request !329 from yukai_k/master
This commit is contained in:
opengauss-bot
2020-10-26 10:13:21 +08:00
committed by Gitee
6 changed files with 28 additions and 26 deletions

View File

@ -962,6 +962,12 @@ opt_path_map(ConfigOption *opt, const char *arg, TablespaceList *list,
else
list->head = cell;
list->tail = cell;
if (strncmp(type, "tablespace", strlen(type)) == 0) {
specify_tbsdir = true;
} else if (strncmp(type, "external directory", strlen(type)) == 0) {
specify_extdir = true;
}
}
/* Parse tablespace mapping */

View File

@ -137,7 +137,7 @@ void help_pg_probackup(void)
printf(_(" [--compress-algorithm=compress-algorithm]\n"));
printf(_(" [--compress-level=compress-level]\n"));
printf(_(" [--compress]\n"));
printf(_(" [-d dbname] [-h host] [-p port] [-U username] [-w] [-W]\n"));
printf(_(" [-d dbname] [-h host] [-p port] [-U username] [-w] [-W password]\n"));
printf(_(" [--remote-proto=protocol] [--remote-host=destination]\n"));
printf(_(" [--remote-path=path] [--remote-user=username]\n"));
printf(_(" [--remote-port=port] [--ssh-options=ssh_options]\n"));
@ -410,7 +410,7 @@ static void help_backup(void)
printf(_(" [--compress-algorithm=compress-algorithm]\n"));
printf(_(" [--compress-level=compress-level]\n"));
printf(_(" [--compress]\n"));
printf(_(" [-d dbname] [-h host] [-p port] [-U username] [-w] [-W]\n"));
printf(_(" [-d dbname] [-h host] [-p port] [-U username] [-w] [-W password]\n"));
printf(_(" [--remote-proto=protocol] [--remote-host=destination]\n"));
printf(_(" [--remote-path=path] [--remote-user=username]\n"));
printf(_(" [--remote-port=port] [--ssh-options=ssh_options]\n"));
@ -484,7 +484,7 @@ static void help_backup(void)
printf(_(" -h, --pghost=hostname database server host or socket directory(default: 'local socket')\n"));
printf(_(" -p, --pgport=port database server port (default: 5432)\n"));
printf(_(" -w, --no-password never prompt for password\n"));
printf(_(" -W, --password force password prompt\n"));
printf(_(" -W, --password=password the password of specified database user\n"));
printf(_("\n Remote options:\n"));
printf(_(" --remote-proto=protocol remote protocol to use\n"));

View File

@ -102,6 +102,9 @@ IncrRestoreMode incremental_mode = INCR_NONE;
bool skip_block_validation = false;
bool skip_external_dirs = false;
bool specify_extdir = false;
bool specify_tbsdir = false;
/* delete options */
bool delete_wal = false;
bool delete_expired = false;
@ -235,8 +238,7 @@ setMyLocation(void)
/*
* Entry point of pg_probackup command.
*/
int
main(int argc, char *argv[])
int main(int argc, char *argv[])
{
char *command = NULL,
*command_name;
@ -382,11 +384,19 @@ main(int argc, char *argv[])
optind += 1;
/* Parse command line only arguments */
config_get_opt(argc, argv, cmd_options, instance_options);
if (password) {
if (!prompt_password) {
elog(ERROR, "You cannot specify --password and --no-password options together");
}
replace_password(argc, argv, "-W");
replace_password(argc, argv, "--password");
}
if (specify_tbsdir && !specify_extdir) {
elog(ERROR, "If specify --tablespace-mapping option, you must specify --external-mapping option together");
}
pgut_init();
if (help_opt)

View File

@ -719,6 +719,8 @@ extern bool compress_shortcut;
/* other options */
extern char *instance_name;
extern bool specify_extdir;
extern bool specify_tbsdir;
/* show options */
extern ShowFormat show_format;

View File

@ -24,8 +24,7 @@
#include "logger.h"
#include "file.h"
bool prompt_password = true;
bool force_password = false;
bool prompt_password = true;
/* Database connections */
static PGcancel *volatile cancel_conn = NULL;
@ -554,21 +553,14 @@ escapeConnectionParameter(const char *src)
/* TODO: it is better to use PQconnectdbParams like in psql
* It will allow to set application_name for pg_probackup
*/
PGconn *
pgut_connect(const char *host, const char *port,
const char *dbname, const char *username)
PGconn* pgut_connect(const char *host, const char *port,
const char *dbname, const char *username)
{
PGconn *conn;
if (interrupted && !in_cleanup)
elog(ERROR, "interrupted");
if (force_password && !prompt_password)
elog(ERROR, "You cannot specify --password and --no-password options together");
if (!password && force_password)
prompt_for_password(username);
/* Start the connection. Loop until we have a password if requested by backend. */
for (;;)
{
@ -602,9 +594,8 @@ pgut_connect(const char *host, const char *port,
}
}
PGconn *
pgut_connect_replication(const char *host, const char *port,
const char *dbname, const char *username)
PGconn* pgut_connect_replication(const char *host, const char *port,
const char *dbname, const char *username)
{
PGconn *tmpconn;
int argcount = 7; /* dbname, replication, fallback_app_name,
@ -616,12 +607,6 @@ pgut_connect_replication(const char *host, const char *port,
if (interrupted && !in_cleanup)
elog(ERROR, "interrupted");
if (force_password && !prompt_password)
elog(ERROR, "You cannot specify --password and --no-password options together");
if (!password && force_password)
prompt_for_password(username);
i = 0;
keywords = (const char**)pg_malloc0((argcount + 1) * sizeof(*keywords));

View File

@ -23,7 +23,6 @@ extern void pgut_help(bool details);
* pgut framework variables and functions
*/
extern bool prompt_password;
extern bool force_password;
extern bool interrupted;
extern bool in_cleanup;