1
0
mirror of https://github.com/postgrespro/pg_probackup.git synced 2024-11-28 09:33:54 +02:00
Backup and recovery manager for PostgreSQL https://postgrespro.github.io/pg_probackup/
Go to file
2016-11-02 21:04:24 +03:00
doc Fix docs and use recovery time for show command. 2016-10-31 18:57:15 +03:00
expected Use --stream option only for backup. Add STREAM to show command. 2016-11-01 17:25:46 +03:00
pgut Add support for Postgres 10 in pgut lib 2016-09-27 18:17:34 +03:00
sql Remove date range and start use base36 from start_time as backup ID. 2016-10-31 18:19:11 +03:00
travis Travis tests 2016-09-16 00:26:18 +03:00
.gitignore Page-level backup using block tracking in WAL records 2016-01-15 23:47:38 +09:00
.travis.yml Travis tests 2016-09-16 00:26:18 +03:00
backup.c Use --stream option only for backup. Add STREAM to show command. 2016-11-01 17:25:46 +03:00
catalog.c Use --stream option only for backup. Add STREAM to show command. 2016-11-01 17:25:46 +03:00
COPYRIGHT Update some copyright lines to 2016 2016-01-16 00:02:09 +09:00
data.c Hide some log message for non-verbose mode. 2016-10-18 12:31:11 +03:00
delete.c Remove date range and start use base36 from start_time as backup ID. 2016-10-31 18:19:11 +03:00
dir.c Fix make mkdir.sh if tablespace path have root path. 2016-11-02 20:19:37 +03:00
fetch.c Make pg_control file optional for restore. 2016-03-02 20:50:33 +03:00
init.c Stop creating pg_xlog dir in BACKUP because it is rudiment. 2016-10-27 11:47:16 +03:00
Makefile Hide regress tests for contrib 2016-09-13 18:57:31 +03:00
parray.c Rename project to pg_arman 2014-01-27 12:02:56 +09:00
parray.h Convert newline characters from CRLF to LF. 2013-01-24 06:35:48 +00:00
parsexlog.c Check ptrack control file. 2016-03-10 17:40:33 +03:00
pg_arman.c Try fixing restore command. 2016-11-02 21:04:24 +03:00
pg_arman.h Try fixing restore command. 2016-11-02 21:04:24 +03:00
README.md Add Requirements to README 2016-10-31 20:10:50 +03:00
restore.c Try fixing restore command. 2016-11-02 21:04:24 +03:00
show.c Use --stream option only for backup. Add STREAM to show command. 2016-11-01 17:25:46 +03:00
status.c Sanitize error checks 2016-01-19 12:41:30 +09:00
util.c Remove date range and start use base36 from start_time as backup ID. 2016-10-31 18:19:11 +03:00
validate.c Remove date range and start use base36 from start_time as backup ID. 2016-10-31 18:19:11 +03:00

pg_arman fork from Postgres Professional

This repository contains fork of pg_arman by Postgres Professional with block level incremental backup support.

pg_arman is a backup and recovery manager for PostgreSQL servers able to do differential and full backup as well as restore a cluster to a state defined by a given recovery target. It is designed to perform periodic backups of an existing PostgreSQL server, combined with WAL archives to provide a way to recover a server in case of failure of server because of a reason or another. Its differential backup facility reduces the amount of data necessary to be taken between two consecutive backups.

Main features:

  • incremental backup from WAL and PTRACK
  • backup from replica
  • multithreaded backup and restore
  • autonomous backup without archive command (will need slot replication)

Requirements:

  • =PostgreSQL 9.5

  • =gcc 4.4 or >=clang 3.6 or >= XLC 12.1

  • pthread

Download

The latest version of this software can be found on the project website at https://github.com/postgrespro/pg_arman. Original fork of pg_arman can be found at https://github.com/michaelpq/pg_arman.

Installation

Compiling pg_arman requires a PostgreSQL installation to be in place as well as a raw source tree. Pass the path to the PostgreSQL source tree to make, in the top_srcdir variable:

make USE_PGXS=1 top_srcdir=<path to PostgreSQL source tree>

In addition, you must have pg_config in $PATH.

The current version of pg_arman is compatible with PostgreSQL 9.5 and upper versions.

Platforms

pg_arman has been tested on Linux and Unix-based platforms.

Documentation

All the documentation you can find here.

Regression tests

The test suite of pg_arman is available in the code tree and can be launched in a way similar to common PostgreSQL extensions and modules:

make installcheck

Block level incremental backup

Idea of block level incremental backup is that you may backup only blocks changed since last full backup. It gives two major benefits: taking backups faster and making backups smaller.

The major question here is how to get the list of changed blocks. Since each block contains LSN number, changed blocks could be retrieved by full scan of all the blocks. But this approach consumes as much server IO as full backup.

This is why we implemented alternative approaches to retrieve list of changed blocks.

  1. Scan WAL archive and extract changed blocks from it. However, shortcoming of these approach is requirement to have WAL archive.

  2. Track bitmap of changes blocks inside PostgreSQL (ptrack). It introduces some overhead to PostgreSQL performance. On our experiments it appears to be less than 3%.

These two approaches were implemented in this fork of pg_arman. The second approach requires patch for PostgreSQL 9.5 or patch for PostgreSQL 10.

Testing block level incremental backup

You need build and install PGPRO9_5 or PGPRO9_6 branch of PostgreSQL or apply this patch to PostgreSQL 9.5 or PostgreSQL 10.

Retrieving changed blocks from WAL archive

You need to enable WAL archive by adding following lines to postgresql.conf:

wal_level = archive
archive_command = 'test ! -f /home/postgres/backup/arman/wal/%f && cp %p /home/postgres/backup/arman/wal/%f'
wal_log_hints = on

Example backup (assuming PostgreSQL is running):

# Init pg_aramn backup folder
pg_arman init -B /home/postgres/backup/pgarman
# Make full backup with 2 thread and verbose mode.
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2
# Show backups information
pg_arman show -B /home/postgres/backup/pgarman

# Now you can insert or update some data in your database

# Then start the incremental backup.
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b page -v -j 2
# You should see that increment is really small
pg_arman show -B /home/postgres/backup/pgarman

For restore after remove your pgdata you can use:

pg_arman restore -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -j 4 --verbose

Retrieving changed blocks from ptrack

The advantage of this approach is that you don't have to save WAL archive. You will need to enable ptrack in postgresql.conf (restart required).

ptrack_enable = on

Also, some WALs still need to be fetched in order to get consistent backup. pg_arman can fetch them trough the streaming replication protocol. Thus, you also need to enable streaming replication connection.

Example backup (assuming PostgreSQL is running):

# Init pg_aramn backup folder
pg_arman init -B /home/postgres/backup/pgarman
# Make full backup with 2 thread and verbose mode.
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b full -v -j 2 --stream
# Show backups information
pg_arman show -B /home/postgres/backup/pgarman

# Now you can insert or update some data in your database

# Then start the incremental backup.
pg_arman backup -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -b ptrack -v -j 2 --stream
# You should see that increment is really small
pg_arman show -B /home/postgres/backup/pgarman

For restore after remove your pgdata you can use:

pg_arman restore -B /home/postgres/backup/pgarman -D /home/postgres/pgdata/arman -j 4 --verbose --stream

License

pg_arman can be distributed under the PostgreSQL license. See COPYRIGHT file for more information. pg_arman is a fork of the existing project pg_rman, initially created and maintained by NTT and Itagaki Takahiro.