v13-0012-pg_verifybackup-Tests-and-document.patch
application/x-patch
Filename: v13-0012-pg_verifybackup-Tests-and-document.patch
Type: application/x-patch
Part: 6
Patch
Format: format-patch
Series: patch v13-0012
Subject: pg_verifybackup: Tests and document
| File | + | − |
|---|---|---|
| doc/src/sgml/ref/pg_verifybackup.sgml | 41 | 2 |
| src/bin/pg_verifybackup/t/001_basic.pl | 3 | 3 |
| src/bin/pg_verifybackup/t/002_algorithm.pl | 25 | 7 |
| src/bin/pg_verifybackup/t/003_corruption.pl | 176 | 11 |
| src/bin/pg_verifybackup/t/004_options.pl | 1 | 1 |
| src/bin/pg_verifybackup/t/005_bad_manifest.pl | 1 | 1 |
| src/bin/pg_verifybackup/t/008_untar.pl | 24 | 49 |
| src/bin/pg_verifybackup/t/010_client_untar.pl | 3 | 45 |
From 500d9bc69d7d786fae637315261dca79916b91ab Mon Sep 17 00:00:00 2001
From: Amul Sul <amul.sul@enterprisedb.com>
Date: Thu, 29 Aug 2024 19:01:22 +0530
Subject: [PATCH v13 12/12] pg_verifybackup: Tests and document
----
NOTE: This patch is not meant to be committed separately. It should
be squashed with the previous patch that implements tar format support.
----
---
doc/src/sgml/ref/pg_verifybackup.sgml | 43 +++-
src/bin/pg_verifybackup/t/001_basic.pl | 6 +-
src/bin/pg_verifybackup/t/002_algorithm.pl | 32 ++-
src/bin/pg_verifybackup/t/003_corruption.pl | 187 ++++++++++++++++--
src/bin/pg_verifybackup/t/004_options.pl | 2 +-
src/bin/pg_verifybackup/t/005_bad_manifest.pl | 2 +-
src/bin/pg_verifybackup/t/008_untar.pl | 73 +++----
src/bin/pg_verifybackup/t/010_client_untar.pl | 48 +----
8 files changed, 274 insertions(+), 119 deletions(-)
diff --git a/doc/src/sgml/ref/pg_verifybackup.sgml b/doc/src/sgml/ref/pg_verifybackup.sgml
index a3f167f9f6e..ea6bc3ccb12 100644
--- a/doc/src/sgml/ref/pg_verifybackup.sgml
+++ b/doc/src/sgml/ref/pg_verifybackup.sgml
@@ -34,8 +34,10 @@ PostgreSQL documentation
integrity of a database cluster backup taken using
<command>pg_basebackup</command> against a
<literal>backup_manifest</literal> generated by the server at the time
- of the backup. The backup must be stored in the "plain"
- format; a "tar" format backup can be checked after extracting it.
+ of the backup. The backup must be stored in the "plain" or "tar"
+ format. Verification is supported for <literal>gzip</literal>,
+ <literal>lz4</literal>, and <literal>zstd</literal> compressed tar backup;
+ any other compressed format backups can be checked after decompressing them.
</para>
<para>
@@ -168,6 +170,43 @@ PostgreSQL documentation
</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>-F <replaceable class="parameter">format</replaceable></option></term>
+ <term><option>--format=<replaceable class="parameter">format</replaceable></option></term>
+ <listitem>
+ <para>
+ Specifies the format of the backup. <replaceable>format</replaceable>
+ can be one of the following:
+
+ <variablelist>
+ <varlistentry>
+ <term><literal>p</literal></term>
+ <term><literal>plain</literal></term>
+ <listitem>
+ <para>
+ Backup consists of plain files with the same layout as the
+ source server's data directory and tablespaces.
+ </para>
+ </listitem>
+ </varlistentry>
+
+ <varlistentry>
+ <term><literal>t</literal></term>
+ <term><literal>tar</literal></term>
+ <listitem>
+ <para>
+ Backup consists of tar files. A valid backup includes the main data
+ directory in a file named <filename>base.tar</filename>, the WAL
+ files in <filename>pg_wal.tar</filename>, and separate tar files for
+ each tablespace, named after the tablespace's OID, followed by the
+ compression extension.
+ </para>
+ </listitem>
+ </varlistentry>
+ </variablelist></para>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>-n</option></term>
<term><option>--no-parse-wal</option></term>
diff --git a/src/bin/pg_verifybackup/t/001_basic.pl b/src/bin/pg_verifybackup/t/001_basic.pl
index 2f3e52d296f..ca5b0402b7d 100644
--- a/src/bin/pg_verifybackup/t/001_basic.pl
+++ b/src/bin/pg_verifybackup/t/001_basic.pl
@@ -17,11 +17,11 @@ command_fails_like(
qr/no backup directory specified/,
'target directory must be specified');
command_fails_like(
- [ 'pg_verifybackup', $tempdir ],
+ [ 'pg_verifybackup', '-Fp', $tempdir ],
qr/could not open file.*\/backup_manifest\"/,
'pg_verifybackup requires a manifest');
command_fails_like(
- [ 'pg_verifybackup', $tempdir, $tempdir ],
+ [ 'pg_verifybackup', '-Fp', $tempdir, $tempdir ],
qr/too many command-line arguments/,
'multiple target directories not allowed');
@@ -31,7 +31,7 @@ close($fh);
# but then try to use an alternate, nonexisting manifest
command_fails_like(
- [ 'pg_verifybackup', '-m', "$tempdir/not_the_manifest", $tempdir ],
+ [ 'pg_verifybackup', '-Fp', '-m', "$tempdir/not_the_manifest", $tempdir ],
qr/could not open file.*\/not_the_manifest\"/,
'pg_verifybackup respects -m flag');
diff --git a/src/bin/pg_verifybackup/t/002_algorithm.pl b/src/bin/pg_verifybackup/t/002_algorithm.pl
index fb2a1fd7c4e..ac276f3da6b 100644
--- a/src/bin/pg_verifybackup/t/002_algorithm.pl
+++ b/src/bin/pg_verifybackup/t/002_algorithm.pl
@@ -14,24 +14,33 @@ my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
$primary->start;
-for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
+sub test_checksums
{
- my $backup_path = $primary->backup_dir . '/' . $algorithm;
+ my ($format, $algorithm) = @_;
+ my $backup_path = $primary->backup_dir . '/' . $format . '/' . $algorithm;
my @backup = (
'pg_basebackup', '-D', $backup_path,
'--manifest-checksums', $algorithm, '--no-sync', '-cfast');
my @verify = ('pg_verifybackup', '-e', $backup_path);
+ if ($format eq 'tar')
+ {
+ # Add tar backup format option
+ push @backup, ('-F', 't');
+ # Add switch to skip WAL verification.
+ push @verify, ('-n');
+ }
+
# A backup with a bogus algorithm should fail.
if ($algorithm eq 'bogus')
{
$primary->command_fails(\@backup,
- "backup fails with algorithm \"$algorithm\"");
- next;
+ "$format backup fails with algorithm \"$algorithm\"");
+ return;
}
# A backup with a valid algorithm should work.
- $primary->command_ok(\@backup, "backup ok with algorithm \"$algorithm\"");
+ $primary->command_ok(\@backup, "$format backup ok with algorithm \"$algorithm\"");
# We expect each real checksum algorithm to be mentioned on every line of
# the backup manifest file except the first and last; for simplicity, we
@@ -39,7 +48,7 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
# is none, we just check that the manifest exists.
if ($algorithm eq 'none')
{
- ok(-f "$backup_path/backup_manifest", "backup manifest exists");
+ ok(-f "$backup_path/backup_manifest", "$format backup manifest exists");
}
else
{
@@ -52,10 +61,19 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
# Make sure that it verifies OK.
$primary->command_ok(\@verify,
- "verify backup with algorithm \"$algorithm\"");
+ "verify $format backup with algorithm \"$algorithm\"");
# Remove backup immediately to save disk space.
rmtree($backup_path);
}
+# Do the check
+for my $format (qw(plain tar))
+{
+ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
+ {
+ test_checksums($format, $algorithm);
+ }
+}
+
done_testing();
diff --git a/src/bin/pg_verifybackup/t/003_corruption.pl b/src/bin/pg_verifybackup/t/003_corruption.pl
index ae91e043384..d0c3ffedd14 100644
--- a/src/bin/pg_verifybackup/t/003_corruption.pl
+++ b/src/bin/pg_verifybackup/t/003_corruption.pl
@@ -11,6 +11,8 @@ use PostgreSQL::Test::Cluster;
use PostgreSQL::Test::Utils;
use Test::More;
+my $tar = $ENV{TAR};
+
my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
$primary->start;
@@ -32,62 +34,73 @@ EOM
my @scenario = (
{
'name' => 'extra_file',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_extra_file,
'fails_like' =>
qr/extra_file.*present on disk but not in the manifest/
},
{
'name' => 'extra_tablespace_file',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_extra_tablespace_file,
'fails_like' =>
qr/extra_ts_file.*present on disk but not in the manifest/
},
{
'name' => 'missing_file',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_missing_file,
'fails_like' =>
qr/pg_xact\/0000.*present in the manifest but not on disk/
},
{
'name' => 'missing_tablespace',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_missing_tablespace,
'fails_like' =>
qr/pg_tblspc.*present in the manifest but not on disk/
},
{
'name' => 'append_to_file',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_append_to_file,
'fails_like' => qr/has size \d+ on disk but size \d+ in the manifest/
},
{
'name' => 'truncate_file',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_truncate_file,
'fails_like' => qr/has size 0 on disk but size \d+ in the manifest/
},
{
'name' => 'replace_file',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_replace_file,
'fails_like' => qr/checksum mismatch for file/
},
{
'name' => 'system_identifier',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_system_identifier,
'fails_like' =>
qr/manifest system identifier is .*, but control file has/
},
{
'name' => 'bad_manifest',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_bad_manifest,
'fails_like' => qr/manifest checksum mismatch/
},
{
'name' => 'open_file_fails',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_open_file_fails,
'fails_like' => qr/could not open file/,
'skip_on_windows' => 1
},
{
'name' => 'open_directory_fails',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_open_directory_fails,
'cleanup' => \&cleanup_open_directory_fails,
'fails_like' => qr/could not open directory/,
@@ -95,10 +108,61 @@ my @scenario = (
},
{
'name' => 'search_directory_fails',
+ 'backup_format' => 'p',
'mutilate' => \&mutilate_search_directory_fails,
'cleanup' => \&cleanup_search_directory_fails,
'fails_like' => qr/could not stat file or directory/,
'skip_on_windows' => 1
+ },
+ {
+ 'name' => 'tar_backup_unexpected_file',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_extra_file,
+ 'fails_like' =>
+ qr/extra_file.*unexpected file in the tar format backup/
+ },
+ {
+ 'name' => 'tar_backup_extra_file',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_tar_backup_extra_file,
+ 'fails_like' =>
+ qr/extra_tar_member_file.*present on disk but not in the manifest/
+ },
+ {
+ 'name' => 'tar_backup_missing_file',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_tar_backup_missing_file,
+ 'fails_like' =>
+ qr/pg_xact\/0000.*present in the manifest but not on disk/,
+ 'skip_on_windows' => 1
+ },
+ {
+ 'name' => 'tar_backup_append_to_file',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_tar_backup_append_to_file,
+ 'fails_like' => qr/has size \d+ on disk but size \d+ in the manifest/,
+ 'skip_on_windows' => 1
+ },
+ {
+ 'name' => 'tar_backup_truncate_file',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_tar_backup_truncate_file,
+ 'fails_like' => qr/has size 0 on disk but size \d+ in the manifest/,
+ 'skip_on_windows' => 1
+ },
+ {
+ 'name' => 'tar_backup_replace_file',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_tar_backup_replace_file,
+ 'fails_like' => qr/checksum mismatch for file/,
+ 'skip_on_windows' => 1
+ },
+ {
+ 'name' => 'tar_backup_system_identifier',
+ 'backup_format' => 't',
+ 'mutilate' => \&mutilate_system_identifier,
+ 'fails_like' =>
+ qr/manifest system identifier is .*, but control file has/
});
for my $scenario (@scenario)
@@ -111,29 +175,40 @@ for my $scenario (@scenario)
if ($scenario->{'skip_on_windows'}
&& ($windows_os || $Config::Config{osname} eq 'cygwin'));
+ # Skip tests for tar format-backup if tar is not available.
+ skip "no tar program available", 4
+ if ($scenario->{'backup_format'} eq 't' && (!defined $tar || $tar eq ''));
+
# Take a backup and check that it verifies OK.
my $backup_path = $primary->backup_dir . '/' . $name;
my $backup_ts_path = PostgreSQL::Test::Utils::tempdir_short();
+
+ my @backup = (
+ 'pg_basebackup', '-D', $backup_path, '--no-sync', '-cfast',
+ '-T', "${source_ts_path}=${backup_ts_path}");
+ my @verify = ('pg_verifybackup', $backup_path);
+
+ if ($scenario->{'backup_format'} eq 't')
+ {
+ # Add tar backup format option
+ push @backup, ('-F', 't');
+ # Add switch to skip WAL verification.
+ push @verify, ('-n');
+ }
+
# The tablespace map parameter confuses Msys2, which tries to mangle
# it. Tell it not to.
# See https://www.msys2.org/wiki/Porting/#filesystem-namespaces
local $ENV{MSYS2_ARG_CONV_EXCL} = $source_ts_prefix;
- $primary->command_ok(
- [
- 'pg_basebackup', '-D', $backup_path, '--no-sync', '-cfast',
- '-T', "${source_ts_path}=${backup_ts_path}"
- ],
- "base backup ok");
- command_ok([ 'pg_verifybackup', $backup_path ],
- "intact backup verified");
+
+ $primary->command_ok( \@backup, "base backup ok");
+ command_ok(\@verify, "intact backup verified");
# Mutilate the backup in some way.
$scenario->{'mutilate'}->($backup_path);
# Now check that the backup no longer verifies.
- command_fails_like(
- [ 'pg_verifybackup', $backup_path ],
- $scenario->{'fails_like'},
+ command_fails_like(\@verify, $scenario->{'fails_like'},
"corrupt backup fails verification: $name");
# Run cleanup hook, if provided.
@@ -260,6 +335,7 @@ sub mutilate_system_identifier
$backup_path . '/backup_manifest')
or BAIL_OUT "could not copy manifest to $backup_path";
$node->teardown_node(fail_ok => 1);
+ $node->clean_node();
return;
}
@@ -316,4 +392,93 @@ sub cleanup_search_directory_fails
return;
}
+# Unpack base.tar, perform the specified file operation, and then repack the
+# modified content into base.tar at the same location.
+sub mutilate_base_tar
+{
+ my ($backup_path, $op) = @_;
+
+ my $archive = 'base.tar';
+ my $tmpdir = "$backup_path/tmpdir";
+ mkdir($tmpdir) || die "$!";
+
+ # Extract the archive
+ system_or_bail($tar, '-xf', "$backup_path/$archive", '-C', "$tmpdir");
+ unlink("$backup_path/$archive") || die "$!";
+
+ if ($op eq 'add')
+ {
+ create_extra_file($tmpdir, 'extra_tar_member_file');
+ }
+ elsif ($op eq 'delete')
+ {
+ mutilate_missing_file($tmpdir);
+ }
+ elsif ($op eq 'append')
+ {
+ mutilate_append_to_file($tmpdir);
+ }
+ elsif ($op eq 'truncate')
+ {
+ mutilate_truncate_file($tmpdir);
+ }
+ elsif ($op eq 'replace')
+ {
+ mutilate_replace_file($tmpdir);
+ }
+ else
+ {
+ die "mutilate_tar_backup: \"$op\" invalid operation";
+ }
+
+
+ # Navigate to the extracted location and list the files.
+ chdir("$tmpdir") || die "$!";
+ my @files = glob("*");
+ # Repack the extracted content
+ system_or_bail($tar, '-cf', "$backup_path/$archive", @files);
+ chdir($backup_path) || die "$!";
+ rmtree("$tmpdir") || die "$!";
+}
+
+# Add a file into the base.tar of the backup.
+sub mutilate_tar_backup_extra_file
+{
+ my ($backup_path) = @_;
+ mutilate_base_tar($backup_path, 'add');
+ return;
+}
+
+# Remove a file.
+sub mutilate_tar_backup_missing_file
+{
+ my ($backup_path) = @_;
+ mutilate_base_tar($backup_path, 'delete');
+ return;
+}
+
+# Append an additional bytes to a file.
+sub mutilate_tar_backup_append_to_file
+{
+ my ($backup_path) = @_;
+ mutilate_base_tar($backup_path, 'append');
+ return;
+}
+
+# Truncate a file to zero length.
+sub mutilate_tar_backup_truncate_file
+{
+ my ($backup_path) = @_;
+ mutilate_base_tar($backup_path, 'truncate');
+ return;
+}
+
+# Replace a file's contents
+sub mutilate_tar_backup_replace_file
+{
+ my ($backup_path) = @_;
+ mutilate_base_tar($backup_path, 'replace');
+ return;
+}
+
done_testing();
diff --git a/src/bin/pg_verifybackup/t/004_options.pl b/src/bin/pg_verifybackup/t/004_options.pl
index 8ed2214408e..2f197648740 100644
--- a/src/bin/pg_verifybackup/t/004_options.pl
+++ b/src/bin/pg_verifybackup/t/004_options.pl
@@ -108,7 +108,7 @@ unlike(
# Test valid manifest with nonexistent backup directory.
command_fails_like(
[
- 'pg_verifybackup', '-m',
+ 'pg_verifybackup', '-Fp', '-m',
"$backup_path/backup_manifest", "$backup_path/fake"
],
qr/could not open directory/,
diff --git a/src/bin/pg_verifybackup/t/005_bad_manifest.pl b/src/bin/pg_verifybackup/t/005_bad_manifest.pl
index c4ed64b62d5..28c51b6feb0 100644
--- a/src/bin/pg_verifybackup/t/005_bad_manifest.pl
+++ b/src/bin/pg_verifybackup/t/005_bad_manifest.pl
@@ -208,7 +208,7 @@ sub test_bad_manifest
print $fh $manifest_contents;
close($fh);
- command_fails_like([ 'pg_verifybackup', $tempdir ], $regexp, $test_name);
+ command_fails_like([ 'pg_verifybackup', '-Fp', $tempdir ], $regexp, $test_name);
return;
}
diff --git a/src/bin/pg_verifybackup/t/008_untar.pl b/src/bin/pg_verifybackup/t/008_untar.pl
index 7a09f3b75b2..1c83f38d5b5 100644
--- a/src/bin/pg_verifybackup/t/008_untar.pl
+++ b/src/bin/pg_verifybackup/t/008_untar.pl
@@ -16,6 +16,20 @@ my $primary = PostgreSQL::Test::Cluster->new('primary');
$primary->init(allows_streaming => 1);
$primary->start;
+# Create a tablespace directory.
+my $TS1_LOCATION = $primary->backup_dir .'/ts1';
+$TS1_LOCATION =~ s/\/\.\//\//g; # collapse foo/./bar to foo/bar
+mkdir($TS1_LOCATION);
+
+# Create a tablespace with table in it.
+$primary->safe_psql('postgres', qq(
+ CREATE TABLESPACE regress_ts1 LOCATION '$TS1_LOCATION';
+ SELECT oid FROM pg_tablespace WHERE spcname = 'regress_ts1';
+ CREATE TABLE regress_tbl1(i int) TABLESPACE regress_ts1;
+ INSERT INTO regress_tbl1 VALUES(generate_series(1,5));));
+my $tsoid = $primary->safe_psql('postgres', qq(
+ SELECT oid FROM pg_tablespace WHERE spcname = 'regress_ts1'));
+
my $backup_path = $primary->backup_dir . '/server-backup';
my $extract_path = $primary->backup_dir . '/extracted-backup';
@@ -23,39 +37,31 @@ my @test_configuration = (
{
'compression_method' => 'none',
'backup_flags' => [],
- 'backup_archive' => 'base.tar',
+ 'backup_archive' => ['base.tar', "$tsoid.tar"],
'enabled' => 1
},
{
'compression_method' => 'gzip',
'backup_flags' => [ '--compress', 'server-gzip' ],
- 'backup_archive' => 'base.tar.gz',
- 'decompress_program' => $ENV{'GZIP_PROGRAM'},
- 'decompress_flags' => ['-d'],
+ 'backup_archive' => [ 'base.tar.gz', "$tsoid.tar.gz" ],
'enabled' => check_pg_config("#define HAVE_LIBZ 1")
},
{
'compression_method' => 'lz4',
'backup_flags' => [ '--compress', 'server-lz4' ],
- 'backup_archive' => 'base.tar.lz4',
- 'decompress_program' => $ENV{'LZ4'},
- 'decompress_flags' => [ '-d', '-m' ],
+ 'backup_archive' => ['base.tar.lz4', "$tsoid.tar.lz4" ],
'enabled' => check_pg_config("#define USE_LZ4 1")
},
{
'compression_method' => 'zstd',
'backup_flags' => [ '--compress', 'server-zstd' ],
- 'backup_archive' => 'base.tar.zst',
- 'decompress_program' => $ENV{'ZSTD'},
- 'decompress_flags' => ['-d'],
+ 'backup_archive' => [ 'base.tar.zst', "$tsoid.tar.zst" ],
'enabled' => check_pg_config("#define USE_ZSTD 1")
},
{
'compression_method' => 'zstd',
'backup_flags' => [ '--compress', 'server-zstd:level=1,long' ],
- 'backup_archive' => 'base.tar.zst',
- 'decompress_program' => $ENV{'ZSTD'},
- 'decompress_flags' => ['-d'],
+ 'backup_archive' => [ 'base.tar.zst', "$tsoid.tar.zst" ],
'enabled' => check_pg_config("#define USE_ZSTD 1")
});
@@ -86,47 +92,16 @@ for my $tc (@test_configuration)
my $backup_files = join(',',
sort grep { $_ ne '.' && $_ ne '..' } slurp_dir($backup_path));
my $expected_backup_files =
- join(',', sort ('backup_manifest', $tc->{'backup_archive'}));
+ join(',', sort ('backup_manifest', @{ $tc->{'backup_archive'} }));
is($backup_files, $expected_backup_files,
"found expected backup files, compression $method");
- # Decompress.
- if (exists $tc->{'decompress_program'})
- {
- my @decompress = ($tc->{'decompress_program'});
- push @decompress, @{ $tc->{'decompress_flags'} }
- if $tc->{'decompress_flags'};
- push @decompress, $backup_path . '/' . $tc->{'backup_archive'};
- system_or_bail(@decompress);
- }
-
- SKIP:
- {
- my $tar = $ENV{TAR};
- # don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
- skip "no tar program available", 1
- if (!defined $tar || $tar eq '');
-
- # Untar.
- mkdir($extract_path);
- system_or_bail($tar, 'xf', $backup_path . '/base.tar',
- '-C', $extract_path);
-
- # Verify.
- $primary->command_ok(
- [
- 'pg_verifybackup', '-n',
- '-m', "$backup_path/backup_manifest",
- '-e', $extract_path
- ],
- "verify backup, compression $method");
- }
+ # Verify tar backup.
+ $primary->command_ok(['pg_verifybackup', '-n', '-e', $backup_path],
+ "verify backup, compression $method");
# Cleanup.
- unlink($backup_path . '/backup_manifest');
- unlink($backup_path . '/base.tar');
- unlink($backup_path . '/' . $tc->{'backup_archive'});
+ rmtree($backup_path);
rmtree($extract_path);
}
}
diff --git a/src/bin/pg_verifybackup/t/010_client_untar.pl b/src/bin/pg_verifybackup/t/010_client_untar.pl
index 8c076d46dee..6b7d7483f6e 100644
--- a/src/bin/pg_verifybackup/t/010_client_untar.pl
+++ b/src/bin/pg_verifybackup/t/010_client_untar.pl
@@ -29,41 +29,30 @@ my @test_configuration = (
'compression_method' => 'gzip',
'backup_flags' => [ '--compress', 'client-gzip:5' ],
'backup_archive' => 'base.tar.gz',
- 'decompress_program' => $ENV{'GZIP_PROGRAM'},
- 'decompress_flags' => ['-d'],
'enabled' => check_pg_config("#define HAVE_LIBZ 1")
},
{
'compression_method' => 'lz4',
'backup_flags' => [ '--compress', 'client-lz4:5' ],
'backup_archive' => 'base.tar.lz4',
- 'decompress_program' => $ENV{'LZ4'},
- 'decompress_flags' => ['-d'],
- 'output_file' => 'base.tar',
'enabled' => check_pg_config("#define USE_LZ4 1")
},
{
'compression_method' => 'zstd',
'backup_flags' => [ '--compress', 'client-zstd:5' ],
'backup_archive' => 'base.tar.zst',
- 'decompress_program' => $ENV{'ZSTD'},
- 'decompress_flags' => ['-d'],
'enabled' => check_pg_config("#define USE_ZSTD 1")
},
{
'compression_method' => 'zstd',
'backup_flags' => [ '--compress', 'client-zstd:level=1,long' ],
'backup_archive' => 'base.tar.zst',
- 'decompress_program' => $ENV{'ZSTD'},
- 'decompress_flags' => ['-d'],
'enabled' => check_pg_config("#define USE_ZSTD 1")
},
{
'compression_method' => 'parallel zstd',
'backup_flags' => [ '--compress', 'client-zstd:workers=3' ],
'backup_archive' => 'base.tar.zst',
- 'decompress_program' => $ENV{'ZSTD'},
- 'decompress_flags' => ['-d'],
'enabled' => check_pg_config("#define USE_ZSTD 1"),
'possibly_unsupported' =>
qr/could not set compression worker count to 3: Unsupported parameter/
@@ -118,40 +107,9 @@ for my $tc (@test_configuration)
is($backup_files, $expected_backup_files,
"found expected backup files, compression $method");
- # Decompress.
- if (exists $tc->{'decompress_program'})
- {
- my @decompress = ($tc->{'decompress_program'});
- push @decompress, @{ $tc->{'decompress_flags'} }
- if $tc->{'decompress_flags'};
- push @decompress, $backup_path . '/' . $tc->{'backup_archive'};
- push @decompress, $backup_path . '/' . $tc->{'output_file'}
- if $tc->{'output_file'};
- system_or_bail(@decompress);
- }
-
- SKIP:
- {
- my $tar = $ENV{TAR};
- # don't check for a working tar here, to accommodate various odd
- # cases. If tar doesn't work the init_from_backup below will fail.
- skip "no tar program available", 1
- if (!defined $tar || $tar eq '');
-
- # Untar.
- mkdir($extract_path);
- system_or_bail($tar, 'xf', $backup_path . '/base.tar',
- '-C', $extract_path);
-
- # Verify.
- $primary->command_ok(
- [
- 'pg_verifybackup', '-n',
- '-m', "$backup_path/backup_manifest",
- '-e', $extract_path
- ],
- "verify backup, compression $method");
- }
+ # Verify tar backup.
+ $primary->command_ok( [ 'pg_verifybackup', '-n', '-e', $backup_path ],
+ "verify backup, compression $method");
# Cleanup.
rmtree($extract_path);
--
2.18.0