public inbox for [email protected]  
help / color / mirror / Atom feed
From: Robert Haas <[email protected]>
To: [email protected]
Subject: pgsql: pg_combinebackup: Add -k, --link option.
Date: Mon, 17 Mar 2025 18:09:30 +0000
Message-ID: <[email protected]> (raw)

pg_combinebackup: Add -k, --link option.

This is similar to pg_upgrade's --link option, except that here we won't
typically be able to use it for every input file: sometimes we will need
to reconstruct a complete backup from blocks stored in different files.
However, when a whole file does need to be copied, we can use an
optimized copying strategy: see the existing --clone and
--copy-file-range options and the code to use CopyFile() on Windows.
This commit adds a new strategy: add a hard link to an existing file.
Making a hard link doesn't actually copy anything, but it makes sense
for the code to treat it as doing so.

This is useful when the input directories are merely staging directories
that will be removed once the restore is complete. In such cases, there
is no need to actually copy the data, and making a bunch of new hard
links can be very quick. However, it would be quite dangerous to use it
if the input directories might later be reused for any other purpose,
since starting postgres on the output directory would destructively
modify the input directories. For that reason, using this new option
causes pg_combinebackup to emit a warning about the danger involved.

Author: Israel Barth Rubio <[email protected]>
Co-authored-by: Robert Haas <[email protected]> (cosmetic changes)
Reviewed-by: Vignesh C <[email protected]>
Discussion: http://postgr.es/m/CA+TgmoaEFsYHsMefNaNkU=2SnMRufKE3eVJxvAaX=OWgcnPmPg@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/99aeb84703177308c1541e2d11c09fdc59acb724

Modified Files
--------------
doc/src/sgml/ref/pg_combinebackup.sgml      |  32 +++++-
src/bin/pg_combinebackup/copy_file.c        |  33 +++++-
src/bin/pg_combinebackup/copy_file.h        |   1 +
src/bin/pg_combinebackup/meson.build        |   1 +
src/bin/pg_combinebackup/pg_combinebackup.c |  12 +-
src/bin/pg_combinebackup/t/010_hardlink.pl  | 169 ++++++++++++++++++++++++++++
6 files changed, 245 insertions(+), 3 deletions(-)



reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected]
  Subject: Re: pgsql: pg_combinebackup: Add -k, --link option.
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox