Log a note at program start when running in dry-run mode
authorÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 18 Nov 2025 15:13:29 +0000 (16:13 +0100)
committerÁlvaro Herrera <alvherre@kurilemu.de>
Tue, 18 Nov 2025 15:13:29 +0000 (16:13 +0100)
Users might get some peace of mind knowing their data is not being
destroyed or whatever.

Author: Peter Smith <smithpb2250@gmail.com>
Reviewed-by: Álvaro Herrera <alvherre@kurilemu.de>
Discussion: https://postgr.es/m/CAHut+PsvQJQnQO0KT0S2oegenkvJ8FUuY-QS5syyqmT24R2xFQ@mail.gmail.com

src/bin/pg_archivecleanup/pg_archivecleanup.c
src/bin/pg_basebackup/pg_createsubscriber.c
src/bin/pg_combinebackup/pg_combinebackup.c
src/bin/pg_rewind/pg_rewind.c

index c25348bcb85ddb098b8359c4a0034b6a14a891e6..ab686b4748ca43b976afd58ba8743267010146af 100644 (file)
@@ -375,6 +375,10 @@ main(int argc, char **argv)
        exit(2);
    }
 
+   if (dryrun)
+       pg_log_info("Executing in dry-run mode.\n"
+                   "No files will be removed.");
+
    /*
     * Check archive exists and other initialization if required.
     */
index df41836e70f05246d36ac632fe4529c98f1f6d47..cc4be5d6ef477c96c86a59bff67003327f6d6ecf 100644 (file)
@@ -2305,6 +2305,11 @@ 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.\n"
+                   "The 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);
index 3a325127209216dc24cb86b94b431a0c0c9e17ce..c9bf0a9e1055c28187d76e7fe9b0b5be9e8399cd 100644 (file)
@@ -242,6 +242,10 @@ 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.\n"
+                   "The target directory will not be modified.");
+
    /* Check that the platform supports the requested copy method. */
    if (opt.copy_method == COPY_METHOD_CLONE)
    {
index 27c514f934a3fe9aa80977139b29f706c45bc685..e9364d04f76e77e3277039470635e9a0a7e33942 100644 (file)
@@ -300,10 +300,12 @@ 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.\n"
+                   "The target directory will not be modified.");
+
+   /* First, connect to remote server. */
    if (connstr_source)
    {
        conn = PQconnectdb(connstr_source);