1+ diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
2+ index 34a2c71812..2d73d8023e 100644
3+ --- a/src/backend/access/transam/xlog.c
4+ +++ b/src/backend/access/transam/xlog.c
5+ @@ -135,6 +135,7 @@ intwal_retrieve_retry_interval = 5000;
6+ intmax_slot_wal_keep_size_mb = -1;
7+ intwal_decode_buffer_size = 512 * 1024;
8+ booltrack_wal_io_timing = false;
9+ + backup_checkpoint_request_hook_type backup_checkpoint_request_hook = NULL;
10+
11+ #ifdef WAL_DEBUG
12+ boolXLOG_DEBUG = false;
13+ @@ -8801,6 +8802,12 @@ do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces,
14+ {
15+ boolcheckpointfpw;
16+
17+ + /*
18+ + * Before we call RequestCheckpoint() we need to set
19+ + * init_lsn for ptrack map
20+ + */
21+ + if (backup_checkpoint_request_hook)
22+ + backup_checkpoint_request_hook();
23+ /*
24+ * Force a CHECKPOINT. Aside from being necessary to prevent torn
25+ * page problems, this guarantees that two successive backup runs
126diff --git a/src/backend/backup/basebackup.c b/src/backend/backup/basebackup.c
2- index5fbbe5ffd20..3c9b99f851d 100644
27+ index9a2bf59e84..ade9115651 100644
328--- a/src/backend/backup/basebackup.c
429+++ b/src/backend/backup/basebackup.c
530@@ -220,6 +220,13 @@ static const struct exclude_list_item excludeFiles[] =
@@ -17,7 +42,7 @@ index 5fbbe5ffd20..3c9b99f851d 100644
1742 {NULL, false}
1843 };
1944diff --git a/src/backend/storage/file/copydir.c b/src/backend/storage/file/copydir.c
20- indexd4fbe542077..b108416c708 100644
45+ indexd4fbe54207..b108416c70 100644
2146--- a/src/backend/storage/file/copydir.c
2247+++ b/src/backend/storage/file/copydir.c
2348@@ -27,6 +27,8 @@
@@ -40,7 +65,7 @@ index d4fbe542077..b108416c708 100644
4065 * Be paranoid here and fsync all files to ensure the copy is really done.
4166 * But if fsync is disabled, we're done.
4267diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c
43- indexbf0f3ca76d1..7d9833a3604 100644
68+ indexbf0f3ca76d..7d9833a360 100644
4469--- a/src/backend/storage/smgr/md.c
4570+++ b/src/backend/storage/smgr/md.c
4671@@ -85,6 +85,8 @@ typedef struct _MdfdVec
@@ -92,7 +117,7 @@ index bf0f3ca76d1..7d9833a3604 100644
92117 }
93118
94119diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
95- indexab7137d0fff..bc40a763c05 100644
120+ indexab7137d0ff..bc40a763c0 100644
96121--- a/src/backend/storage/sync/sync.c
97122+++ b/src/backend/storage/sync/sync.c
98123@@ -74,6 +74,8 @@ static MemoryContext pendingOpsCxt; /* context for the above */
@@ -115,7 +140,7 @@ index ab7137d0fff..bc40a763c05 100644
115140 sync_in_progress = false;
116141 }
117142diff --git a/src/bin/pg_checksums/pg_checksums.c b/src/bin/pg_checksums/pg_checksums.c
118- index9e6fd435f60..f2180b9f6de 100644
143+ index9e6fd435f6..f2180b9f6d 100644
119144--- a/src/bin/pg_checksums/pg_checksums.c
120145+++ b/src/bin/pg_checksums/pg_checksums.c
121146@@ -110,6 +110,11 @@ static const struct exclude_list_item skip[] = {
@@ -131,7 +156,7 @@ index 9e6fd435f60..f2180b9f6de 100644
131156 {"config_exec_params", true},
132157 #endif
133158diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
134- indexe9dcb5a6d89..844b04d5e12 100644
159+ indexe9dcb5a6d8..844b04d5e1 100644
135160--- a/src/bin/pg_resetwal/pg_resetwal.c
136161+++ b/src/bin/pg_resetwal/pg_resetwal.c
137162@@ -86,6 +86,7 @@ static void FindEndOfXLOG(void);
@@ -193,10 +218,10 @@ index e9dcb5a6d89..844b04d5e12 100644
193218 /*
194219 * Remove existing archive status files
195220diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c
196- index255ddf2ffaf..1142c244926 100644
221+ index4458324c9d..7d857467f7 100644
197222--- a/src/bin/pg_rewind/filemap.c
198223+++ b/src/bin/pg_rewind/filemap.c
199- @@ -157 ,6 +157 ,10 @@ static const struct exclude_list_item excludeFiles[] =
224+ @@ -156 ,6 +156 ,10 @@ static const struct exclude_list_item excludeFiles[] =
200225 {"postmaster.pid", false},
201226 {"postmaster.opts", false},
202227
@@ -207,8 +232,22 @@ index 255ddf2ffaf..1142c244926 100644
207232 /* end of list */
208233 {NULL, false}
209234 };
235+ diff --git a/src/include/access/xlog.h b/src/include/access/xlog.h
236+ index 76787a8267..2c662f4022 100644
237+ --- a/src/include/access/xlog.h
238+ +++ b/src/include/access/xlog.h
239+ @@ -57,6 +57,9 @@ extern PGDLLIMPORT int wal_decode_buffer_size;
240+
241+ extern PGDLLIMPORT int CheckPointSegments;
242+
243+ + typedef void (*backup_checkpoint_request_hook_type) (void);
244+ + extern PGDLLIMPORT backup_checkpoint_request_hook_type backup_checkpoint_request_hook;
245+ +
246+ /* Archive modes */
247+ typedef enum ArchiveMode
248+ {
210249diff --git a/src/include/storage/copydir.h b/src/include/storage/copydir.h
211- indexa25e258f479..b20b9c76e8d 100644
250+ indexa25e258f47..b20b9c76e8 100644
212251--- a/src/include/storage/copydir.h
213252+++ b/src/include/storage/copydir.h
214253@@ -13,6 +13,9 @@
@@ -222,7 +261,7 @@ index a25e258f479..b20b9c76e8d 100644
222261 extern void copy_file(const char *fromfile, const char *tofile);
223262
224263diff --git a/src/include/storage/md.h b/src/include/storage/md.h
225- index620f10abdeb..b36936871bd 100644
264+ index620f10abde..b36936871b 100644
226265--- a/src/include/storage/md.h
227266+++ b/src/include/storage/md.h
228267@@ -19,6 +19,13 @@
@@ -240,7 +279,7 @@ index 620f10abdeb..b36936871bd 100644
240279 extern void mdinit(void);
241280 extern void mdopen(SMgrRelation reln);
242281diff --git a/src/include/storage/sync.h b/src/include/storage/sync.h
243- index9dee8fa6e5b..348ed53e4e2 100644
282+ index9dee8fa6e5..348ed53e4e 100644
244283--- a/src/include/storage/sync.h
245284+++ b/src/include/storage/sync.h
246285@@ -55,6 +55,9 @@ typedef struct FileTag