From 9f8c13a2c01f7c7a3a983099ee474c65e0b16896 Mon Sep 17 00:00:00 2001
From: Peter Smith <peter.b.smith@fujitsu.com>
Date: Mon, 10 Nov 2025 14:51:30 +1100
Subject: [PATCH v4] log to say command is executing in dry run mode

---
 src/bin/pg_archivecleanup/pg_archivecleanup.c | 3 +++
 src/bin/pg_basebackup/pg_createsubscriber.c   | 4 ++++
 src/bin/pg_combinebackup/pg_combinebackup.c   | 3 +++
 src/bin/pg_resetwal/pg_resetwal.c             | 3 +++
 src/bin/pg_rewind/pg_rewind.c                 | 9 +++++++--
 5 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/src/bin/pg_archivecleanup/pg_archivecleanup.c b/src/bin/pg_archivecleanup/pg_archivecleanup.c
index c25348b..d09b761 100644
--- a/src/bin/pg_archivecleanup/pg_archivecleanup.c
+++ b/src/bin/pg_archivecleanup/pg_archivecleanup.c
@@ -375,6 +375,9 @@ main(int argc, char **argv)
 		exit(2);
 	}
 
+	if (dryrun)
+		pg_log_info("Executing in dry-run mode.\nNo files will be removed.");
+
 	/*
 	 * Check archive exists and other initialization if required.
 	 */
diff --git a/src/bin/pg_basebackup/pg_createsubscriber.c b/src/bin/pg_basebackup/pg_createsubscriber.c
index df41836..7aca319 100644
--- a/src/bin/pg_basebackup/pg_createsubscriber.c
+++ b/src/bin/pg_basebackup/pg_createsubscriber.c
@@ -2305,6 +2305,10 @@ main(int argc, char **argv)
 		pg_log_error_hint("Try \"%s --help\" for more information.", progname);
 		exit(1);
 	}
+
+	if (dry_run)
+		pg_log_info("Executing in dry-run mode.\nThe target directory will not be modified.");
+
 	pg_log_info("validating publisher connection string");
 	pub_base_conninfo = get_base_conninfo(opt.pub_conninfo_str,
 										  &dbname_conninfo);
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c b/src/bin/pg_combinebackup/pg_combinebackup.c
index 3a32512..670205e 100644
--- a/src/bin/pg_combinebackup/pg_combinebackup.c
+++ b/src/bin/pg_combinebackup/pg_combinebackup.c
@@ -242,6 +242,9 @@ main(int argc, char *argv[])
 	if (opt.no_manifest)
 		opt.manifest_checksums = CHECKSUM_TYPE_NONE;
 
+	if (opt.dry_run)
+		pg_log_info("Executing in dry-run mode.\nThe target directory will not be modified.");
+
 	/* Check that the platform supports the requested copy method. */
 	if (opt.copy_method == COPY_METHOD_CLONE)
 	{
diff --git a/src/bin/pg_resetwal/pg_resetwal.c b/src/bin/pg_resetwal/pg_resetwal.c
index a89d72f..b8139d5 100644
--- a/src/bin/pg_resetwal/pg_resetwal.c
+++ b/src/bin/pg_resetwal/pg_resetwal.c
@@ -397,6 +397,9 @@ main(int argc, char *argv[])
 		exit(1);
 	}
 
+	if (noupdate)
+		printf(_("Executing in dry-run mode.\nNothing will be modified."));
+
 	/*
 	 * Attempt to read the existing pg_control file
 	 */
diff --git a/src/bin/pg_rewind/pg_rewind.c b/src/bin/pg_rewind/pg_rewind.c
index 27c514f..d4fcfef 100644
--- a/src/bin/pg_rewind/pg_rewind.c
+++ b/src/bin/pg_rewind/pg_rewind.c
@@ -301,8 +301,13 @@ main(int argc, char **argv)
 	atexit(disconnect_atexit);
 
 	/*
-	 * Ok, we have all the options and we're ready to start. First, connect to
-	 * remote server.
+	 * Ok, we have all the options and we're ready to start.
+	 */
+	if (dry_run)
+		pg_log_info("Executing in dry-run mode.\nThe target directory will not be modified.");
+
+	/*
+	 * First, connect to remote server.
 	 */
 	if (connstr_source)
 	{
-- 
1.8.3.1

