From 278c94209b90b8e241f64ea4ce2d955b63b1f5d7 Mon Sep 17 00:00:00 2001
From: Robert Haas <rhaas@postgresql.org>
Date: Tue, 25 Feb 2014 11:23:45 -0500
Subject: [PATCH] pg_basebackup: Skip only the *contents* of pg_replslot.

Include the directory itself.

Fujii Masao
---
 src/backend/replication/basebackup.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/src/backend/replication/basebackup.c b/src/backend/replication/basebackup.c
index 06e54bc530e..2bbe384e351 100644
--- a/src/backend/replication/basebackup.c
+++ b/src/backend/replication/basebackup.c
@@ -862,10 +862,6 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
 		if (strcmp(de->d_name, BACKUP_LABEL_FILE) == 0)
 			continue;
 
-		/* Skip pg_replslot, not useful to copy */
-		if (strcmp(de->d_name, "pg_replslot") == 0)
-			continue;
-
 		/*
 		 * Check if the postmaster has signaled us to exit, and abort with an
 		 * error in that case. The error handler further up will call
@@ -920,6 +916,18 @@ sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces)
 			continue;
 		}
 
+		/*
+		 * Skip pg_replslot, not useful to copy. But include it as an empty
+		 * directory anyway, so we get permissions right.
+		 */
+		if (strcmp(de->d_name, "pg_replslot") == 0)
+		{
+			if (!sizeonly)
+				_tarWriteHeader(pathbuf + basepathlen + 1, NULL, &statbuf);
+			size += 512;		/* Size of the header just added */
+			continue;
+		}
+
 		/*
 		 * We can skip pg_xlog, the WAL segments need to be fetched from the
 		 * WAL archive anyway. But include it as an empty directory anyway, so
-- 
GitLab