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 onstderr. 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 afterpg_combinebackuphas 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-runoption tellspg_combinebackupto 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_combinebackupwaits 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.-ooutputdir,--output=outputdir โ specifies the output directory where the synthetic full backup should be written. Currently, this argument is required ๐ฅ-Tolddir=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 thecopy_file_rangesystem 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 โ likepg_basebackup(1),pg_combinebackupwrites 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 areNONE,CRC32C,SHA224,SHA256,SHA384, andSHA512. The default isCRC32C.--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 tofsync, which is the default,pg_combinebackupwill 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 thepg_combinebackupversion and exits ๐-?,--helpโ shows help aboutpg_combinebackupcommand 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 ๐
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 ๐ฆโจ
๐ฆ where this page comes from
- alpine 3.23: postgresql18-doc 18.6-r0 ยท PostgreSQL
- alpine 3.24: postgresql18-doc 18.6-r0 ยท PostgreSQL
- arch rolling: postgresql 18.6-4 ยท PostgreSQL
- fedora 43: postgresql-server 18.6-1.fc43 ยท PostgreSQL
- fedora 43: postgresql-server 18.6-1.fc43 ยท PostgreSQL
- fedora 44: postgresql-server 18.6-1.fc44 ยท PostgreSQL
- fedora 44: postgresql-server 18.6-1.fc44 ยท PostgreSQL
- nixos 26.05: postgresql 18.6
- ubuntu resolute: postgresql-client-18 18.6-0ubuntu0.26.04.1 ยท PostgreSQL
- ubuntu stonking: postgresql-client-18 18.6-3build2 ยท PostgreSQL
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms