PG_COMBINEBACKUP(1)

๐Ÿ’– pg_combinebackup ๐Ÿ’–

okay bestie, gather round, because this one is the glow-up tool of the PostgreSQL 18.6 documentation era โœจ it's the pg_combinebackup page and she is, lowkey, a whole reconstruction icon ๐Ÿ‘‘


โœจ NAME โœจ

pg_combinebackup โ€” no cap, her whole job is rebuilding a full backup out of an incremental backup plus all the backups it depends on ๐Ÿซถ


๐ŸŒธ SYNOPSIS ๐ŸŒธ

pg_combinebackup [option...] [backup_directory...]

๐Ÿฆ‹ DESCRIPTION ๐Ÿฆ‹

so pg_combinebackup is literally the girl who takes an incremental backup, plus every earlier backup it leans on, and stitches them into one synthetic full backup ๐Ÿ’… iconic behaviour, honestly.

Here's the tea on how you feed her: you put all the required backups on the command line, ordered oldest to newest โณ like, the first backup directory has to be the path to the full backup, and the last one has to be the path to the final incremental backup you wanna restore. Then the reconstructed backup gets written to the output directory you gave her with the -o option ๐Ÿ“โœจ

She will try to verify that the backups you handed her form a legal backup chain, like, one that actually produces a correct full backup ๐Ÿ•ต๏ธโ€โ™€๏ธ but bestie, listen โ€” she is not designed to help you keep track of which backups depend on which other backups. That's on you ๐Ÿ™ˆ If you go and delete one or more of the previous backups that your incremental backup relies on, you will not be able to restore it. Periodt. ๐Ÿ’€

Also, and this is important: pg_combinebackup only tries to verify that the backups have the correct relationship to each other โ€” not that each individual backup is intact ๐Ÿฅฒ for that, go use pg_verifybackup(1).

Now the cute part ๐ŸŽ€ since the output of pg_combinebackup is a synthetic full backup, it can be used as an input to a future invocation of pg_combinebackup. In that case you'd specify the synthetic full backup on the command line instead of the chain of backups it was reconstructed from. She's her own source material, main character energy fr fr ๐Ÿ‘‘


๐Ÿ’… OPTIONS ๐Ÿ’…

  • -d, --debug โ€” prints a lot of debug logging output on stderr. she's chatty and we love that for her ๐Ÿ—ฃ๏ธ
  • -k, --link โ€” uses hard links instead of copying files to the synthetic backup. Reconstruction of the synthetic backup might be faster (because, hello, no file copying) and use less disk space, but โš ๏ธ you have to be careful with the output directory, because any modifications to that directory (for example, starting the server) can also affect the input directories. Same deal the other way: changes to the input directories (for example, starting the server on the full backup) could affect the output directory. So this option is best used when the input directories are only copies that will be removed after pg_combinebackup has completed.

Requires that the input backups and the output directory are in the same file system.

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.

  • -n, --dry-run โ€” the -n/--dry-run option tells pg_combinebackup to figure out what would be done without actually creating the target directory or any output files ๐Ÿ‘ป it's especially useful in combination with --debug.
  • -N, --no-sync โ€” by default, pg_combinebackup waits for all files to be written safely to disk. This option makes her return without waiting, which is faster, but it means a subsequent operating system crash can leave the output backup corrupt ๐Ÿ˜ญ generally this option is useful for testing but should not be used when creating a production installation.
  • -o outputdir, --output=outputdir โ€” specifies the output directory where the synthetic full backup should be written. Currently, this argument is required ๐Ÿ”ฅ
  • -T olddir=newdir, --tablespace-mapping=olddir=newdir โ€” relocates the tablespace in directory olddir to newdir during the backup. olddir is the absolute path of the tablespace as it exists in the final backup specified on the command line, and newdir is the absolute path to use for the tablespace in the reconstructed backup. If either path needs to contain an equal sign (=), precede that with a backslash. This option can be specified multiple times for multiple tablespaces ๐Ÿ”
  • --clone โ€” uses efficient file cloning (also known as โ€œreflinksโ€ on some systems) instead of copying files to the new data directory, which can result in near-instantaneous copying of the data files โšก

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.

File cloning is only supported on some operating systems and file systems. If it is selected but not supported, the pg_combinebackup 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.

  • --copy โ€” performs a regular file copy. This is the default โœจ (see also --copy-file-range, --clone, and -k/--link.)
  • --copy-file-range โ€” uses the copy_file_range system call for efficient copying. On some file systems this gives results similar to --clone, 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.

If a backup manifest is not available or does not contain checksum of the right type, copy_file_range will be used to copy the file, but the file will be also read block-by-block for the checksum calculation.

  • --manifest-checksums=algorithm โ€” like pg_basebackup(1), pg_combinebackup writes a backup manifest in the output directory. This option specifies the checksum algorithm that should be applied to each file included in the backup manifest ๐Ÿงพ Currently, the available algorithms are NONE, CRC32C, SHA224, SHA256, SHA384, and SHA512. The default is CRC32C.
  • --no-manifest โ€” disables generation of a backup manifest. If this option is not specified, a backup manifest for the reconstructed backup will be written to the output directory ๐Ÿ“
  • --sync-method=method โ€” when set to fsync, which is the default, pg_combinebackup will recursively open and synchronize all files in the backup directory. When the plain format is used, the search for files will follow symbolic links for the WAL directory and each configured tablespace ๐Ÿ”—

On Linux, syncfs may be used instead to ask the operating system to synchronize the whole file system that contains the backup directory. When the plain format is used, pg_combinebackup will also synchronize the file systems that contain the WAL files and each tablespace. See recovery_init_sync_method for information about the caveats to be aware of when using syncfs ๐Ÿ‘€

This option has no effect when --no-sync is used.

  • -V, --version โ€” prints the pg_combinebackup version and exits ๐Ÿ‘‹
  • -?, --help โ€” shows help about pg_combinebackup command line arguments, and exits ๐Ÿ†˜

๐Ÿ˜ญ LIMITATIONS ๐Ÿ˜ญ

okay so this is the part where we have to be honest with each other, bestie.

pg_combinebackup does not recompute page checksums when writing the output directory ๐Ÿ˜” therefore, if any of the backups used for reconstruction were taken with checksums disabled, but the final backup was taken with checksums enabled, the resulting directory may contain pages with invalid checksums. it's giving chaos, honestly.

To avoid this problem, taking a new full backup after changing the checksum state of the cluster using pg_checksums(1) is recommended ๐Ÿซถ Otherwise, you can disable and then optionally reenable checksums on the directory produced by pg_combinebackup in order to correct the problem ๐Ÿ”ง


๐ŸŒˆ ENVIRONMENT ๐ŸŒˆ

This utility, like most other PostgreSQL utilities, uses the environment variables supported by libpq (see Section 32.15) ๐ŸŒฑ

The environment variable PG_COLOR specifies whether to use color in diagnostic messages ๐ŸŽจ Possible values are always, auto and never.


๐Ÿ‘‘ SEE ALSO ๐Ÿ‘‘

pg_basebackup(1)


and that's the whole page, babe ๐Ÿ’œ this was written up for PostgreSQL 18.6, dated 2026, and it's the PG_COMBINEBACKUP(1) page in the PostgreSQL 18.6 Documentation set ๐ŸŽ€ go forth and reconstruct your synthetic full backups, you absolute legend ๐Ÿฆ‹โœจ