@@ -215,16 +215,6 @@ do_backup_database(parray *backup_list)
215215 */
216216if (current .backup_mode == BACKUP_MODE_DIFF_PAGE )
217217{
218- /*
219- * Switch to a new WAL segment. It is necessary to get archived WAL
220- * segment, which includes start LSN of current backup.
221- *
222- * Do not switch for standby node and if backup is stream.
223- */
224- if (!from_replica && !stream_wal )
225- pg_switch_wal ();
226- if (!stream_wal )
227- wait_archive_lsn (current .start_lsn , false);
228218/*
229219 * Build the page map. Obtain information about changed pages
230220 * reading WAL segments present in archives up to the point
@@ -593,6 +583,17 @@ pg_start_backup(const char *label, bool smooth, pgBackup *backup)
593583backup -> start_lsn = (XLogRecPtr ) ((uint64 )xlogid <<32 ) |xrecoff ;
594584
595585PQclear (res );
586+
587+ /*
588+ * Switch to a new WAL segment. It is necessary to get archived WAL
589+ * segment, which includes start LSN of current backup.
590+ *
591+ * Do not switch for standby node and if backup is stream.
592+ */
593+ if (!from_replica && !stream_wal )
594+ pg_switch_wal ();
595+ if (!stream_wal )
596+ wait_archive_lsn (backup -> start_lsn , false);
596597}
597598
598599/*