mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2026-06-21 01:34:15 +02:00
Add --remote-path option
This commit is contained in:
+6
-4
@@ -69,6 +69,7 @@ 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;
|
||||
@@ -145,10 +146,11 @@ static ConfigOption cmd_options[] =
|
||||
{ 's', 19, "remote-host", &remote_host, SOURCE_CMD_STRICT, },
|
||||
{ 's', 20, "remote-port", &remote_port, SOURCE_CMD_STRICT, },
|
||||
{ 's', 21, "remote-proto", &remote_proto, SOURCE_CMD_STRICT, },
|
||||
{ 's', 22, "ssh-config", &ssh_config, SOURCE_CMD_STRICT, },
|
||||
{ 's', 23, "ssh-options", &ssh_options, SOURCE_CMD_STRICT, },
|
||||
{ 'b', 24, "agent", &is_remote_agent, SOURCE_CMD_STRICT, },
|
||||
{ 'b', 25, "remote", &is_remote_backup, SOURCE_CMD_STRICT, },
|
||||
{ 's', 22, "remote-path", &remote_path, SOURCE_CMD_STRICT, },
|
||||
{ 's', 23, "ssh-config", &ssh_config, SOURCE_CMD_STRICT, },
|
||||
{ 's', 24, "ssh-options", &ssh_options, SOURCE_CMD_STRICT, },
|
||||
{ 'b', 25, "agent", &is_remote_agent, SOURCE_CMD_STRICT, },
|
||||
{ 'b', 26, "remote", &is_remote_backup, SOURCE_CMD_STRICT, },
|
||||
/* restore options */
|
||||
{ 's', 136, "time", &target_time, SOURCE_CMD_STRICT },
|
||||
{ 's', 137, "xid", &target_xid, SOURCE_CMD_STRICT },
|
||||
|
||||
@@ -360,6 +360,7 @@ extern char *replication_slot;
|
||||
|
||||
/* backup options */
|
||||
extern bool smooth_checkpoint;
|
||||
extern char *remote_path;
|
||||
extern char *remote_port;
|
||||
extern char *remote_host;
|
||||
extern char *remote_proto;
|
||||
|
||||
+13
-2
@@ -71,6 +71,7 @@ int remote_execute(int argc, char* argv[], bool listen)
|
||||
int outfd[2];
|
||||
int infd[2];
|
||||
pid_t pid;
|
||||
char* pg_probackup = argv[0];
|
||||
|
||||
ssh_argc = 0;
|
||||
ssh_argv[ssh_argc++] = remote_proto;
|
||||
@@ -86,10 +87,20 @@ int remote_execute(int argc, char* argv[], bool listen)
|
||||
ssh_argc = split_options(ssh_argc, ssh_argv, MAX_CMDLINE_OPTIONS, ssh_options);
|
||||
}
|
||||
ssh_argv[ssh_argc++] = remote_host;
|
||||
ssh_argv[ssh_argc++] = cmd+1;
|
||||
ssh_argv[ssh_argc++] = cmd;
|
||||
ssh_argv[ssh_argc] = NULL;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (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);
|
||||
} else {
|
||||
dst = snprintf(cmd, sizeof(cmd), "%s", pg_probackup);
|
||||
}
|
||||
for (i = 1; i < argc; i++) {
|
||||
dst = append_option(cmd, sizeof(cmd), dst, argv[i]);
|
||||
}
|
||||
dst = append_option(cmd, sizeof(cmd), dst, "--agent");
|
||||
|
||||
Reference in New Issue
Block a user