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

Commitaf0e674

Browse files
committed
Add automatic detect of replica and remove same option.
1 parentf0703e5 commitaf0e674

File tree

4 files changed

+22
-6
lines changed

4 files changed

+22
-6
lines changed

‎backup.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ static void get_lsn(PGconn *conn, PGresult *res, XLogRecPtr *lsn, bool stop_back
6666
staticvoidget_xid(PGresult*res,uint32*xid);
6767
staticvoidpg_ptrack_clear(void);
6868
staticboolpg_ptrack_support(void);
69+
staticboolpg_is_in_recovery(void);
6970
staticchar*pg_ptrack_get_and_clear(Oidtablespace_oid,
7071
Oiddb_oid,
7172
Oidrel_oid,
@@ -115,6 +116,7 @@ do_backup_database(parray *backup_list, pgBackupOption bkupopt)
115116
pgBackup*prev_backup=NULL;
116117

117118
/* Block backup operations on a standby */
119+
from_replica=pg_is_in_recovery();
118120
if (pg_is_standby()&& !from_replica)
119121
elog(ERROR,"Backup cannot run on a standby.");
120122

@@ -653,9 +655,29 @@ pg_ptrack_support(void)
653655
disconnect();
654656
return false;
655657
}
658+
PQclear(res_db);
659+
disconnect();
656660
return true;
657661
}
658662

663+
staticbool
664+
pg_is_in_recovery(void)
665+
{
666+
PGresult*res_db;
667+
reconnect();
668+
res_db=execute("SELECT pg_is_in_recovery()",0,NULL);
669+
670+
if (PQgetvalue(res_db,0,0)[0]=='t')
671+
{
672+
PQclear(res_db);
673+
disconnect();
674+
return true;
675+
}
676+
PQclear(res_db);
677+
disconnect();
678+
return false;
679+
}
680+
659681
staticvoid
660682
pg_ptrack_clear(void)
661683
{

‎doc/pg_arman.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,9 +246,6 @@ absolute paths; relative paths are not allowed.
246246
**--stream**:
247247
Enable stream replication for save WAL during backup process.
248248

249-
**--from-replica**:
250-
Use non exclusive start backup for replica. Only for 9.6 and higher.
251-
252249

253250
###RESTORE OPTIONS
254251

‎expected/option.out

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ Backup options:
2626
--keep-data-generations=N keep GENERATION of full data backup
2727
--keep-data-days=DAY keep enough data backup to recover to DAY days age
2828
--backup-pg-log start backup pg_log directory
29-
--from-replica use non exclusive start backup for replica
3029

3130
Restore options:
3231
--recovery-target-time time stamp up to which recovery will proceed

‎pg_arman.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ static pgut_option options[] =
6767
{'b',10,"backup-pg-log",&backup_logs },
6868
{'f','b',"backup-mode",opt_backup_mode,SOURCE_ENV },
6969
{'b','C',"smooth-checkpoint",&smooth_checkpoint,SOURCE_ENV },
70-
{'b',12,"from-replica",&from_replica },
7170
/* options with only long name (keep-xxx) */
7271
{'i',1,"keep-data-generations",&keep_data_generations,SOURCE_ENV },
7372
{'i',2,"keep-data-days",&keep_data_days,SOURCE_ENV },
@@ -247,7 +246,6 @@ pgut_help(bool details)
247246
printf(_(" --keep-data-generations=N keep GENERATION of full data backup\n"));
248247
printf(_(" --keep-data-days=DAY keep enough data backup to recover to DAY days age\n"));
249248
printf(_(" --backup-pg-log start backup pg_log directory\n"));
250-
printf(_(" --from-replica use non exclusive start backup for replica\n"));
251249
printf(_("\nRestore options:\n"));
252250
printf(_(" --recovery-target-time time stamp up to which recovery will proceed\n"));
253251
printf(_(" --recovery-target-xid transaction ID up to which recovery will proceed\n"));

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp