PTRACK is a block-level incremental backup engine for Postgres Pro. If PTRACK is enabled, backup tools like pg_probackup can use its API to get information on the changed blocks on the fly when taking incremental backups. Copying only those blocks that have changed since the previous backup can significantly speed up the creation and minimize the size of backups.
PTRACK is designed to allow false positives, but to never allow false negatives: it means that all changes within the data directory except hint bits are guaranteed to be marked in the PTRACK map file, although some unchanged blocks might be included as well.
F.55.1. Setting up PTRACK
Once you complete Postgres Pro Enterprise installation, do the following:
ptrackto the shared_preload_libraries parameter in the
shared_preload_libraries = 'ptrack'
Set ptrack.map_size parameter to a positive integer.
For optimal performance, it is recommended to set
Nis the size of the Postgres Pro cluster, in
MB. If you set this parameter to a lower value, PTRACK is more likely to map several blocks together, which leads to false-positive results when tracking changed blocks and increases the incremental backup size as unchanged blocks can also be copied into the incremental backup.
ptrack.map_sizeto a higher value does not affect PTRACK operation, but keep in mind that you need up to
of additional disk space since PTRACK uses two additional temporary files to ensure durability. It is not recommended to set this parameter to a value higher than 1024. Even for Postgres Pro clusters with
ptrack.map_size* 3 MB
TB, it makes sense to use a higher value only if the efficiency and sizes of backups are more critical than the potential overhead of maintaining a large PTRACK map.
Check the wal_level setting. When using PTRACK, it is required to set the wal_level parameter to
replicaor higher. Otherwise, you can lose some tracked changes if crash-recovery occurs: some commands do not write WAL at all if
minimal, and PTRACK map files are flushed to disk only at checkpoint time.
Restart the Postgres Pro Enterprise instance for the changes to take effect, and then create the PTRACK extension:
CREATE EXTENSION ptrack;
As a result, several PTRACK functions are created, which are required for accessing PTRACK data.
Once this setup is complete, PTRACK starts tracking all the page changes in the Postgres Pro cluster and creates a
ptrack.map file that stores the latest LSN values for these pages.
ptrack.map_size parameter can only be set at server start. If you change this parameter, the previously created PTRACK map file is cleared, and tracking newly changed blocks starts from scratch. To avoid losing recent changes, it is recommended to retake a full backup after modifying this setting.
F.55.2. PTRACK Configuration Parameters
Specifies the size of a PTRACK map file and the amount of shared memory allocated for this file, in
MB. The PTRACK map file stores the latest LSN values for all pages of the Postgres Pro cluster that have changed since PTRACK was enabled. It is not recommended to set this parameter to a value higher than 1GB. The -1 value disables PTRACK, while the 0 value both disables PTRACK and cleans up all the related service files.
ptrack.map_sizeparameter can only be set at server start. If you change this parameter, the previously created PTRACK map file is cleared, and tracking newly changed blocks starts from scratch. To avoid losing recent changes, it is recommended to retake a full backup after modifying this setting.
F.55.3. PTRACK Functions
Returns the LSN of the last PTRACK map initialization.
Returns a list of changed data files with bitmaps of changed blocks since the specified LSN.
SELECT * FROM ptrack_get_pagemapset('0/2000028'); path | pagemap ----------------------+-------------------------- global/2698 | \x0700000000000000000000 global/6000 | \x0100000000000000000000 global/3593 | \x0300000000000000000000 global/1232 | \x0700000000000000000000 global/1233 | \x0700000000000000000000 global/1214_vm | \x0300000000000000000000 global/2847 | \x0300000000000000000000 global/2396 | \x0300000000000000000000 base/1/3603 | \x0f00000000000000000000 base/1/3081 | \x0700000000000000000000 base/1/2652 | \x0700000000000000000000 base/1/4152 | \x0300000000000000000000
Returns PTRACK version.