Skip to content

Commit e9af504

Browse files
committed
Added --primary-conninfo option for restoring as replica
1 parent 9c662d5 commit e9af504

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/pg_probackup.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ static bool target_immediate;
9090
static char *target_name = NULL;
9191
static char *target_action = NULL;
9292

93+
static char *primary_conninfo = NULL;
94+
9395
static pgRecoveryTarget *recovery_target_options = NULL;
9496
static pgRestoreParams *restore_params = NULL;
9597

@@ -191,6 +193,7 @@ static ConfigOption cmd_options[] =
191193
{ 'b', 156, "skip-external-dirs", &skip_external_dirs, SOURCE_CMD_STRICT },
192194
{ 'f', 158, "db-include", opt_datname_include_list, SOURCE_CMD_STRICT },
193195
{ 'f', 159, "db-exclude", opt_datname_exclude_list, SOURCE_CMD_STRICT },
196+
{ 's', 160, "primary-conninfo", &primary_conninfo, SOURCE_CMD_STRICT },
194197
/* checkdb options */
195198
{ 'b', 195, "amcheck", &need_amcheck, SOURCE_CMD_STRICT },
196199
{ 'b', 196, "heapallindexed", &heapallindexed, SOURCE_CMD_STRICT },
@@ -675,6 +678,7 @@ main(int argc, char *argv[])
675678
restore_params->skip_external_dirs = skip_external_dirs;
676679
restore_params->partial_db_list = NULL;
677680
restore_params->partial_restore_type = NONE;
681+
restore_params->primary_conninfo = primary_conninfo;
678682

679683
/* handle partial restore parameters */
680684
if (datname_exclude_list && datname_include_list)

src/pg_probackup.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,7 @@ typedef struct pgRestoreParams
423423
/* options for partial restore */
424424
PartialRestoreType partial_restore_type;
425425
parray *partial_db_list;
426+
const char *primary_conninfo;
426427
} pgRestoreParams;
427428

428429
/* Options needed for set-backup command */

src/restore.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,12 @@ create_recovery_conf(time_t backup_id,
10691069
fio_fprintf(fp, "standby_mode = 'on'\n");
10701070
#endif
10711071

1072-
if (backup->primary_conninfo)
1073-
fio_fprintf(fp, "primary_conninfo = '%s'\n", backup->primary_conninfo);
1072+
if(params->primary_conninfo)
1073+
fio_fprintf(fp, "primary_conninfo = '%s'\n", params->primary_conninfo);
1074+
else{
1075+
if (backup->primary_conninfo)
1076+
fio_fprintf(fp, "primary_conninfo = '%s'\n", backup->primary_conninfo);
1077+
}
10741078
}
10751079

10761080
if (pitr_requested)

0 commit comments

Comments
 (0)