1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-24 08:52:38 +02:00
Backup and recovery manager for PostgreSQL https://postgrespro.github.io/pg_probackup/
Go to file
2019-11-27 23:16:35 +03:00
doc DOC: update fonts 2019-11-27 23:16:35 +03:00
src wal_bytes for ARCHIVE backups was calculated incorrectly 2019-11-01 18:42:20 +03:00
tests tests: minor fixes 2019-11-01 15:23:31 +03:00
travis [Issue #101] Multiple spelling fixes. Reported by Alexander Lakhin 2019-07-23 20:11:11 +03:00
.gitignore DOC: add README for docs and add '.html' files to '.gitignore' 2019-11-06 17:36:40 +02:00
.travis.yml Travis tests 2016-09-16 00:26:18 +03:00
Documentation.md update current version to 2.2.5 in Readme and Documentation 2019-11-02 04:10:51 +03:00
gen_probackup_project.pl Windows: minor fix 2019-08-13 19:41:02 +03:00
LICENSE Update copyrights 2019-04-25 15:47:24 +03:00
Makefile Makefile update for future PG13 2019-11-08 20:04:32 +03:00
README.md Readme: minor update 2019-11-19 12:39:37 +03:00

pg_probackup

pg_probackup is a utility to manage backup and recovery of PostgreSQL database clusters. It is designed to perform periodic backups of the PostgreSQL instance that enable you to restore the server in case of a failure.

The utility is compatible with:

  • PostgreSQL 9.5, 9.6, 10, 11, 12;

As compared to other backup solutions, pg_probackup offers the following benefits that can help you implement different backup strategies and deal with large amounts of data:

  • Incremental backup: page-level incremental backup allows you to save disk space, speed up backup and restore. With three different incremental modes, you can plan the backup strategy in accordance with your data flow.
  • Validation: automatic data consistency checks and on-demand backup validation without actual data recovery
  • Verification: on-demand verification of PostgreSQL instance with the checkdb command.
  • Retention: managing WAL archive and backups in accordance with retention policy. You can configure retention policy based on recovery time or the number of backups to keep, as well as specify time to live (TTL) for a particular backup. Expired backups can be merged or deleted.
  • Parallelization: running backup, restore, merge, delete, verificaton and validation processes on multiple parallel threads
  • Compression: storing backup data in a compressed state to save disk space
  • Deduplication: saving disk space by not copying unchanged non-data files, such as _vm or _fsm
  • Remote operations: backing up PostgreSQL instance located on a remote system or restoring a backup remotely
  • Backup from standby: avoid extra load on master by taking backups from a standby server
  • External directories: backing up files and directories located outside of the PostgreSQL data directory (PGDATA), such as scripts, configuration files, logs, or SQL dump files.
  • Backup Catalog: get list of backups and corresponding meta information in plain text or JSON formats
  • Archive catalog: getting the list of all WAL timelines and the corresponding meta information in plain text or JSON formats
  • Partial Restore: restore only the specified databases or exclude the specified databases from restore.

To manage backup data, pg_probackup creates a backup catalog. This directory stores all backup files with additional meta information, as well as WAL archives required for point-in-time recovery. You can store backups for different instances in separate subdirectories of a single backup catalog.

Using pg_probackup, you can take full or incremental backups:

  • Full backups contain all the data files required to restore the database cluster from scratch.
  • Incremental backups only store the data that has changed since the previous backup. It allows to decrease the backup size and speed up backup operations. pg_probackup supports the following modes of incremental backups:
    • PAGE backup. In this mode, pg_probackup scans all WAL files in the archive from the moment the previous full or incremental backup was taken. Newly created backups contain only the pages that were mentioned in WAL records. This requires all the WAL files since the previous backup to be present in the WAL archive. If the size of these files is comparable to the total size of the database cluster files, speedup is smaller, but the backup still takes less space.
    • DELTA backup. In this mode, pg_probackup read all data files in PGDATA directory and only those pages, that where changed since previous backup, are copied. Continuous archiving is not necessary for it to operate. Also this mode could impose read-only I/O pressure equal to Full backup.
    • PTRACK backup. In this mode, PostgreSQL tracks page changes on the fly. Continuous archiving is not necessary for it to operate. Each time a relation page is updated, this page is marked in a special PTRACK bitmap for this relation. As one page requires just one bit in the PTRACK fork, such bitmaps are quite small. Tracking implies some minor overhead on the database server operation, but speeds up incremental backups significantly.

Regardless of the chosen backup type, all backups taken with pg_probackup support the following strategies of WAL delivery:

  • Autonomous backups streams via replication protocol all the WAL files required to restore the cluster to a consistent state at the time the backup was taken. Even if continuous archiving is not set up, the required WAL segments are included into the backup.
  • Archive backups rely on continuous archiving.

ptrack support

PTRACK backup support provided via following options:

  • vanilla PostgreSQL compiled with ptrack patch. Currently there are patches for PostgreSQL 9.6 and PostgreSQL 10
  • Postgres Pro Standard 9.6, 10, 11
  • Postgres Pro Enterprise 9.6, 10, 11

Limitations

pg_probackup currently has the following limitations:

  • The server from which the backup was taken and the restored server must be compatible by the block_size and wal_block_size parameters and have the same major release number.
  • Incremental chain can span only within one timeline. So if you have backup incremental chain taken from replica and it gets promoted, you would be forced to take another FULL backup.

Current release

2.2.5

Documentation

Documentation can be found at github.

Installation and Setup

Windows Installation

Installers are available in release assets. Latests.

Linux Installation

pg_probackup for vanilla PostgreSQL

#DEB Ubuntu|Debian Packages
sudo echo "deb [arch=amd64] http://repo.postgrespro.ru/pg_probackup/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" > /etc/apt/sources.list.d/pg_probackup.list
sudo wget -O - http://repo.postgrespro.ru/pg_probackup/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update
sudo apt-get install pg-probackup-{12,11,10,9.6,9.5}
sudo apt-get install pg-probackup-{12,11,10,9.6,9.5}-dbg

#DEB-SRC Packages
sudo echo "deb-src [arch=amd64] http://repo.postgrespro.ru/pg_probackup/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" >>\
  /etc/apt/sources.list.d/pg_probackup.list
sudo apt-get source pg-probackup-{12,11,10,9.6,9.5}

#RPM Centos Packages
rpm -ivh http://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-centos.noarch.rpm
yum install pg_probackup-{12,11,10,9.6,9.5}
yum install pg_probackup-{12,11,10,9.6,9.5}-debuginfo

#RPM RHEL Packages
rpm -ivh http://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-rhel.noarch.rpm
yum install pg_probackup-{12,11,10,9.6,9.5}
yum install pg_probackup-{12,11,10,9.6,9.5}-debuginfo

#RPM Oracle Linux Packages
rpm -ivh http://repo.postgrespro.ru/pg_probackup/keys/pg_probackup-repo-oraclelinux.noarch.rpm
yum install pg_probackup-{12,11,10,9.6,9.5}
yum install pg_probackup-{12,11,10,9.6,9.5}-debuginfo

#SRPM Packages
yumdownloader --source pg_probackup-{12,11,10,9.6,9.5}

#RPM ALT Linux p7
sudo echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p7 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list
sudo apt-get update
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}-debuginfo

