Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commiteea74a8

Browse files
committed
More remote options to config
1 parentbd241d8 commiteea74a8

File tree

5 files changed

+64
-42
lines changed

5 files changed

+64
-42
lines changed

‎src/backup.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@ do_backup_instance(void)
492492
current.data_bytes=0;
493493

494494
/* Obtain current timeline */
495-
if (is_remote_backup)
495+
if (instance_config.remote.enabled)
496496
{
497497
char*sysidentifier;
498498
TimeLineIDstarttli;
@@ -632,7 +632,7 @@ do_backup_instance(void)
632632
backup_files_list=parray_new();
633633

634634
/* list files with the logical path. omit $PGDATA */
635-
if (is_remote_backup)
635+
if (instance_config.remote.enabled)
636636
get_remote_pgdata_filelist(backup_files_list);
637637
else
638638
dir_list_file(backup_files_list,instance_config.pgdata,
@@ -699,7 +699,7 @@ do_backup_instance(void)
699699
char*dir_name;
700700
chardatabase_path[MAXPGPATH];
701701

702-
if (!is_remote_backup)
702+
if (!instance_config.remote.enabled)
703703
dir_name=GetRelativePath(file->path,instance_config.pgdata);
704704
else
705705
dir_name=file->path;
@@ -749,7 +749,7 @@ do_backup_instance(void)
749749

750750
elog(VERBOSE,"Start thread num: %i",i);
751751

752-
if (!is_remote_backup)
752+
if (!instance_config.remote.enabled)
753753
pthread_create(&threads[i],NULL,backup_files,arg);
754754
else
755755
pthread_create(&threads[i],NULL,remote_backup_files,arg);
@@ -902,7 +902,7 @@ do_backup(time_t start_time)
902902
check_server_version();
903903

904904
/* TODO fix it for remote backup*/
905-
if (!is_remote_backup)
905+
if (!instance_config.remote.enabled)
906906
current.checksum_version=get_data_checksum_version(true);
907907

908908
is_checksum_enabled=pg_checksum_enable();
@@ -958,7 +958,7 @@ do_backup(time_t start_time)
958958
* belogns to the same instance.
959959
*/
960960
/* TODO fix it for remote backup */
961-
if (!is_remote_backup)
961+
if (!instance_config.remote.enabled)
962962
check_system_identifiers();
963963

964964

‎src/configure.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static void show_configure_json(ConfigOption *opt);
3737
#defineOPTION_LOG_GROUP"Logging parameters"
3838
#defineOPTION_RETENTION_GROUP"Retention parameters"
3939
#defineOPTION_COMPRESS_GROUP"Compression parameters"
40+
#defineOPTION_REMOTE_GROUP"Remote access parameters"
4041

4142
/*
4243
* Short name should be non-printable ASCII character.
@@ -172,6 +173,42 @@ ConfigOption instance_options[] =
172173
&instance_config.compress_level,SOURCE_CMD,0,
173174
OPTION_COMPRESS_GROUP,0,option_get_value
174175
},
176+
/* Remote backup options */
177+
{
178+
's',219,"remote-proto",
179+
&instance_config.remote.proto,SOURCE_CMD,0,
180+
OPTION_REMOTE_GROUP,0,option_get_value
181+
},
182+
{
183+
's',220,"remote-host",
184+
&instance_config.remote.host,SOURCE_CMD,0,
185+
OPTION_REMOTE_GROUP,0,option_get_value
186+
},
187+
{
188+
's',221,"remote-port",
189+
&instance_config.remote.port,SOURCE_CMD,0,
190+
OPTION_REMOTE_GROUP,0,option_get_value
191+
},
192+
{
193+
's',222,"remote-path",
194+
&instance_config.remote.path,SOURCE_CMD,0,
195+
OPTION_REMOTE_GROUP,0,option_get_value
196+
},
197+
{
198+
's',223,"ssh-options",
199+
&instance_config.remote.ssh_options,SOURCE_CMD,0,
200+
OPTION_REMOTE_GROUP,0,option_get_value
201+
},
202+
{
203+
's',224,"ssh-config",
204+
&instance_config.remote.ssh_config,SOURCE_CMD,0,
205+
OPTION_REMOTE_GROUP,0,option_get_value
206+
},
207+
{
208+
'b',225,"remote",
209+
&instance_config.remote.enabled,SOURCE_CMD,0,
210+
OPTION_REMOTE_GROUP,0,option_get_value
211+
},
175212
{0 }
176213
};
177214

@@ -277,6 +314,8 @@ init_config(InstanceConfig *config)
277314

278315
config->compress_alg=COMPRESS_ALG_DEFAULT;
279316
config->compress_level=COMPRESS_LEVEL_DEFAULT;
317+
318+
config->remote.proto= (char*)"ssh";
280319
}
281320

