Skip to content

postgrespro/ptrack

Repository files navigation

Build Status codecov GitHub release

ptrack

Overview

Ptrack is a block-level incremental backup engine for PostgreSQL. Currently ptrack codebase is split between small PostgreSQL core patch and extension. All public SQL API methods and main engine are placed in the ptrack extension, while the core patch contains only certain hooks and modifies binary utilities to ignore ptrack.map.* files.

Installation

  1. Get latest PostgreSQL sources:
git clone https://github.com/postgres/postgres.git -b REL_12_STABLE && cd postgres
  1. Apply PostgreSQL core patch:
git apply -3 ptrack/patches/REL_12_STABLE-ptrack-core.diff
  1. Compile and install PostgreSQL

  2. Set ptrack.map_size (in MB)

echo "shared_preload_libraries = 'ptrack'" >> postgres_data/postgresql.conf
echo "ptrack.map_size = 64" >> postgres_data/postgresql.conf
  1. Compile and install ptrack extension
USE_PGXS=1 make -C /path/to/ptrack/ install
  1. Run PostgreSQL and create ptrack extension
CREATE EXTENSION ptrack;

Public SQL API

  • ptrack_version() — returns ptrack version string.
  • ptrack_init_lsn() — returns LSN of the last ptrack map initialization.
  • ptrack_get_pagemapset('LSN') — returns a set of changed data files with bitmaps of changed blocks since specified LSN.

Usage example:

postgres=# SELECT ptrack_version();
 ptrack_version 
----------------
 2.1
(1 row)

postgres=# SELECT ptrack_init_lsn();
 ptrack_init_lsn 
-----------------
 0/1814408
(1 row)

postgres=# SELECT ptrack_get_pagemapset('0/186F4C8');
           ptrack_get_pagemapset           
-------------------------------------------
 (global/1262,"\\x0100000000000000000000")
 (global/2672,"\\x0200000000000000000000")
 (global/2671,"\\x0200000000000000000000")
(3 rows)

Architecture

TBA

Roadmap

The main goal currently is to move as much ptrack functionality into the extension as possible and leave only certain requred hooks as core patch.