mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2025-03-04 15:51:29 +02:00
More remote options to config
This commit is contained in:
parent
bd241d8253
commit
eea74a8423
12
src/backup.c
12
src/backup.c
@ -492,7 +492,7 @@ do_backup_instance(void)
|
||||
current.data_bytes = 0;
|
||||
|
||||
/* Obtain current timeline */
|
||||
if (is_remote_backup)
|
||||
if (instance_config.remote.enabled)
|
||||
{
|
||||
char *sysidentifier;
|
||||
TimeLineID starttli;
|
||||
@ -632,7 +632,7 @@ do_backup_instance(void)
|
||||
backup_files_list = parray_new();
|
||||
|
||||
/* list files with the logical path. omit $PGDATA */
|
||||
if (is_remote_backup)
|
||||
if (instance_config.remote.enabled)
|
||||
get_remote_pgdata_filelist(backup_files_list);
|
||||
else
|
||||
dir_list_file(backup_files_list, instance_config.pgdata,
|
||||
@ -699,7 +699,7 @@ do_backup_instance(void)
|
||||
char *dir_name;
|
||||
char database_path[MAXPGPATH];
|
||||
|
||||
if (!is_remote_backup)
|
||||
if (!instance_config.remote.enabled)
|
||||
dir_name = GetRelativePath(file->path, instance_config.pgdata);
|
||||
else
|
||||
dir_name = file->path;
|
||||
@ -749,7 +749,7 @@ do_backup_instance(void)
|
||||
|
||||
elog(VERBOSE, "Start thread num: %i", i);
|
||||
|
||||
if (!is_remote_backup)
|
||||
if (!instance_config.remote.enabled)
|
||||
pthread_create(&threads[i], NULL, backup_files, arg);
|
||||
else
|
||||
pthread_create(&threads[i], NULL, remote_backup_files, arg);
|
||||
@ -902,7 +902,7 @@ do_backup(time_t start_time)
|
||||
check_server_version();
|
||||
|
||||
/* TODO fix it for remote backup*/
|
||||
if (!is_remote_backup)
|
||||
if (!instance_config.remote.enabled)
|
||||
current.checksum_version = get_data_checksum_version(true);
|
||||
|
||||
is_checksum_enabled = pg_checksum_enable();
|
||||
@ -958,7 +958,7 @@ do_backup(time_t start_time)
|
||||
* belogns to the same instance.
|
||||
*/
|
||||
/* TODO fix it for remote backup */
|
||||
if (!is_remote_backup)
|
||||
if (!instance_config.remote.enabled)
|
||||
check_system_identifiers();
|
||||
|
||||
|
||||
|
@ -37,6 +37,7 @@ static void show_configure_json(ConfigOption *opt);
|
||||
#define OPTION_LOG_GROUP "Logging parameters"
|
||||
#define OPTION_RETENTION_GROUP "Retention parameters"
|
||||
#define OPTION_COMPRESS_GROUP "Compression parameters"
|
||||
#define OPTION_REMOTE_GROUP "Remote access parameters"
|
||||
|
||||
/*
|
||||
* Short name should be non-printable ASCII character.
|
||||
@ -172,6 +173,42 @@ ConfigOption instance_options[] =
|
||||
&instance_config.compress_level, SOURCE_CMD, 0,
|
||||
OPTION_COMPRESS_GROUP, 0, option_get_value
|
||||
},
|
||||
/* Remote backup options */
|
||||
{
|
||||
's', 219, "remote-proto",
|
||||
&instance_config.remote.proto, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 220, "remote-host",
|
||||
&instance_config.remote.host, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 221, "remote-port",
|
||||
&instance_config.remote.port, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 222, "remote-path",
|
||||
&instance_config.remote.path, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 223, "ssh-options",
|
||||
&instance_config.remote.ssh_options, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
's', 224, "ssh-config",
|
||||
&instance_config.remote.ssh_config, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{
|
||||
'b', 225, "remote",
|
||||
&instance_config.remote.enabled, SOURCE_CMD, 0,
|
||||
OPTION_REMOTE_GROUP, 0, option_get_value
|
||||
},
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -277,6 +314,8 @@ init_config(InstanceConfig *config)
|
||||
|
||||
config->compress_alg = COMPRESS_ALG_DEFAULT;
|
||||
config->compress_level = COMPRESS_LEVEL_DEFAULT;
|
||||
|
||||
config->remote.proto = (char*)"ssh";
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -66,14 +66,7 @@ char *replication_slot = NULL;
|
||||
/* backup options */
|
||||
bool backup_logs = false;
|
||||
bool smooth_checkpoint;
|
||||
char *remote_host;
|
||||
char *remote_port;
|
||||
char *remote_path;
|
||||
char *remote_proto = (char*)"ssh";
|
||||
char *ssh_config;
|
||||
char *ssh_options;
|
||||
char *remote_agent;
|
||||
bool is_remote_backup;
|
||||
|
||||
/* restore options */
|
||||
static char *target_time = NULL;
|
||||
@ -142,15 +135,6 @@ static ConfigOption cmd_options[] =
|
||||
{ 's', 'S', "slot", &replication_slot, SOURCE_CMD_STRICT },
|
||||
{ 'b', 134, "delete-wal", &delete_wal, SOURCE_CMD_STRICT },
|
||||
{ 'b', 135, "delete-expired", &delete_expired, SOURCE_CMD_STRICT },
|
||||
/* remote options */
|
||||
{ 's', 19, "remote-proto", &remote_proto, SOURCE_CMD_STRICT, },
|
||||
{ 'b', 20, "remote", &is_remote_backup, SOURCE_CMD_STRICT, },
|
||||
{ 's', 21, "remote-host", &remote_host, SOURCE_CMD_STRICT, },
|
||||
{ 's', 22, "remote-port", &remote_port, SOURCE_CMD_STRICT, },
|
||||
{ 's', 23, "remote-path", &remote_path, SOURCE_CMD_STRICT, },
|
||||
{ 's', 24, "ssh-config", &ssh_config, SOURCE_CMD_STRICT, },
|
||||
{ 's', 25, "ssh-options", &ssh_options, SOURCE_CMD_STRICT, },
|
||||
{ 's', 26, "agent", &remote_agent, SOURCE_CMD_STRICT, },
|
||||
/* restore options */
|
||||
{ 's', 136, "time", &target_time, SOURCE_CMD_STRICT },
|
||||
{ 's', 137, "xid", &target_xid, SOURCE_CMD_STRICT },
|
||||
@ -182,6 +166,8 @@ static ConfigOption cmd_options[] =
|
||||
{ 'b', 152, "overwrite", &file_overwrite, SOURCE_CMD_STRICT },
|
||||
/* show options */
|
||||
{ 'f', 153, "format", opt_show_format, SOURCE_CMD_STRICT },
|
||||
/* remote options */
|
||||
{ 's', 155, "agent", &remote_agent, SOURCE_CMD_STRICT, },
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -531,9 +517,9 @@ main(int argc, char *argv[])
|
||||
start_time = time(NULL);
|
||||
backup_mode = deparse_backup_mode(current.backup_mode);
|
||||
|
||||
elog(INFO, "Backup start, pg_probackup version: %s, backup ID: %s, backup mode: %s, instance: %s, stream: %s, remote: %s",
|
||||
elog(INFO, "Backup start, pg_probackup version: %s, backup ID: %s, backup mode: %s, instance: %s, stream: %s, remote %s",
|
||||
PROGRAM_VERSION, base36enc(start_time), backup_mode, instance_name,
|
||||
stream_wal ? "true" : "false", remote_host ? "true" : "false");
|
||||
stream_wal ? "true" : "false", instance_config.remote.enabled ? "true" : "false");
|
||||
|
||||
return do_backup(start_time);
|
||||
}
|
||||
|
@ -25,6 +25,7 @@
|
||||
|
||||
#include "utils/configuration.h"
|
||||
#include "utils/logger.h"
|
||||
#include "utils/remote.h"
|
||||
#include "utils/parray.h"
|
||||
#include "utils/pgut.h"
|
||||
#include "utils/file.h"
|
||||
@ -197,6 +198,9 @@ typedef struct InstanceConfig
|
||||
/* Logger parameters */
|
||||
LoggerConfig logger;
|
||||
|
||||
/* Remote access parameters */
|
||||
RemoteConfig remote;
|
||||
|
||||
/* Retention options. 0 disables the option. */
|
||||
uint32 retention_redundancy;
|
||||
uint32 retention_window;
|
||||
@ -344,7 +348,7 @@ typedef struct
|
||||
XLByteInSeg(xlrp, logSegNo)
|
||||
#endif
|
||||
|
||||
#define IsSshConnection() (remote_host != NULL && strcmp(remote_proto, "ssh") == 0)
|
||||
#define IsSshConnection() (instance_config.remote.enabled && strcmp(instance_config.remote.proto, "ssh") == 0)
|
||||
|
||||
/* directory options */
|
||||
extern char *backup_path;
|
||||
@ -364,14 +368,7 @@ extern char *replication_slot;
|
||||
extern bool smooth_checkpoint;
|
||||
|
||||
/* remote probackup options */
|
||||
extern char *remote_path;
|
||||
extern char *remote_port;
|
||||
extern char *remote_host;
|
||||
extern char *remote_proto;
|
||||
extern char *ssh_config;
|
||||
extern char *ssh_options;
|
||||
extern char* remote_agent;
|
||||
extern bool is_remote_backup;
|
||||
|
||||
extern bool is_ptrack_support;
|
||||
extern bool is_checksum_enabled;
|
||||
|
@ -83,29 +83,29 @@ int remote_execute(int argc, char* argv[], bool listen)
|
||||
char* pg_probackup = argv[0];
|
||||
|
||||
ssh_argc = 0;
|
||||
ssh_argv[ssh_argc++] = remote_proto;
|
||||
if (remote_port != NULL) {
|
||||
ssh_argv[ssh_argc++] = instance_config.remote.proto;
|
||||
if (instance_config.remote.port != NULL) {
|
||||
ssh_argv[ssh_argc++] = (char*)"-p";
|
||||
ssh_argv[ssh_argc++] = remote_port;
|
||||
ssh_argv[ssh_argc++] = instance_config.remote.port;
|
||||
}
|
||||
if (ssh_config != NULL) {
|
||||
if (instance_config.remote.ssh_config != NULL) {
|
||||
ssh_argv[ssh_argc++] = (char*)"-F";
|
||||
ssh_argv[ssh_argc++] = ssh_config;
|
||||
ssh_argv[ssh_argc++] = instance_config.remote.ssh_config;
|
||||
}
|
||||
if (ssh_options != NULL) {
|
||||
ssh_argc = split_options(ssh_argc, ssh_argv, MAX_CMDLINE_OPTIONS, ssh_options);
|
||||
if (instance_config.remote.ssh_options != NULL) {
|
||||
ssh_argc = split_options(ssh_argc, ssh_argv, MAX_CMDLINE_OPTIONS, instance_config.remote.ssh_options);
|
||||
}
|
||||
ssh_argv[ssh_argc++] = remote_host;
|
||||
ssh_argv[ssh_argc++] = instance_config.remote.host;
|
||||
ssh_argv[ssh_argc++] = cmd;
|
||||
ssh_argv[ssh_argc] = NULL;
|
||||
|
||||
if (remote_path)
|
||||
if (instance_config.remote.path)
|
||||
{
|
||||
char* sep = strrchr(pg_probackup, '/');
|
||||
if (sep != NULL) {
|
||||
pg_probackup = sep + 1;
|
||||
}
|
||||
dst = snprintf(cmd, sizeof(cmd), "%s/%s", remote_path, pg_probackup);
|
||||
dst = snprintf(cmd, sizeof(cmd), "%s/%s", instance_config.remote.path, pg_probackup);
|
||||
} else {
|
||||
dst = snprintf(cmd, sizeof(cmd), "%s", pg_probackup);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user