Movatterモバイル変換


[0]ホーム

URL:



Facebook
Postgres Pro
Facebook
Downloads
F.56. ptrack — a block-level incremental backup engine forPostgres Pro
Prev UpAppendix F. Additional Supplied Modules and Extensions Shipped inpostgrespro-std-17-contribHome Next

F.56. ptrack — a block-level incremental backup engine forPostgres Pro#

PTRACK is a block-level incremental backup engine forPostgres Pro. If PTRACK is enabled, backup tools likepg_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.56.1. Setting up PTRACK#

Once you completePostgres Pro Standard installation, do the following:

  1. Addptrack to theshared_preload_libraries parameter in thepostgresql.conf file:

    shared_preload_libraries = 'ptrack'
  2. Setptrack.map_size parameter to a positive integer.

    For optimal performance, it is recommended to setptrack.map_size toN / 1024, whereN is the size of thePostgres Pro cluster, inMB. 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.

    Settingptrack.map_size to a higher value does not affect PTRACK operation, but keep in mind that you need up toptrack.map_size * 3 MB 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 forPostgres Pro clusters withN > 1TB, 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.

  3. Check thewal_level setting. When using PTRACK, it is required to set thewal_level parameter toreplica or higher. Otherwise, you can lose some tracked changes if crash-recovery occurs: some commands do not write WAL at all ifwal_level isminimal, and PTRACK map files are flushed to disk only at checkpoint time.

  4. Restart thePostgres Pro Standard instance for the changes to take effect, and then create thePTRACK 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 thePostgres Pro cluster and creates aptrack.map file that stores the latest LSN values for these pages.

Note

Theptrack.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.56.2. PTRACK Configuration Parameters#

ptrack.map_size (integer)#

Specifies the size of a PTRACK map file and the amount of shared memory allocated for this file, inMB. The PTRACK map file stores the latest LSN values for all pages of thePostgres Pro cluster that have changed since PTRACK was enabled. It is not recommended to set this parameter to a value higher than 1GB. The 0 value disables PTRACK and cleans up all the related service files.

Theptrack.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.

Default: 0

F.56.3. PTRACK Functions#

ptrack_init_lsn() returnspg_lsn#

Returns the LSN of the last PTRACK map initialization.

ptrack_get_pagemapset(start_lsnpg_lsn) returnssetof record#

Returns a list of data files changed since the specifiedstart_lsn with the number and bitmap of changed pages for each file.

For example:

postgres=# SELECT * FROM ptrack_get_pagemapset('0/185C8C0');        path         | pagecount |                pagemap---------------------+-----------+---------------------------------------- base/16384/1255     |         3 | \x001000000005000000000000 base/16384/2674     |         3 | \x0000000900010000000000000000 base/16384/2691     |         1 | \x00004000000000000000000000 base/16384/2608     |         1 | \x000000000000000400000000000000000000 base/16384/2690     |         1 | \x000400000000000000000000
ptrack_get_change_stat(start_lsnpg_lsn) returnsrecord#

Returns the statistics of changes (number of files, number of changed pages and their total size inMB) since the specifiedstart_lsn.

For example:

postgres=# SELECT * FROM ptrack_get_change_stat('0/285C8C8'); files | pages |        size, MB-------+-------+------------------------    20 |    25 | 0.19531250000000000000
ptrack_version() returnstext#

Returns PTRACK version.


Prev Up Next
F.55. postgres_fdw — access data stored in externalPostgres Pro servers Home F.57. rum — an access method to work with theRUM indexes
pdfepub
Go to Postgres Pro Standard 17
By continuing to browse this website, you agree to the use of cookies. Go toPrivacy Policy.

[8]ページ先頭

©2009-2025 Movatter.jp