- BASE_BACKUP [LABEL 'label' ] [PROGRESS ] [FAST ] [WAL ]
+ BASE_BACKUP [LABEL 'label' ] [PROGRESS ] [FAST ] [WAL ] [NOWAIT ]
Instructs the server to start streaming a base backup.
+
+
+ NOWAIT
+
+ By default, the backup will wait until the last required xlog
+ segment has been archived, or emit a warning if log archiving is
+ not enabled. Specifying NOWAIT disables both
+ the waiting and the warning, leaving the client responsible for
+ ensuring the required log is available.
+
+
+
XLogRecPtr stoppoint;
char stopxlogstr[MAXFNAMELEN];
- stoppoint = do_pg_stop_backup(NULL);
+ stoppoint = do_pg_stop_backup(NULL, true );
snprintf(stopxlogstr, sizeof(stopxlogstr), "%X/%X",
stoppoint.xlogid, stoppoint.xrecoff);
* the non-exclusive backup specified by 'labelfile'.
*/
XLogRecPtr
-do_pg_stop_backup(char *labelfile)
+do_pg_stop_backup(char *labelfile, bool waitforarchive )
{
bool exclusive = (labelfile == NULL);
XLogRecPtr startpoint;
* wish to wait, you can set statement_timeout. Also, some notices are
* issued to clue in anyone who might be doing this interactively.
*/
- if (XLogArchivingActive())
+ if (waitforarchive && XLogArchivingActive())
{
XLByteToPrevSeg(stoppoint, _logId, _logSeg);
XLogFileName(lastxlogfilename, ThisTimeLineID, _logId, _logSeg);
ereport(NOTICE,
(errmsg("pg_stop_backup complete, all required WAL segments have been archived")));
}
- else
+ else if (waitforarchive)
ereport(NOTICE,
(errmsg("WAL archiving is not enabled; you must ensure that all required WAL segments are copied through other means to complete the backup")));
const char *label;
bool progress;
bool fastcheckpoint;
+ bool nowait;
bool includewal;
} basebackup_options;
}
PG_END_ENSURE_ERROR_CLEANUP(base_backup_cleanup, (Datum) 0);
- endptr = do_pg_stop_backup(labelfile);
+ endptr = do_pg_stop_backup(labelfile, !opt->nowait );
if (opt->includewal)
{
bool o_label = false;
bool o_progress = false;
bool o_fast = false;
+ bool o_nowait = false;
bool o_wal = false;
MemSet(opt, 0, sizeof(*opt));
opt->fastcheckpoint = true;
o_fast = true;
}
+ else if (strcmp(defel->defname, "nowait") == 0)
+ {
+ if (o_nowait)
+ ereport(ERROR,
+ (errcode(ERRCODE_SYNTAX_ERROR),
+ errmsg("duplicate option \"%s\"", defel->defname)));
+ opt->nowait = true;
+ o_nowait = true;
+ }
else if (strcmp(defel->defname, "wal") == 0)
{
if (o_wal)
%token K_LABEL
%token K_PROGRESS
%token K_FAST
+%token K_NOWAIT
%token K_WAL
%token K_START_REPLICATION
;
/*
- * BASE_BACKUP [LABEL ''] [PROGRESS] [FAST] [WAL]
+ * BASE_BACKUP [LABEL ''] [PROGRESS] [FAST] [WAL] [NOWAIT]
*/
base_backup:
K_BASE_BACKUP base_backup_opt_list
$$ = makeDefElem("wal",
(Node *)makeInteger(TRUE));
}
+ | K_NOWAIT
+ {
+ $$ = makeDefElem("nowait",
+ (Node *)makeInteger(TRUE));
+ }
;
/*
FAST { return K_FAST; }
IDENTIFY_SYSTEM { return K_IDENTIFY_SYSTEM; }
LABEL { return K_LABEL; }
+NOWAIT { return K_NOWAIT; }
PROGRESS { return K_PROGRESS; }
WAL { return K_WAL; }
START_REPLICATION { return K_START_REPLICATION; }
* Starting/stopping a base backup
*/
extern XLogRecPtr do_pg_start_backup(const char *backupidstr, bool fast, char **labelfile);
-extern XLogRecPtr do_pg_stop_backup(char *labelfile);
+extern XLogRecPtr do_pg_stop_backup(char *labelfile, bool waitforarchive );
extern void do_pg_abort_backup(void);
/* File path names (all relative to $PGDATA) */