282321
staticvoid

‎src/pg_probackup.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,7 @@ char *replication_slot = NULL;
6666
/* backup options */
6767
boolbackup_logs= false;
6868
boolsmooth_checkpoint;
69-
char*remote_host;
70-
char*remote_port;
71-
char*remote_path;
72-
char*remote_proto= (char*)"ssh";
73-
char*ssh_config;
74-
char*ssh_options;
7569
char*remote_agent;
76-
boolis_remote_backup;
7770

7871
/* restore options */
7972
staticchar*target_time=NULL;
@@ -142,15 +135,6 @@ static ConfigOption cmd_options[] =
142135
{'s','S',"slot",&replication_slot,SOURCE_CMD_STRICT },
143136
{'b',134,"delete-wal",&delete_wal,SOURCE_CMD_STRICT },
144137
{'b',135,"delete-expired",&delete_expired,SOURCE_CMD_STRICT },
145-
/* remote options */
146-
{'s',19,"remote-proto",&remote_proto,SOURCE_CMD_STRICT, },
147-
{'b',20,"remote",&is_remote_backup,SOURCE_CMD_STRICT, },
148-
{'s',21,"remote-host",&remote_host,SOURCE_CMD_STRICT, },
149-
{'s',22,"remote-port",&remote_port,SOURCE_CMD_STRICT, },
150-
{'s',23,"remote-path",&remote_path,SOURCE_CMD_STRICT, },
151-
{'s',24,"ssh-config",&ssh_config,SOURCE_CMD_STRICT, },
152-
{'s',25,"ssh-options",&ssh_options,SOURCE_CMD_STRICT, },
153-
{'s',26,"agent",&remote_agent,SOURCE_CMD_STRICT, },
154138
/* restore options */
155139
{'s',136,"time",&target_time,SOURCE_CMD_STRICT },
156140
{'s',137,"xid",&target_xid,SOURCE_CMD_STRICT },
@@ -182,6 +166,8 @@ static ConfigOption cmd_options[] =
182166
{'b',152,"overwrite",&file_overwrite,SOURCE_CMD_STRICT },
183167
/* show options */
184168
{'f',153,"format",opt_show_format,SOURCE_CMD_STRICT },
169+
/* remote options */
170+
{'s',155,"agent",&remote_agent,SOURCE_CMD_STRICT, },
185171
{0 }
186172
};
187173

@@ -531,9 +517,9 @@ main(int argc, char *argv[])
531517
start_time=time(NULL);
532518
backup_mode=deparse_backup_mode(current.backup_mode);
533519

534-
elog(INFO,"Backup start, pg_probackup version: %s, backup ID: %s, backup mode: %s, instance: %s, stream: %s, remote: %s",
520+
elog(INFO,"Backup start, pg_probackup version: %s, backup ID: %s, backup mode: %s, instance: %s, stream: %s, remote %s",
535521
PROGRAM_VERSION,base36enc(start_time),backup_mode,instance_name,
536-
stream_wal ?"true" :"false",remote_host ?"true" :"false");
522+
stream_wal ?"true" :"false",instance_config.remote.enabled ?"true" :"false");
537523

