This is an automated email from the ASF dual-hosted git repository.
chenjinbao1989 pushed a commit to branch cbdb-postgres-merge
in repository https://gitbox.apache.org/repos/asf/cloudberry.git
The following commit(s) were added to refs/heads/cbdb-postgres-merge by this
push:
new 60b73a04854 Delete exist path in basebackup
60b73a04854 is described below
commit 60b73a04854f70e5add068378cc791524543db66
Author: Jinbao Chen <[email protected]>
AuthorDate: Wed Feb 4 09:20:09 2026 +0800
Delete exist path in basebackup
---
src/bin/pg_basebackup/bbstreamer_file.c | 20 ++++++++++++++++++++
src/bin/pg_basebackup/pg_basebackup.c | 14 ++++++++++++++
2 files changed, 34 insertions(+)
diff --git a/src/bin/pg_basebackup/bbstreamer_file.c
b/src/bin/pg_basebackup/bbstreamer_file.c
index 45f32974ff6..ec76084c8d4 100644
--- a/src/bin/pg_basebackup/bbstreamer_file.c
+++ b/src/bin/pg_basebackup/bbstreamer_file.c
@@ -315,6 +315,26 @@ should_allow_existing_directory(const char *pathname)
static void
extract_directory(const char *filename, mode_t mode)
{
+ /* MERGE16_FIXME: We should test forceoverwrite here ? */
+ if (pg_check_dir(filename) != 0)
+ {
+ /*
+ * We want to retain the contents of pg_log. And for
+ * pg_xlog we assume is deleted at the start of
+ * pg_basebackup. We cannot delete pg_xlog because if
+ * streammode was used then it may have already copied
+ * new xlog files into pg_xlog directory.
+ */
+ if (pg_str_endswith(filename, "/pg_log") ||
+ pg_str_endswith(filename, "/log") ||
+ pg_str_endswith(filename, "/pg_wal") ||
+ pg_str_endswith(filename, "/pg_xlog"))
+ return;
+
+ rmtree(filename, true);
+ }
+
+
if (mkdir(filename, pg_dir_create_mode) != 0 &&
(errno != EEXIST || !should_allow_existing_directory(filename)))
pg_fatal("could not create directory \"%s\": %m",
diff --git a/src/bin/pg_basebackup/pg_basebackup.c
b/src/bin/pg_basebackup/pg_basebackup.c
index 10c4cfd2991..d6ed714c506 100644
--- a/src/bin/pg_basebackup/pg_basebackup.c
+++ b/src/bin/pg_basebackup/pg_basebackup.c
@@ -2108,6 +2108,16 @@ BaseBackup(char *compression_algorithm, char
*compression_detail,
if (pg_check_dir(xlog_path) != 0)
rmtree(xlog_path, true);
+
+ snprintf(xlog_path, MAXPGPATH, "%s/%s", basedir,
"pg_distributedlog");
+
+ if (pg_check_dir(xlog_path) != 0)
+ rmtree(xlog_path, true);
+
+ snprintf(xlog_path, MAXPGPATH, "%s/%s", basedir, "pg_notify");
+
+ if (pg_check_dir(xlog_path) != 0)
+ rmtree(xlog_path, true);
}
/*
@@ -2142,6 +2152,7 @@ BaseBackup(char *compression_algorithm, char
*compression_detail,
{
/* Receive a single tar stream with everything. */
ReceiveArchiveStream(conn, client_compress);
+ WriteInternalConfFile();
}
else
{
@@ -2174,7 +2185,10 @@ BaseBackup(char *compression_algorithm, char
*compression_detail,
ReceiveTarFile(conn, archive_name, spclocation, i,
client_compress);
}
+
+ WriteInternalConfFile();
+
/*
* Now receive backup manifest, if appropriate.
*
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]