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 <barthisr...@gmail.com> Co-authored-by: Robert Haas <robertmh...@gmail.com> (cosmetic changes) Reviewed-by: Vignesh C <vignes...@gmail.com> Discussion: http://postgr.es/m/CA+TgmoaEFsYHsMefNaNkU=2SnMRufKE3eVJxvAaX=owgcnp...@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(-)