#RPM ALT Linux p8
sudo echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p8 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list
sudo apt-get update
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}-debuginfo

#RPM ALT Linux p9
sudo echo "rpm http://repo.postgrespro.ru/pg_probackup/rpm/latest/altlinux-p9 x86_64 vanilla" > /etc/apt/sources.list.d/pg_probackup.list
sudo apt-get update
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}
sudo apt-get install pg_probackup-{12,11,10,9.6,9.5}-debuginfo

pg_probackup for PostgresPro Standart and Enterprise

#DEB Ubuntu|Debian Packages
sudo echo "deb [arch=amd64] http://repo.postgrespro.ru/pg_probackup-forks/deb/ $(lsb_release -cs) main-$(lsb_release -cs)" > /etc/apt/sources.list.d/pg_probackup-forks.list
sudo wget -O - http://repo.postgrespro.ru/pg_probackup-forks/keys/GPG-KEY-PG_PROBACKUP | sudo apt-key add - && sudo apt-get update
sudo apt-get install pg-probackup-{std,ent}-{11,10,9.6}
sudo apt-get install pg-probackup-{std,ent}-{11,10,9.6}-dbg

#RPM Centos Packages
rpm -ivh http://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-centos.noarch.rpm
yum install pg_probackup-{std,ent}-{11,10,9.6}
yum install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo

#RPM RHEL Packages
rpm -ivh http://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-rhel.noarch.rpm
yum install pg_probackup-{std,ent}-{11,10,9.6}
yum install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo

#RPM Oracle Linux Packages
rpm -ivh http://repo.postgrespro.ru/pg_probackup-forks/keys/pg_probackup-repo-forks-oraclelinux.noarch.rpm
yum install pg_probackup-{std,ent}-{11,10,9.6}
yum install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo

#RPM ALT Linux p7
sudo echo "rpm http://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p7 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list
sudo apt-get update
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo

#RPM ALT Linux p8
sudo echo "rpm http://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p8 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list
sudo apt-get update
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo

#RPM ALT Linux p9
sudo echo "rpm http://repo.postgrespro.ru/pg_probackup-forks/rpm/latest/altlinux-p9 x86_64 forks" > /etc/apt/sources.list.d/pg_probackup_forks.list && sudo apt-get update
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}
sudo apt-get install pg_probackup-{std,ent}-{11,10,9.6}-debuginfo

Once you have pg_probackup installed, complete the setup.

Building from source

Linux

To compile pg_probackup, you must have a PostgreSQL installation and raw source tree. To install pg_probackup, execute this in the module's directory:

make USE_PGXS=1 PG_CONFIG=<path_to_pg_config> top_srcdir=<path_to_PostgreSQL_source_tree>

Windows

Currently pg_probackup can be build using only MSVC 2013. Build PostgreSQL using pgwininstall or PostgreSQL instruction with MSVC 2013. If zlib support is needed, src/tools/msvc/config.pl must contain path to directory with compiled zlib. Example

CALL "C:\Program Files (x86)\Microsoft Visual Studio 12.0\VC\vcvarsall" amd64
SET PATH=%PATH%;C:\Perl64\bin
SET PATH=%PATH%;C:\msys64\usr\bin
gen_probackup_project.pl C:\path_to_postgresql_source_tree

License

This module available under the license similar to PostgreSQL.

Feedback

Do not hesitate to post your issues, questions and new ideas at the issues page.

Authors

Postgres Professional, Moscow, Russia.

Credits

pg_probackup utility is based on pg_arman, that was originally written by NTT and then developed and maintained by Michael Paquier.