PG_COMBINEBACKUP(1)
π PG_COMBINEBACKUP β reconstruct a full backup from an incremental backup and dependent backups β¨
okay so welcome to the <pink>pg_combinebackup</pink> page, part of the PostgreSQL 17.11 Documentation bestie. this is the tool that glues your incremental backups back into one whole full backup. she's giving restoration era. π¦
β¨ SYNOPSIS β¨
pg_combinebackup [option...] [backup_directory...]
π DESCRIPTION π
pg_combinebackup reconstructs a synthetic full backup from an incremental backup plus all the earlier backups it depends on. it's giving frankenstein but make it β¨legitimateβ¨.
so here's the vibe: you list all the required backups on the command line, oldest to newest. yes, in that order, i'm serious π. the first backup directory should be the path to the full backup, and the last should be the path to the final incremental backup that you actually want to restore. the reconstructed backup gets written to the output directory you specify with the -o option. periodt.
pg_combinebackup will attempt to verify that the backups you specify form a legal backup chain β like, one from which a correct full backup can actually be reconstructed. but listen π β she is not designed to help you keep track of which backups depend on which other backups. if you delete one or more of the previous backups that your incremental backup relies on, you will not be able to restore it. that's it, that's the tragedy. π
and also β and this is the part people skip β pg_combinebackup only tries to verify that the backups have the correct relationship to each other. it does not check that each individual backup is intact. for that, use pg_verifybackup(1). two different jobs, bestie, don't conflate them π
.
here's the cute part though: since the output of pg_combinebackup is itself a synthetic full backup, it can absolutely be used as an input to a future invocation of pg_combinebackup. iconic. you'd just specify that synthetic full backup on the command line in lieu of the whole chain of backups it was reconstructed from. slay. π
π OPTIONS π
-d,--debugβ prints lots of debug logging output onstderr. wordy queen. π£οΈ-n,--dry-runβ this option instructspg_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. a little preview era, no commitment. π-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 means that a subsequent operating system crash can leave the output backup corrupt. generally this one is useful for testing but should not be used when creating a production installation. bestie i'm begging you π-ooutputdir,--output=outputdir β specifies the output directory where the synthetic full backup should be written. currently, this argument is required. no output dir, no backup, no vibes.-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. yes, multiple times. go off. π«--cloneβ use 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 a checksum of the right type, file cloning will be used to copy the file, but the file will also be read block-by-block for the checksum calculation.
file cloning is only supported on some operating systems and file systems. if it's selected but not supported, the pg_combinebackup run will error. at present, it's supported on Linux (kernel 4.5 or later) with Btrfs and XFS (on file systems created with reflink support), and on macOS with APFS. know your filesystem before you commit, iykyk. π§
--copyβ perform regular file copy. this is the default. (see also--copy-file-rangeand--clone.) the reliable friend. π«Ά--copy-file-rangeβ use 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's supported on Linux and FreeBSD. π
if a backup manifest is not available, or does not contain a checksum of the right type, copy_file_range will be used to copy the file, but the file will also be 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. (yes, she writes one by default. very thorough of her.)--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. (obvi.)
-V,--versionβ prints thepg_combinebackupversion and exits. short and sweet. π-?,--helpβ shows help aboutpg_combinebackupcommand line arguments, and exits. when in doubt,-?. π
β οΈ LIMITATIONS β οΈ
pg_combinebackup does not recompute page checksums when writing the output directory. soooo π¬ β 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. that's the whole limitation, and it's lowkey a big deal.
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. either way, handle it. don't just leave it there being broken. π
πΈ 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. aesthetic choices matter, bestie π
π¦ SEE ALSO π¦
psst β and honestly, also go peek atpg_verifybackup(1)andpg_checksums(1)if you're doing any of the stuff mentioned above. the page said it, not me. π
okay that's the whole page, mwah π β brought to you by PostgreSQL 17.11, dated 2026. go forth and combine those backups, you absolute icon. πβ¨
π¦ where this page comes from
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- opensuse-leap 16.0: postgresql17 17.11-160000.1.1 Β· PostgreSQL
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms