Thanks for taking a look.  Here is a v2.

On Fri, Dec 04, 2026 at 08:34:09AM +0800, Xueyu Gao wrote:
> The help output loses the indication that copy is the default.

Good catch.  Fixed.

On Fri, Dec 04, 2026 at 09:12:52AM +0100, Jakub Wartak wrote:
> +1 too. We could also just fprintf(stderr) some info that the --link/--clone
> are deprecated too and users should switch to --transfer-mode=XXX in future.

I don't think we want to do that.  AFAICT none of our other deprecated
options (e.g., pg_dump's --blobs) emit a warning, and since I doubt we'll
ever remove these, it'd just be noise for folks with existing scripts.

> I would like it to have it the same way.

0002 gives pg_combinebackup the same treatment.

-- 
nathan
>From 16f4d60783e848b49746ca9ff613bdd45cd9f34c Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 4 Dec 2026 09:48:18 -0600
Subject: [PATCH v2 1/2] pg_upgrade: Add --transfer-mode.

pg_upgrade has a separate option for each of its file transfer
modes (--clone, --copy, --copy-file-range, --link, and --swap),
even though only one mode can be used at a time.  This commit adds
a new --transfer-mode option that accepts the mode as its argument
(e.g., --transfer-mode=link).  The existing options are now
documented as deprecated spellings of the new one, but they
continue to work as before, and it seems unlikely that we'll ever
be able to remove them.

Reviewed-by: Xueyu Gao <[email protected]>
Reviewed-by: Jakub Wartak <[email protected]>
Discussion: https://postgr.es/m/axGSXghPd_TNT5qZ%40nathan
---
 doc/src/sgml/ref/pgupgrade.sgml            | 158 ++++++++++++++-------
 doc/src/sgml/runtime.sgml                  |   2 +-
 src/bin/pg_upgrade/option.c                |  30 +++-
 src/bin/pg_upgrade/t/006_transfer_modes.pl |  12 +-
 4 files changed, 141 insertions(+), 61 deletions(-)

diff --git a/doc/src/sgml/ref/pgupgrade.sgml b/doc/src/sgml/ref/pgupgrade.sgml
index e4e8c02e6d6..d492420bc3b 100644
--- a/doc/src/sgml/ref/pgupgrade.sgml
+++ b/doc/src/sgml/ref/pgupgrade.sgml
@@ -133,8 +133,11 @@ PostgreSQL documentation
      <varlistentry>
       <term><option>-k</option></term>
       <term><option>--link</option></term>
-      <listitem><para>use hard links instead of copying files to the new
-      cluster</para></listitem>
+      <listitem>
+       <para>
+        Deprecated spelling of <option>--transfer-mode=link</option>.
+       </para>
+      </listitem>
      </varlistentry>
 
      <varlistentry>
@@ -221,19 +224,7 @@ PostgreSQL documentation
       <term><option>--clone</option></term>
       <listitem>
        <para>
-        Use efficient file cloning (also known as <quote>reflinks</quote> on
-        some systems) instead of copying files to the new cluster.  This can
-        result in near-instantaneous copying of the data files, giving the
-        speed advantages of <option>-k</option>/<option>--link</option> while
-        leaving the old cluster untouched.
-       </para>
-
-       <para>
-        File cloning is only supported on some operating systems and file
-        systems.  If it is selected but not supported, the
-        <application>pg_upgrade</application> run will error.  At present, it
-        is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on
-        file systems created with reflink support), and on macOS with APFS.
+        Deprecated spelling of <option>--transfer-mode=clone</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -242,9 +233,7 @@ PostgreSQL documentation
       <term><option>--copy</option></term>
       <listitem>
        <para>
-        Copy files to the new cluster.  This is the default.  (See also
-        <option>--link</option>, <option>--clone</option>,
-        <option>--copy-file-range</option>, and <option>--swap</option>.)
+        Deprecated spelling of <option>--transfer-mode=copy</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -253,11 +242,8 @@ PostgreSQL documentation
       <term><option>--copy-file-range</option></term>
       <listitem>
        <para>
-        Use the <function>copy_file_range</function> system call for efficient
-        copying.  On some file systems this gives results similar to
-        <option>--clone</option>, sharing physical disk blocks, while on others
-        it may still copy blocks, but do so via an optimized path.  At present,
-        it is supported on Linux and FreeBSD.
+        Deprecated spelling of
+        <option>--transfer-mode=copy-file-range</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -328,24 +314,7 @@ PostgreSQL documentation
       <term><option>--swap</option></term>
       <listitem>
        <para>
-        Move the data directories from the old cluster to the new cluster.
-        Then, replace the catalog files with those generated for the new
-        cluster.  This mode can outperform <option>--link</option>,
-        <option>--clone</option>, <option>--copy</option>, and
-        <option>--copy-file-range</option>, especially on clusters with many
-        relations.
-       </para>
-       <para>
-        However, this mode creates many garbage files in the old cluster, which
-        can prolong the file synchronization step if
-        <option>--sync-method=syncfs</option> is used.  Therefore, it is
-        recommended to use <option>--sync-method=fsync</option> with
-        <option>--swap</option>.
-       </para>
-       <para>
-        Additionally, once the file transfer step begins, the old cluster will
-        be destructively modified and therefore will no longer be safe to
-        start.  See <xref linkend="pgupgrade-step-revert"/> for details.
+        Deprecated spelling of <option>--transfer-mode=swap</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -373,6 +342,98 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      
<term><option>--transfer-mode=</option><replaceable>mode</replaceable></term>
+      <listitem>
+       <para>
+        Specifies how files are transferred from the old cluster to the new
+        cluster.  <replaceable>mode</replaceable> can be one of the following:
+
+        <variablelist>
+         <varlistentry>
+          <term><literal>clone</literal></term>
+          <listitem>
+           <para>
+            Use efficient file cloning (also known as <quote>reflinks</quote>
+            on some systems) instead of copying files to the new cluster.
+            This can result in near-instantaneous copying of the data files,
+            giving the speed advantages of <literal>link</literal> while
+            leaving the old cluster untouched.
+           </para>
+
+           <para>
+            File cloning is only supported on some operating systems and file
+            systems.  If it is selected but not supported, the
+            <application>pg_upgrade</application> run will error.  At
+            present, it is supported on Linux (kernel 4.5 or later) with Btrfs
+            and XFS (on file systems created with reflink support), and on
+            macOS with APFS.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>copy</literal></term>
+          <listitem>
+           <para>
+            Copy files to the new cluster.  This is the default.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>copy-file-range</literal></term>
+          <listitem>
+           <para>
+            Use the <function>copy_file_range</function> system call for
+            efficient copying.  On some file systems this gives results
+            similar to <literal>clone</literal>, sharing physical disk blocks,
+            while on others it may still copy blocks, but do so via an
+            optimized path.  At present, it is supported on Linux and FreeBSD.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>link</literal></term>
+          <listitem>
+           <para>
+            Use hard links instead of copying files to the new cluster.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>swap</literal></term>
+          <listitem>
+           <para>
+            Move the data directories from the old cluster to the new cluster.
+            Then, replace the catalog files with those generated for the new
+            cluster.  This mode can outperform <literal>link</literal>,
+            <literal>clone</literal>, <literal>copy</literal>, and
+            <literal>copy-file-range</literal>, especially on clusters with
+            many relations.
+           </para>
+           <para>
+            However, this mode creates many garbage files in the old cluster,
+            which can prolong the file synchronization step if
+            <option>--sync-method=syncfs</option> is used.  Therefore, it is
+            recommended to use <option>--sync-method=fsync</option> with
+            <literal>swap</literal>.
+           </para>
+           <para>
+            Additionally, once the file transfer step begins, the old cluster
+            will be destructively modified and therefore will no longer be
+            safe to start.  See <xref linkend="pgupgrade-step-revert"/> for
+            details.
+           </para>
+          </listitem>
+         </varlistentry>
+        </variablelist>
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
       <term><option>-?</option></term>
       <term><option>--help</option></term>
@@ -598,8 +659,7 @@ pg_upgrade.exe
      running. <command>pg_upgrade --check</command> will also outline any
      manual adjustments you will need to make after the upgrade.  If you
      are going to be using link, clone, copy-file-range, or swap mode, you