538524
returndo_backup(start_time);
539525
}

‎src/pg_probackup.h

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
#include"utils/configuration.h"
2727
#include"utils/logger.h"
28+
#include"utils/remote.h"
2829
#include"utils/parray.h"
2930
#include"utils/pgut.h"
3031
#include"utils/file.h"
@@ -197,6 +198,9 @@ typedef struct InstanceConfig
197198
/* Logger parameters */
198199
LoggerConfiglogger;
199200

201+
/* Remote access parameters */
202+
RemoteConfigremote;
203+
200204
/* Retention options. 0 disables the option. */
201205
uint32retention_redundancy;
202206
uint32retention_window;
@@ -344,7 +348,7 @@ typedef struct
344348
XLByteInSeg(xlrp, logSegNo)
345349
#endif
346350

347-
#defineIsSshConnection() (remote_host != NULL&& strcmp(remote_proto, "ssh") == 0)
351+
#defineIsSshConnection() (instance_config.remote.enabled&& strcmp(instance_config.remote.proto, "ssh") == 0)
348352

349353
/* directory options */
350354
externchar*backup_path;
@@ -364,14 +368,7 @@ extern char *replication_slot;
364368
externboolsmooth_checkpoint;
365369

366370
/* remote probackup options */
367-
externchar*remote_path;
368-
externchar*remote_port;
369-
externchar*remote_host;
370-
externchar*remote_proto;
371-
externchar*ssh_config;
372-
externchar*ssh_options;
373371
externchar*remote_agent;
374-
externboolis_remote_backup;
375372

376373
externboolis_ptrack_support;
377374
externboolis_checksum_enabled;

‎src/utils/remote.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,29 +83,29 @@ int remote_execute(int argc, char* argv[], bool listen)
8383
char*pg_probackup=argv[0];
8484

8585
ssh_argc=0;
86-
ssh_argv[ssh_argc++]=remote_proto;
87-
if (remote_port!=NULL) {
86+
ssh_argv[ssh_argc++]=instance_config.remote.proto;
87+
if (instance_config.remote.port!=NULL) {
8888
ssh_argv[ssh_argc++]= (char*)"-p";
89-
ssh_argv[ssh_argc++]=remote_port;
89+
ssh_argv[ssh_argc++]=instance_config.remote.port;
9090
}
91-
if (ssh_config!=NULL) {
91+
if (instance_config.remote.ssh_config!=NULL) {
9292
ssh_argv[ssh_argc++]= (char*)"-F";
93-
ssh_argv[ssh_argc++]=ssh_config;
93+
ssh_argv[ssh_argc++]=instance_config.remote.ssh_config;
9494
}
95-
if (ssh_options!=NULL) {
96-
ssh_argc=split_options(ssh_argc,ssh_argv,MAX_CMDLINE_OPTIONS,ssh_options);
95+
if (instance_config.remote.ssh_options!=NULL) {
96+
ssh_argc=split_options(ssh_argc,ssh_argv,MAX_CMDLINE_OPTIONS,instance_config.remote.ssh_options);
9797
}
98-
ssh_argv[ssh_argc++]=remote_host;
98+
ssh_argv[ssh_argc++]=instance_config.remote.host;
9999
ssh_argv[ssh_argc++]=cmd;
100100
ssh_argv[ssh_argc]=NULL;
101101

102-
if (remote_path)
102+
if (instance_config.remote.path)
103103
{
104104
char*sep=strrchr(pg_probackup,'/');
105105
if (sep!=NULL) {
106106
pg_probackup=sep+1;
107107
}
108-
dst=snprintf(cmd,sizeof(cmd),"%s/%s",remote_path,pg_probackup);
108+
dst=snprintf(cmd,sizeof(cmd),"%s/%s",instance_config.remote.path,pg_probackup);
109109
}else {
110110
dst=snprintf(cmd,sizeof(cmd),"%s",pg_probackup);
111111
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp