diff options
author | Robert Haas | 2023-12-20 14:49:12 +0000 |
---|---|---|
committer | Robert Haas | 2023-12-20 14:49:12 +0000 |
commit | dc212340058b4e7ecfc5a7a81ec50e7a207bf288 (patch) | |
tree | 79ffec15f6a8d9fce1333b99dd0b587e2459d38f /src/test/perl/PostgreSQL/Test/Cluster.pm | |
parent | 174c480508ac25568561443e6d4a82d5c1103487 (diff) |
Add support for incremental backup.
To take an incremental backup, you use the new replication command
UPLOAD_MANIFEST to upload the manifest for the prior backup. This
prior backup could either be a full backup or another incremental
backup. You then use BASE_BACKUP with the INCREMENTAL option to take
the backup. pg_basebackup now has an --incremental=PATH_TO_MANIFEST
option to trigger this behavior.
An incremental backup is like a regular full backup except that
some relation files are replaced with files with names like
INCREMENTAL.${ORIGINAL_NAME}, and the backup_label file contains
additional lines identifying it as an incremental backup. The new
pg_combinebackup tool can be used to reconstruct a data directory
from a full backup and a series of incremental backups.
Patch by me. Reviewed by Matthias van de Meent, Dilip Kumar, Jakub
Wartak, Peter Eisentraut, and Álvaro Herrera. Thanks especially to
Jakub for incredibly helpful and extensive testing.
Discussion: http://postgr.es/m/CA+TgmoYOYZfMCyOXFyC-P+-mdrZqm5pP2N7S-r0z3_402h9rsA@mail.gmail.com
Diffstat (limited to 'src/test/perl/PostgreSQL/Test/Cluster.pm')
-rw-r--r-- | src/test/perl/PostgreSQL/Test/Cluster.pm | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/src/test/perl/PostgreSQL/Test/Cluster.pm b/src/test/perl/PostgreSQL/Test/Cluster.pm index a020377761d..46cb2a65500 100644 --- a/src/test/perl/PostgreSQL/Test/Cluster.pm +++ b/src/test/perl/PostgreSQL/Test/Cluster.pm @@ -779,6 +779,10 @@ a tar-format backup, pass the name of the tar program to use in the keyword parameter tar_program. Note that tablespace tar files aren't handled here. +To restore from an incremental backup, pass the parameter combine_with_prior +as a reference to an array of prior backup names with which this backup +is to be combined using pg_combinebackup. + Streaming replication can be enabled on this node by passing the keyword parameter has_streaming => 1. This is disabled by default. @@ -816,7 +820,22 @@ sub init_from_backup mkdir $self->archive_dir; my $data_path = $self->data_dir; - if (defined $params{tar_program}) + if (defined $params{combine_with_prior}) + { + my @prior_backups = @{$params{combine_with_prior}}; + my @prior_backup_path; + + for my $prior_backup_name (@prior_backups) + { + push @prior_backup_path, + $root_node->backup_dir . '/' . $prior_backup_name; + } + + local %ENV = $self->_get_env(); + PostgreSQL::Test::Utils::system_or_bail('pg_combinebackup', '-d', + @prior_backup_path, $backup_path, '-o', $data_path); + } + elsif (defined $params{tar_program}) { mkdir($data_path); PostgreSQL::Test::Utils::system_or_bail($params{tar_program}, 'xf', |