-     should use the option <option>--link</option>, <option>--clone</option>,
-     <option>--copy-file-range</option>, or <option>--swap</option> with
+     should use the option <option>--transfer-mode</option> with
      <option>--check</option> to enable mode-specific checks.
      <command>pg_upgrade</command> requires write permission in the current 
directory.
     </para>
@@ -890,15 +950,15 @@ psql --username=postgres --file=script.sql postgres
 
       <listitem>
        <para>
-        If neither <option>--link</option> nor <option>--swap</option> was
-        used, the old cluster was unmodified;  it can be restarted.
+        If neither link mode nor swap mode was used, the old cluster was
+        unmodified;  it can be restarted.
        </para>
       </listitem>
 
       <listitem>
        <para>
-        If the <option>--link</option> option was used, the data
-        files might be shared between the old and new cluster:
+        If link mode was used, the data files might be shared between the
+        old and new cluster:
 
         <itemizedlist>
          <listitem>
@@ -933,8 +993,8 @@ psql --username=postgres --file=script.sql postgres
 
       <listitem>
        <para>
-        If the <option>--swap</option> option was used, the old cluster might
-        be destructively modified:
+        If swap mode was used, the old cluster might be destructively
+        modified:
 
         <itemizedlist>
          <listitem>
diff --git a/doc/src/sgml/runtime.sgml b/doc/src/sgml/runtime.sgml
index daa87bfaa64..e38b1a7edd7 100644
--- a/doc/src/sgml/runtime.sgml
+++ b/doc/src/sgml/runtime.sgml
@@ -1928,7 +1928,7 @@ pg_dumpall -p 5432 | psql -d postgres -p 5433
     The <xref linkend="pgupgrade"/> module allows an installation to
     be migrated in-place from one major <productname>PostgreSQL</productname>
     version to another.  Upgrades can be performed in minutes,
-    particularly with <option>--link</option> mode.  It requires steps similar 
to
+    particularly with <option>--transfer-mode=link</option>.  It requires 
steps similar to
     <application>pg_dumpall</application> above, e.g.,  starting/stopping the 
server,
     running <application>initdb</application>.  The 
<application>pg_upgrade</application> <link
     linkend="pgupgrade">documentation</link> outlines the necessary steps.
diff --git a/src/bin/pg_upgrade/option.c b/src/bin/pg_upgrade/option.c
index 179eaf0d5e6..52ffeb7cecc 100644
--- a/src/bin/pg_upgrade/option.c
+++ b/src/bin/pg_upgrade/option.c
@@ -63,6 +63,7 @@ parseCommandLine(int argc, char *argv[])
                {"no-statistics", no_argument, NULL, 5},
                {"set-char-signedness", required_argument, NULL, 6},
                {"swap", no_argument, NULL, 7},
+               {"transfer-mode", required_argument, NULL, 8},
 
                {NULL, 0, NULL, 0}
        };
@@ -234,6 +235,21 @@ parseCommandLine(int argc, char *argv[])
                                user_opts.transfer_mode = TRANSFER_MODE_SWAP;
                                break;
 
+                       case 8:
+                               if (strcmp(optarg, "clone") == 0)
+                                       user_opts.transfer_mode = 
TRANSFER_MODE_CLONE;
+                               else if (strcmp(optarg, "copy") == 0)
+                                       user_opts.transfer_mode = 
TRANSFER_MODE_COPY;
+                               else if (strcmp(optarg, "copy-file-range") == 0)
+                                       user_opts.transfer_mode = 
TRANSFER_MODE_COPY_FILE_RANGE;
+                               else if (strcmp(optarg, "link") == 0)
+                                       user_opts.transfer_mode = 
TRANSFER_MODE_LINK;
+                               else if (strcmp(optarg, "swap") == 0)
+                                       user_opts.transfer_mode = 
TRANSFER_MODE_SWAP;
+                               else
+                                       pg_fatal("invalid argument for option 
%s", "--transfer-mode");
+                               break;
+
                        default:
                                fprintf(stderr, _("Try \"%s --help\" for more 
information.\n"),
                                                os_info.progname);
@@ -314,7 +330,7 @@ usage(void)
        printf(_("  -d, --old-datadir=DATADIR     old cluster data 
directory\n"));
        printf(_("  -D, --new-datadir=DATADIR     new cluster data 
directory\n"));
        printf(_("  -j, --jobs=NUM                number of simultaneous 
processes or threads to use\n"));
-       printf(_("  -k, --link                    link instead of copying files 
to new cluster\n"));
+       printf(_("  -k, --link                    (same as 
--transfer-mode=link, deprecated)\n"));
        printf(_("  -N, --no-sync                 do not wait for changes to be 
written safely to disk\n"));
        printf(_("  -o, --old-options=OPTIONS     old cluster options to pass 
to the server\n"));
        printf(_("  -O, --new-options=OPTIONS     new cluster options to pass 
to the server\n"));
@@ -325,14 +341,18 @@ usage(void)
        printf(_("  -U, --username=NAME           cluster superuser (default 
\"%s\")\n"), os_info.user);
        printf(_("  -v, --verbose                 enable verbose internal 
logging\n"));
        printf(_("  -V, --version                 display version information, 
then exit\n"));
-       printf(_("  --clone                       clone instead of copying 
files to new cluster\n"));
-       printf(_("  --copy                        copy files to new cluster 
(default)\n"));
-       printf(_("  --copy-file-range             copy files to new cluster 
with copy_file_range\n"));
+       printf(_("  --clone                       (same as 
--transfer-mode=clone, deprecated)\n"));
+       printf(_("  --copy                        (same as 
--transfer-mode=copy, deprecated)\n"));
+       printf(_("  --copy-file-range             (same as 
--transfer-mode=copy-file-range,\n"
+                        "                                deprecated)\n"));
        printf(_("  --no-statistics               do not import statistics from 
old cluster\n"));
        printf(_("  --set-char-signedness=OPTION  set new cluster char 
signedness to \"signed\" or\n"
                         "                                \"unsigned\"\n"));
-       printf(_("  --swap                        move data directories to new 
cluster\n"));
+       printf(_("  --swap                        (same as 
--transfer-mode=swap, deprecated)\n"));
        printf(_("  --sync-method=METHOD          set method for syncing files 
to disk\n"));
+       printf(_("  --transfer-mode=MODE          set file transfer mode to 
\"clone\",\n"
+                        "                                \"copy\" (default), 
\"copy-file-range\", \"link\",\n"
+                        "                                or \"swap\"\n"));
        printf(_("  -?, --help                    show this help, then 
exit\n"));
        printf(_("\n"
                         "Before running pg_upgrade you must:\n"
diff --git a/src/bin/pg_upgrade/t/006_transfer_modes.pl 
b/src/bin/pg_upgrade/t/006_transfer_modes.pl
index 360d05c4b68..8e7dbb90ec8 100644
--- a/src/bin/pg_upgrade/t/006_transfer_modes.pl
+++ b/src/bin/pg_upgrade/t/006_transfer_modes.pl
@@ -119,7 +119,7 @@ sub test_mode
                        '--socketdir' => $new->host,
                        '--old-port' => $old->port,
                        '--new-port' => $new->port,
-                       $mode
+                       '--transfer-mode' => $mode
                ],
                qr/.* not supported on this platform|could not .* between old 
and new data directories: .*/,
                qr/^$/,
@@ -196,10 +196,10 @@ sub test_mode
 # builds.
 chdir ${PostgreSQL::Test::Utils::tmp_check};
 
-test_mode('--clone');
-test_mode('--copy');
-test_mode('--copy-file-range');
-test_mode('--link');
-test_mode('--swap');
+test_mode('clone');
+test_mode('copy');
+test_mode('copy-file-range');
+test_mode('link');
+test_mode('swap');
 
 done_testing();
-- 
2.55.0

>From 58a56ede6c2b629ccb277aae5453fc6b3ddb3669 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <[email protected]>
Date: Fri, 4 Dec 2026 09:48:34 -0600
Subject: [PATCH v2 2/2] pg_combinebackup: Add --transfer-mode.

pg_combinebackup has a separate option for each of its file
transfer modes (--clone, --copy, --copy-file-range, and --link).
As was recently done for pg_upgrade, this commit adds a new
--transfer-mode option that accepts the mode as its argument (e.g.,
--transfer-mode=link).  The existing options are now documented as
deprecated spellings of the new one, but they continue to work as
before.

Discussion: https://postgr.es/m/axGSXghPd_TNT5qZ%40nathan
---
 doc/src/sgml/ref/pg_combinebackup.sgml      | 156 +++++++++++++-------
 src/bin/pg_combinebackup/pg_combinebackup.c |  26 +++-
 src/bin/pg_combinebackup/t/010_hardlink.pl  |   2 +-
 3 files changed, 126 insertions(+), 58 deletions(-)

diff --git a/doc/src/sgml/ref/pg_combinebackup.sgml 
b/doc/src/sgml/ref/pg_combinebackup.sgml
index 675b802463a..fef2ee12445 100644
--- a/doc/src/sgml/ref/pg_combinebackup.sgml
+++ b/doc/src/sgml/ref/pg_combinebackup.sgml
@@ -86,26 +86,7 @@ PostgreSQL documentation
       <term><option>--link</option></term>
       <listitem>
        <para>
-        Use hard links instead of copying files to the synthetic backup.
-        Reconstruction of the synthetic backup might be faster (no file 
copying)
-        and use less disk space, but care must be taken when using the output
-        directory, because any modifications to that directory (for example,
-        starting the server) can also affect the input directories. Likewise,
-        changes to the input directories (for example, starting the server on
-        the full backup) could affect the output directory. Thus, this option
-        is best used when the input directories are only copies that will be
-        removed after <application>pg_combinebackup</application> has 
completed.
-       </para>
-
-       <para>
-        Requires that the input backups and the output directory are in the
-        same file system.
-       </para>
-
-       <para>
-        If a backup manifest is not available or does not contain checksum of
-        the right type, hard links will still be created, but the file will be
-        also read block-by-block for the checksum calculation.
+        Deprecated spelling of <option>--transfer-mode=link</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -170,23 +151,7 @@ PostgreSQL documentation
       <term><option>--clone</option></term>
       <listitem>
        <para>
-        Use efficient file cloning (also known as <quote>reflinks</quote> on
-        some systems) instead of copying files to the new data directory,
-        which can result in near-instantaneous copying of the data files.
-       </para>
-
-       <para>
-        If a backup manifest is not available or does not contain checksum of
-        the right type, file cloning will be used to copy the file, but the
-        file will be also read block-by-block for the checksum calculation.
-       </para>
-
-       <para>
-        File cloning is only supported on some operating systems and file
-        systems.  If it is selected but not supported, the
-        <application>pg_combinebackup</application> run will error.  At 
present,
-        it is supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on
-        file systems created with reflink support), and on macOS with APFS.
+        Deprecated spelling of <option>--transfer-mode=clone</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -195,9 +160,7 @@ PostgreSQL documentation
       <term><option>--copy</option></term>
       <listitem>
        <para>
-        Perform regular file copy.  This is the default.  (See also
-        <option>--copy-file-range</option>, <option>--clone</option>, and
-        <option>-k</option>/<option>--link</option>.)
+        Deprecated spelling of <option>--transfer-mode=copy</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -206,18 +169,8 @@ PostgreSQL documentation
       <term><option>--copy-file-range</option></term>
       <listitem>
        <para>
-        Use the <function>copy_file_range</function> system call for efficient
-        copying.  On some file systems this gives results similar to
-        <option>--clone</option>, sharing physical disk blocks, while on others
-        it may still copy blocks, but do so via an optimized path.  At present,
-        it is supported on Linux and FreeBSD.
-       </para>
-
-       <para>
-        If a backup manifest is not available or does not contain checksum of
-        the right type, <function>copy_file_range</function> will be used to
-        copy the file, but the file will be also read block-by-block for the
-        checksum calculation.
+        Deprecated spelling of
+        <option>--transfer-mode=copy-file-range</option>.
        </para>
       </listitem>
      </varlistentry>
@@ -273,6 +226,105 @@ PostgreSQL documentation
       </listitem>
      </varlistentry>
 
+     <varlistentry>
+      <term><option>--transfer-mode=<replaceable 
class="parameter">mode</replaceable></option></term>
+      <listitem>
+       <para>
+        Specifies how files are transferred from the input directories to the
+        output directory.  <replaceable>mode</replaceable> can be one of the
+        following:
+
+        <variablelist>
+         <varlistentry>
+          <term><literal>clone</literal></term>
+          <listitem>
+           <para>
+            Use efficient file cloning (also known as <quote>reflinks</quote>
+            on some systems) instead of copying files to the new data
+            directory, which can result in near-instantaneous copying of the
+            data files.
+           </para>
+
+           <para>
+            If a backup manifest is not available or does not contain checksum
+            of the right type, file cloning will be used to copy the file, but
+            the file will be also read block-by-block for the checksum
+            calculation.
+           </para>
+
+           <para>
+            File cloning is only supported on some operating systems and file
+            systems.  If it is selected but not supported, the
+            <application>pg_combinebackup</application> run will error.  At
+            present, it is supported on Linux (kernel 4.5 or later) with Btrfs
+            and XFS (on file systems created with reflink support), and on
+            macOS with APFS.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>copy</literal></term>
+          <listitem>
+           <para>
+            Perform regular file copy.  This is the default.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>copy-file-range</literal></term>
+          <listitem>
+           <para>
+            Use the <function>copy_file_range</function> system call for
+            efficient copying.  On some file systems this gives results similar
+            to <literal>clone</literal>, sharing physical disk blocks, while on
+            others it may still copy blocks, but do so via an optimized path.
+            At present, it is supported on Linux and FreeBSD.
+           </para>
+
+           <para>
+            If a backup manifest is not available or does not contain checksum
+            of the right type, <function>copy_file_range</function> will be
+            used to copy the file, but the file will be also read
+            block-by-block for the checksum calculation.
+           </para>
+          </listitem>
+         </varlistentry>
+
+         <varlistentry>
+          <term><literal>link</literal></term>
+          <listitem>
+           <para>
+            Use hard links instead of copying files to the synthetic backup.
+            Reconstruction of the synthetic backup might be faster (no file
+            copying) and use less disk space, but care must be taken when using
+            the output directory, because any modifications to that directory
+            (for example, starting the server) can also affect the input
+            directories. Likewise, changes to the input directories (for
+            example, starting the server on the full backup) could affect the
+            output directory. Thus, this mode is best used when the input
+            directories are only copies that will be removed after
+            <application>pg_combinebackup</application> has completed.
+           </para>
+
+           <para>
+            Requires that the input backups and the output directory are in the
+            same file system.
+           </para>
+
+           <para>
+            If a backup manifest is not available or does not contain checksum
+            of the right type, hard links will still be created, but the file
+            will be also read block-by-block for the checksum calculation.
+           </para>
+          </listitem>
+         </varlistentry>
+        </variablelist>
+       </para>
+      </listitem>
+     </varlistentry>
+
      <varlistentry>
        <term><option>-V</option></term>
        <term><option>--version</option></term>
diff --git a/src/bin/pg_combinebackup/pg_combinebackup.c 
b/src/bin/pg_combinebackup/pg_combinebackup.c
index 61ac17d6a11..6fa39bc5834 100644
--- a/src/bin/pg_combinebackup/pg_combinebackup.c
+++ b/src/bin/pg_combinebackup/pg_combinebackup.c
@@ -143,6 +143,7 @@ main(int argc, char *argv[])
                {"clone", no_argument, NULL, 4},
                {"copy", no_argument, NULL, 5},
                {"copy-file-range", no_argument, NULL, 6},
+               {"transfer-mode", required_argument, NULL, 7},
                {NULL, 0, NULL, 0}
        };
 
@@ -221,6 +222,18 @@ main(int argc, char *argv[])
                        case 6:
                                opt.copy_method = COPY_METHOD_COPY_FILE_RANGE;
                                break;
+                       case 7:
+                               if (strcmp(optarg, "clone") == 0)
+                                       opt.copy_method = COPY_METHOD_CLONE;
+                               else if (strcmp(optarg, "copy") == 0)
+                                       opt.copy_method = COPY_METHOD_COPY;
+                               else if (strcmp(optarg, "copy-file-range") == 0)
+                                       opt.copy_method = 
COPY_METHOD_COPY_FILE_RANGE;
+                               else if (strcmp(optarg, "link") == 0)
+                                       opt.copy_method = COPY_METHOD_LINK;
+                               else
+                                       pg_fatal("invalid argument for option 
%s", "--transfer-mode");
+                               break;
                        default:
                                /* getopt_long already emitted a complaint */
                                pg_log_error_hint("Try \"%s --help\" for more 
information.", progname);
@@ -443,7 +456,7 @@ main(int argc, char *argv[])
 
        /* Warn about the possibility of compromising the backups, when link 
mode */
        if (opt.copy_method == COPY_METHOD_LINK)
-               pg_log_warning("--link mode was used; any modifications to the 
output "
+               pg_log_warning("link mode was used; any modifications to the 
output "
                                           "directory might destructively 
modify input directories");
 
        /* It's a success, so don't remove the output directories. */
@@ -788,19 +801,22 @@ help(const char *progname)
        printf(_("  %s [OPTION]... DIRECTORY...\n"), progname);
        printf(_("\nOptions:\n"));
        printf(_("  -d, --debug               generate lots of debugging 
output\n"));
-       printf(_("  -k, --link                link files instead of 
copying\n"));
+       printf(_("  -k, --link                (same as --transfer-mode=link, 
deprecated)\n"));
        printf(_("  -n, --dry-run             do not actually do anything\n"));
        printf(_("  -N, --no-sync             do not wait for changes to be 
written safely to disk\n"));
        printf(_("  -o, --output=DIRECTORY    output directory\n"));
        printf(_("  -T, --tablespace-mapping=OLDDIR=NEWDIR\n"
                         "                            relocate tablespace in 
OLDDIR to NEWDIR\n"));
-       printf(_("      --clone               clone (reflink) files instead of 
copying\n"));
-       printf(_("      --copy                copy files (default)\n"));
-       printf(_("      --copy-file-range     copy using copy_file_range() 
system call\n"));
+       printf(_("      --clone               (same as --transfer-mode=clone, 
deprecated)\n"));
+       printf(_("      --copy                (same as --transfer-mode=copy, 
deprecated)\n"));
+       printf(_("      --copy-file-range     (same as 
--transfer-mode=copy-file-range,\n"
+                        "                            deprecated)\n"));
        printf(_("      --manifest-checksums=SHA{224,256,384,512}|CRC32C|NONE\n"
                         "                            use algorithm for 
manifest checksums\n"));
        printf(_("      --no-manifest         suppress generation of backup 
manifest\n"));
        printf(_("      --sync-method=METHOD  set method for syncing files to 
disk\n"));
+       printf(_("      --transfer-mode=MODE  set file transfer mode to 
\"clone\",\n"
+                        "                            \"copy\" (default), 
\"copy-file-range\", or \"link\"\n"));
        printf(_("  -V, --version             output version information, then 
exit\n"));
        printf(_("  -?, --help                show this help, then exit\n"));
 
diff --git a/src/bin/pg_combinebackup/t/010_hardlink.pl 
b/src/bin/pg_combinebackup/t/010_hardlink.pl
index 5fbbe6a923b..e4509abd0dc 100644
--- a/src/bin/pg_combinebackup/t/010_hardlink.pl
+++ b/src/bin/pg_combinebackup/t/010_hardlink.pl
@@ -84,7 +84,7 @@ my $restore = PostgreSQL::Test::Cluster->new('restore');
 $restore->init_from_backup(
        $primary, 'backup2',
        combine_with_prior => ['backup1'],
-       combine_mode => '--link');
+       combine_mode => '--transfer-mode=link');
 
 # Ensure files have the expected count of hard links. We expect all data files
 # from test_1 to contain 2 hard links, because they were not touched between 
the
-- 
2.55.0

Reply via email to