Commit dbc60c55 authored by Robert Haas's avatar Robert Haas

Rename pg_validatebackup to pg_verifybackup.

Also, use "verify" rather than "validate" to refer to the process
being undertaken here. Per discussion, that is a more appropriate
term.

Discussion: https://www.postgresql.org/message-id/172c9d9b-1d0a-1b94-1456-376b1e017322@2ndquadrant.com
Discussion: http://postgr.es/m/CA+TgmobLgMh6p8FmLbj_rv9Uhd7tPrLnAyLgGd2SoSj=qD-bVg@mail.gmail.com
parent 26640c40
...@@ -211,7 +211,7 @@ Complete list of usable sgml source files in this directory. ...@@ -211,7 +211,7 @@ Complete list of usable sgml source files in this directory.
<!ENTITY pgResetwal SYSTEM "pg_resetwal.sgml"> <!ENTITY pgResetwal SYSTEM "pg_resetwal.sgml">
<!ENTITY pgRestore SYSTEM "pg_restore.sgml"> <!ENTITY pgRestore SYSTEM "pg_restore.sgml">
<!ENTITY pgRewind SYSTEM "pg_rewind.sgml"> <!ENTITY pgRewind SYSTEM "pg_rewind.sgml">
<!ENTITY pgValidateBackup SYSTEM "pg_validatebackup.sgml"> <!ENTITY pgVerifyBackup SYSTEM "pg_verifybackup.sgml">
<!ENTITY pgtestfsync SYSTEM "pgtestfsync.sgml"> <!ENTITY pgtestfsync SYSTEM "pgtestfsync.sgml">
<!ENTITY pgtesttiming SYSTEM "pgtesttiming.sgml"> <!ENTITY pgtesttiming SYSTEM "pgtesttiming.sgml">
<!ENTITY pgupgrade SYSTEM "pgupgrade.sgml"> <!ENTITY pgupgrade SYSTEM "pgupgrade.sgml">
......
...@@ -568,7 +568,7 @@ PostgreSQL documentation ...@@ -568,7 +568,7 @@ PostgreSQL documentation
<para> <para>
Disables generation of a backup manifest. If this option is not Disables generation of a backup manifest. If this option is not
specified, the server will generate and send a backup manifest specified, the server will generate and send a backup manifest
which can be verified using <xref linkend="app-pgvalidatebackup" />. which can be verified using <xref linkend="app-pgverifybackup" />.
The manifest is a list of every file present in the backup with the The manifest is a list of every file present in the backup with the
exception of any WAL files that may be included. It also stores the exception of any WAL files that may be included. It also stores the
size, last modification time, and an optional checksum for each file. size, last modification time, and an optional checksum for each file.
...@@ -620,7 +620,7 @@ PostgreSQL documentation ...@@ -620,7 +620,7 @@ PostgreSQL documentation
verified not to have been modified since the backup was taken. verified not to have been modified since the backup was taken.
</para> </para>
<para> <para>
<xref linkend="app-pgvalidatebackup" /> can be used to check the <xref linkend="app-pgverifybackup" /> can be used to check the
integrity of a backup against the backup manifest. integrity of a backup against the backup manifest.
</para> </para>
</listitem> </listitem>
......
<!-- <!--
doc/src/sgml/ref/pg_validatebackup.sgml doc/src/sgml/ref/pg_verifybackup.sgml
PostgreSQL documentation PostgreSQL documentation
--> -->
<refentry id="app-pgvalidatebackup"> <refentry id="app-pgverifybackup">
<indexterm zone="app-pgvalidatebackup"> <indexterm zone="app-pgverifybackup">
<primary>pg_validatebackup</primary> <primary>pg_verifybackup</primary>
</indexterm> </indexterm>
<refmeta> <refmeta>
<refentrytitle>pg_validatebackup</refentrytitle> <refentrytitle>pg_verifybackup</refentrytitle>
<manvolnum>1</manvolnum> <manvolnum>1</manvolnum>
<refmiscinfo>Application</refmiscinfo> <refmiscinfo>Application</refmiscinfo>
</refmeta> </refmeta>
<refnamediv> <refnamediv>
<refname>pg_validatebackup</refname> <refname>pg_verifybackup</refname>
<refpurpose>verify the integrity of a base backup of a <refpurpose>verify the integrity of a base backup of a
<productname>PostgreSQL</productname> cluster</refpurpose> <productname>PostgreSQL</productname> cluster</refpurpose>
</refnamediv> </refnamediv>
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>pg_validatebackup</command> <command>pg_verifybackup</command>
<arg rep="repeat"><replaceable>option</replaceable></arg> <arg rep="repeat"><replaceable>option</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
</refsynopsisdiv> </refsynopsisdiv>
...@@ -32,7 +32,7 @@ PostgreSQL documentation ...@@ -32,7 +32,7 @@ PostgreSQL documentation
Description Description
</title> </title>
<para> <para>
<application>pg_validatebackup</application> is used to check the <application>pg_verifybackup</application> is used to check the
integrity of a database cluster backup taken using integrity of a database cluster backup taken using
<command>pg_basebackup</command> against a <command>pg_basebackup</command> against a
<literal>backup_manifest</literal> generated by the server at the time <literal>backup_manifest</literal> generated by the server at the time
...@@ -41,27 +41,27 @@ PostgreSQL documentation ...@@ -41,27 +41,27 @@ PostgreSQL documentation
</para> </para>
<para> <para>
It is important to note that the validation which is performed by It is important to note that that the validation which is performed by
<application>pg_validatebackup</application> does not and can not include <application>pg_verifybackup</application> does not and can not include
every check which will be performed by a running server when attempting every check which will be performed by a running server when attempting
to make use of the backup. Even if you use this tool, you should still to make use of the backup. Even if you use this tool, you should still
perform test restores and verify that the resulting databases work as perform test restores and verify that the resulting databases work as
expected and that they appear to contain the correct data. However, expected and that they appear to contain the correct data. However,
<application>pg_validatebackup</application> can detect many problems <application>pg_verifybackup</application> can detect many problems
that commonly occur due to storage problems or user error. that commonly occur due to storage problems or user error.
</para> </para>
<para> <para>
Backup verification proceeds in four stages. First, Backup verification proceeds in four stages. First,
<literal>pg_validatebackup</literal> reads the <literal>pg_verifybackup</literal> reads the
<literal>backup_manifest</literal> file. If that file <literal>backup_manifest</literal> file. If that file
does not exist, cannot be read, is malformed, or fails verification does not exist, cannot be read, is malformed, or fails verification
against its own internal checksum, <literal>pg_validatebackup</literal> against its own internal checksum, <literal>pg_verifybackup</literal>
will terminate with a fatal error. will terminate with a fatal error.
</para> </para>
<para> <para>
Second, <literal>pg_validatebackup</literal> will attempt to verify that Second, <literal>pg_verifybackup</literal> will attempt to verify that
the data files currently stored on disk are exactly the same as the data the data files currently stored on disk are exactly the same as the data
files which the server intended to send, with some exceptions that are files which the server intended to send, with some exceptions that are
described below. Extra and missing files will be detected, with a few described below. Extra and missing files will be detected, with a few
...@@ -79,7 +79,7 @@ PostgreSQL documentation ...@@ -79,7 +79,7 @@ PostgreSQL documentation
</para> </para>
<para> <para>
Next, <literal>pg_validatebackup</literal> will checksum all the files, Next, <literal>pg_verifybackup</literal> will checksum all the files,
compare the checksums against the values in the manifest, and emit errors compare the checksums against the values in the manifest, and emit errors
for any files for which the computed checksum does not match the for any files for which the computed checksum does not match the
checksum stored in the manifest. This step is not performed for any files checksum stored in the manifest. This step is not performed for any files
...@@ -89,12 +89,12 @@ PostgreSQL documentation ...@@ -89,12 +89,12 @@ PostgreSQL documentation
</para> </para>
<para> <para>
Finally, <literal>pg_validatebackup</literal> will use the manifest to Finally, <literal>pg_verifybackup</literal> will use the manifest to
verify that the write-ahead log records which will be needed to recover verify that the write-ahead log records which will be needed to recover
the backup are present and that they can be read and parsed. The the backup are present and that they can be read and parsed. The
<literal>backup_manifest</literal> contains information about which <literal>backup_manifest</literal> contains information about which
write-ahead log records will be needed, and write-ahead log records will be needed, and
<literal>pg_validatebackup</literal> will use that information to <literal>pg_verifybackup</literal> will use that information to
invoke <literal>pg_waldump</literal> to parse those write-ahed log invoke <literal>pg_waldump</literal> to parse those write-ahed log
records. The <literal>--quiet</literal> flag will be used, so that records. The <literal>--quiet</literal> flag will be used, so that
<literal>pg_waldump</literal> will only report errors, without producing <literal>pg_waldump</literal> will only report errors, without producing
...@@ -112,7 +112,7 @@ PostgreSQL documentation ...@@ -112,7 +112,7 @@ PostgreSQL documentation
are present, they will not be checked by this tool, although are present, they will not be checked by this tool, although
a separate invocation of <literal>pg_waldump</literal> could be used for a separate invocation of <literal>pg_waldump</literal> could be used for
that purpose. Also note that WAL verification is version-specific: you that purpose. Also note that WAL verification is version-specific: you
must use the version of <literal>pg_validatebackup</literal>, and thus of must use the version of <literal>pg_verifybackup</literal>, and thus of
<literal>pg_waldump</literal>, which pertains to the backup being checked. <literal>pg_waldump</literal>, which pertains to the backup being checked.
In contrast, the data file integrity checks should work with any version In contrast, the data file integrity checks should work with any version
of the server that generates a <literal>backup_manifest</literal> file. of the server that generates a <literal>backup_manifest</literal> file.
...@@ -184,7 +184,7 @@ PostgreSQL documentation ...@@ -184,7 +184,7 @@ PostgreSQL documentation
<term><option>--quiet</option></term> <term><option>--quiet</option></term>
<listitem> <listitem>
<para> <para>
Don't print anything when a backup is successfully validated. Don't print anything when a backup is successfully verified.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -194,7 +194,7 @@ PostgreSQL documentation ...@@ -194,7 +194,7 @@ PostgreSQL documentation
<term><option>--skip-checksums</option></term> <term><option>--skip-checksums</option></term>
<listitem> <listitem>
<para> <para>
Do not validate data file checksums. The presence or absence of Do not verify data file checksums. The presence or absence of
files and the sizes of those files will still be checked. This is files and the sizes of those files will still be checked. This is
much faster, because the files themselves do not need to be read. much faster, because the files themselves do not need to be read.
</para> </para>
...@@ -224,7 +224,7 @@ PostgreSQL documentation ...@@ -224,7 +224,7 @@ PostgreSQL documentation
<term><option>--version</option></term> <term><option>--version</option></term>
<listitem> <listitem>
<para> <para>
Print the <application>pg_validatebackup</application> version and exit. Print the <application>pg_verifybackup</application> version and exit.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
...@@ -234,7 +234,7 @@ PostgreSQL documentation ...@@ -234,7 +234,7 @@ PostgreSQL documentation
<term><option>--help</option></term> <term><option>--help</option></term>
<listitem> <listitem>
<para> <para>
Show help about <application>pg_validatebackup</application> command Show help about <application>pg_verifybackup</application> command
line arguments, and exit. line arguments, and exit.
</para> </para>
</listitem> </listitem>
...@@ -250,31 +250,31 @@ PostgreSQL documentation ...@@ -250,31 +250,31 @@ PostgreSQL documentation
<para> <para>
To create a base backup of the server at <literal>mydbserver</literal> and To create a base backup of the server at <literal>mydbserver</literal> and
validate the integrity of the backup: verify the integrity of the backup:
<screen> <screen>
<prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</userinput> <prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</userinput>
<prompt>$</prompt> <userinput>pg_validatebackup /usr/local/pgsql/data</userinput> <prompt>$</prompt> <userinput>pg_verifybackup /usr/local/pgsql/data</userinput>
</screen> </screen>
</para> </para>
<para> <para>
To create a base backup of the server at <literal>mydbserver</literal>, move To create a base backup of the server at <literal>mydbserver</literal>, move
the manifest somewhere outside the backup directory, and validate the the manifest somewhere outside the backup directory, and verify the
backup: backup:
<screen> <screen>
<prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/backup1234</userinput> <prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/backup1234</userinput>
<prompt>$</prompt> <userinput>mv /usr/local/pgsql/backup1234/backup_manifest /my/secure/location/backup_manifest.1234</userinput> <prompt>$</prompt> <userinput>mv /usr/local/pgsql/backup1234/backup_manifest /my/secure/location/backup_manifest.1234</userinput>
<prompt>$</prompt> <userinput>pg_validatebackup -m /my/secure/location/backup_manifest.1234 /usr/local/pgsql/backup1234</userinput> <prompt>$</prompt> <userinput>pg_verifybackup -m /my/secure/location/backup_manifest.1234 /usr/local/pgsql/backup1234</userinput>
</screen> </screen>
</para> </para>
<para> <para>
To validate a backup while ignoring a file that was added manually to the To verify a backup while ignoring a file that was added manually to the
backup directory, and also skipping checksum verification: backup directory, and also skipping checksum verification:
<screen> <screen>
<prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</userinput> <prompt>$</prompt> <userinput>pg_basebackup -h mydbserver -D /usr/local/pgsql/data</userinput>
<prompt>$</prompt> <userinput>edit /usr/local/pgsql/data/note.to.self</userinput> <prompt>$</prompt> <userinput>edit /usr/local/pgsql/data/note.to.self</userinput>
<prompt>$</prompt> <userinput>pg_validatebackup --ignore=note.to.self --skip-checksums /usr/local/pgsql/data</userinput> <prompt>$</prompt> <userinput>pg_verifybackup --ignore=note.to.self --skip-checksums /usr/local/pgsql/data</userinput>
</screen> </screen>
</para> </para>
......
...@@ -255,7 +255,7 @@ ...@@ -255,7 +255,7 @@
&pgReceivewal; &pgReceivewal;
&pgRecvlogical; &pgRecvlogical;
&pgRestore; &pgRestore;
&pgValidateBackup; &pgVerifyBackup;
&psqlRef; &psqlRef;
&reindexdb; &reindexdb;
&vacuumdb; &vacuumdb;
......
...@@ -27,7 +27,7 @@ SUBDIRS = \ ...@@ -27,7 +27,7 @@ SUBDIRS = \
pg_test_fsync \ pg_test_fsync \
pg_test_timing \ pg_test_timing \
pg_upgrade \ pg_upgrade \
pg_validatebackup \ pg_verifybackup \
pg_waldump \ pg_waldump \
pgbench \ pgbench \
psql \ psql \
......
# src/bin/pg_validatebackup/Makefile # src/bin/pg_verifybackup/Makefile
PGFILEDESC = "pg_validatebackup - validate a backup against a backup manifest" PGFILEDESC = "pg_verifybackup - verify a backup against using a backup manifest"
PGAPPICON = win32 PGAPPICON = win32
subdir = src/bin/pg_validatebackup subdir = src/bin/pg_verifybackup
top_builddir = ../../.. top_builddir = ../../..
include $(top_builddir)/src/Makefile.global include $(top_builddir)/src/Makefile.global
...@@ -13,24 +13,24 @@ LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport) ...@@ -13,24 +13,24 @@ LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
OBJS = \ OBJS = \
$(WIN32RES) \ $(WIN32RES) \
parse_manifest.o \ parse_manifest.o \
pg_validatebackup.o pg_verifybackup.o
all: pg_validatebackup all: pg_verifybackup
pg_validatebackup: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils pg_verifybackup: $(OBJS) | submake-libpq submake-libpgport submake-libpgfeutils
$(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X) $(CC) $(CFLAGS) $^ $(LDFLAGS) $(LDFLAGS_EX) $(LIBS) -o $@$(X)
install: all installdirs install: all installdirs
$(INSTALL_PROGRAM) pg_validatebackup$(X) '$(DESTDIR)$(bindir)/pg_validatebackup$(X)' $(INSTALL_PROGRAM) pg_verifybackup$(X) '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
installdirs: installdirs:
$(MKDIR_P) '$(DESTDIR)$(bindir)' $(MKDIR_P) '$(DESTDIR)$(bindir)'
uninstall: uninstall:
rm -f '$(DESTDIR)$(bindir)/pg_validatebackup$(X)' rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
clean distclean maintainer-clean: clean distclean maintainer-clean:
rm -f pg_validatebackup$(X) $(OBJS) rm -f pg_verifybackup$(X) $(OBJS)
rm -rf tmp_check rm -rf tmp_check
check: check:
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* src/bin/pg_validatebackup/parse_manifest.c * src/bin/pg_verifybackup/parse_manifest.c
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
...@@ -151,7 +151,7 @@ json_parse_manifest(JsonManifestParseContext *context, char *buffer, ...@@ -151,7 +151,7 @@ json_parse_manifest(JsonManifestParseContext *context, char *buffer,
if (parse.state != JM_EXPECT_EOF) if (parse.state != JM_EXPECT_EOF)
json_manifest_parse_failure(context, "manifest ended unexpectedly"); json_manifest_parse_failure(context, "manifest ended unexpectedly");
/* Validate the checksum. */ /* Verify the manifest checksum. */
verify_manifest_checksum(&parse, buffer, size); verify_manifest_checksum(&parse, buffer, size);
} }
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group * Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California * Portions Copyright (c) 1994, Regents of the University of California
* *
* src/bin/pg_validatebackup/parse_manifest.h * src/bin/pg_verifybackup/parse_manifest.h
* *
*------------------------------------------------------------------------- *-------------------------------------------------------------------------
*/ */
......
...@@ -5,17 +5,17 @@ use Test::More tests => 16; ...@@ -5,17 +5,17 @@ use Test::More tests => 16;
my $tempdir = TestLib::tempdir; my $tempdir = TestLib::tempdir;
program_help_ok('pg_validatebackup'); program_help_ok('pg_verifybackup');
program_version_ok('pg_validatebackup'); program_version_ok('pg_verifybackup');
program_options_handling_ok('pg_validatebackup'); program_options_handling_ok('pg_verifybackup');
command_fails_like(['pg_validatebackup'], command_fails_like(['pg_verifybackup'],
qr/no backup directory specified/, qr/no backup directory specified/,
'target directory must be specified'); 'target directory must be specified');
command_fails_like(['pg_validatebackup', $tempdir], command_fails_like(['pg_verifybackup', $tempdir],
qr/could not open file.*\/backup_manifest\"/, qr/could not open file.*\/backup_manifest\"/,
'pg_validatebackup requires a manifest'); 'pg_verifybackup requires a manifest');
command_fails_like(['pg_validatebackup', $tempdir, $tempdir], command_fails_like(['pg_verifybackup', $tempdir, $tempdir],
qr/too many command-line arguments/, qr/too many command-line arguments/,
'multiple target directories not allowed'); 'multiple target directories not allowed');
...@@ -24,7 +24,7 @@ open(my $fh, '>', "$tempdir/backup_manifest") || die "open: $!"; ...@@ -24,7 +24,7 @@ open(my $fh, '>', "$tempdir/backup_manifest") || die "open: $!";
close($fh); close($fh);
# but then try to use an alternate, nonexisting manifest # but then try to use an alternate, nonexisting manifest
command_fails_like(['pg_validatebackup', '-m', "$tempdir/not_the_manifest", command_fails_like(['pg_verifybackup', '-m', "$tempdir/not_the_manifest",
$tempdir], $tempdir],
qr/could not open file.*\/not_the_manifest\"/, qr/could not open file.*\/not_the_manifest\"/,
'pg_validatebackup respects -m flag'); 'pg_verifybackup respects -m flag');
# Verify that we can take and validate backups with various checksum types. # Verify that we can take and verify backups with various checksum types.
use strict; use strict;
use warnings; use warnings;
...@@ -19,7 +19,7 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512)) ...@@ -19,7 +19,7 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
my @backup = ('pg_basebackup', '-D', $backup_path, my @backup = ('pg_basebackup', '-D', $backup_path,
'--manifest-checksums', $algorithm, '--manifest-checksums', $algorithm,
'--no-sync'); '--no-sync');
my @validate = ('pg_validatebackup', '-e', $backup_path); my @verify = ('pg_verifybackup', '-e', $backup_path);
# A backup with a bogus algorithm should fail. # A backup with a bogus algorithm should fail.
if ($algorithm eq 'bogus') if ($algorithm eq 'bogus')
...@@ -49,9 +49,9 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512)) ...@@ -49,9 +49,9 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
"$algorithm is mentioned many times in the manifest"); "$algorithm is mentioned many times in the manifest");
} }
# Make sure that it validates OK. # Make sure that it verifies OK.
$master->command_ok(\@validate, $master->command_ok(\@verify,
"validate backup with algorithm \"$algorithm\""); "verify backup with algorithm \"$algorithm\"");
# Remove backup immediately to save disk space. # Remove backup immediately to save disk space.
rmtree($backup_path); rmtree($backup_path);
......
# Verify that various forms of corruption are detected by pg_validatebackup. # Verify that various forms of corruption are detected by pg_verifybackup.
use strict; use strict;
use warnings; use warnings;
...@@ -105,7 +105,7 @@ for my $scenario (@scenario) ...@@ -105,7 +105,7 @@ for my $scenario (@scenario)
skip "unix-style permissions not supported on Windows", 4 skip "unix-style permissions not supported on Windows", 4
if $scenario->{'skip_on_windows'} && $windows_os; if $scenario->{'skip_on_windows'} && $windows_os;
# Take a backup and check that it validates OK. # Take a backup and check that it verifies OK.
my $backup_path = $master->backup_dir . '/' . $name; my $backup_path = $master->backup_dir . '/' . $name;
my $backup_ts_path = TestLib::perl2host(TestLib::tempdir_short()); my $backup_ts_path = TestLib::perl2host(TestLib::tempdir_short());
# The tablespace map parameter confuses Msys2, which tries to mangle # The tablespace map parameter confuses Msys2, which tries to mangle
...@@ -115,16 +115,16 @@ for my $scenario (@scenario) ...@@ -115,16 +115,16 @@ for my $scenario (@scenario)
$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync', $master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync',
'-T', "${source_ts_path}=${backup_ts_path}"], '-T', "${source_ts_path}=${backup_ts_path}"],
"base backup ok"); "base backup ok");
command_ok(['pg_validatebackup', $backup_path ], command_ok(['pg_verifybackup', $backup_path ],
"intact backup validated"); "intact backup verified");
# Mutilate the backup in some way. # Mutilate the backup in some way.
$scenario->{'mutilate'}->($backup_path); $scenario->{'mutilate'}->($backup_path);
# Now check that the backup no longer validates. # Now check that the backup no longer verifies.
command_fails_like(['pg_validatebackup', $backup_path ], command_fails_like(['pg_verifybackup', $backup_path ],
$scenario->{'fails_like'}, $scenario->{'fails_like'},
"corrupt backup fails validation: $name"); "corrupt backup fails verification: $name");
# Run cleanup hook, if provided. # Run cleanup hook, if provided.
$scenario->{'cleanup'}->($backup_path) $scenario->{'cleanup'}->($backup_path)
......
# Verify the behavior of assorted pg_validatebackup options. # Verify the behavior of assorted pg_verifybackup options.
use strict; use strict;
use warnings; use warnings;
...@@ -17,10 +17,10 @@ my $backup_path = $master->backup_dir . '/test_options'; ...@@ -17,10 +17,10 @@ my $backup_path = $master->backup_dir . '/test_options';
$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync' ], $master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync' ],
"base backup ok"); "base backup ok");
# Verify that pg_validatebackup -q succeeds and produces no output. # Verify that pg_verifybackup -q succeeds and produces no output.
my $stdout; my $stdout;
my $stderr; my $stderr;
my $result = IPC::Run::run ['pg_validatebackup', '-q', $backup_path ], my $result = IPC::Run::run ['pg_verifybackup', '-q', $backup_path ],
'>', \$stdout, '2>', \$stderr; '>', \$stdout, '2>', \$stderr;
ok($result, "-q succeeds: exit code 0"); ok($result, "-q succeeds: exit code 0");
is($stdout, '', "-q succeeds: no stdout"); is($stdout, '', "-q succeeds: no stdout");
...@@ -33,19 +33,19 @@ open(my $fh, '>', $version_pathname) || die "open $version_pathname: $!"; ...@@ -33,19 +33,19 @@ open(my $fh, '>', $version_pathname) || die "open $version_pathname: $!";
print $fh 'q' x length($version_contents); print $fh 'q' x length($version_contents);
close($fh); close($fh);
# Verify that pg_validatebackup -q now fails. # Verify that pg_verifybackup -q now fails.
command_fails_like(['pg_validatebackup', '-q', $backup_path ], command_fails_like(['pg_verifybackup', '-q', $backup_path ],
qr/checksum mismatch for file \"PG_VERSION\"/, qr/checksum mismatch for file \"PG_VERSION\"/,
'-q checksum mismatch'); '-q checksum mismatch');
# Since we didn't change the length of the file, validation should succeed # Since we didn't change the length of the file, verification should succeed
# if we ignore checksums. Check that we get the right message, too. # if we ignore checksums. Check that we get the right message, too.
command_like(['pg_validatebackup', '-s', $backup_path ], command_like(['pg_verifybackup', '-s', $backup_path ],
qr/backup successfully verified/, qr/backup successfully verified/,
'-s skips checksumming'); '-s skips checksumming');
# Validation should succeed if we ignore the problem file. # Validation should succeed if we ignore the problem file.
command_like(['pg_validatebackup', '-i', 'PG_VERSION', $backup_path ], command_like(['pg_verifybackup', '-i', 'PG_VERSION', $backup_path ],
qr/backup successfully verified/, qr/backup successfully verified/,
'-i ignores problem file'); '-i ignores problem file');
...@@ -53,19 +53,19 @@ command_like(['pg_validatebackup', '-i', 'PG_VERSION', $backup_path ], ...@@ -53,19 +53,19 @@ command_like(['pg_validatebackup', '-i', 'PG_VERSION', $backup_path ],
rmtree($backup_path . "/pg_xact"); rmtree($backup_path . "/pg_xact");
# We're ignoring the problem with PG_VERSION, but not the problem with # We're ignoring the problem with PG_VERSION, but not the problem with
# pg_xact, so validation should fail here. # pg_xact, so verification should fail here.
command_fails_like(['pg_validatebackup', '-i', 'PG_VERSION', $backup_path ], command_fails_like(['pg_verifybackup', '-i', 'PG_VERSION', $backup_path ],
qr/pg_xact.*is present in the manifest but not on disk/, qr/pg_xact.*is present in the manifest but not on disk/,
'-i does not ignore all problems'); '-i does not ignore all problems');
# If we use -i twice, we should be able to ignore all of the problems. # If we use -i twice, we should be able to ignore all of the problems.
command_like(['pg_validatebackup', '-i', 'PG_VERSION', '-i', 'pg_xact', command_like(['pg_verifybackup', '-i', 'PG_VERSION', '-i', 'pg_xact',
$backup_path ], $backup_path ],
qr/backup successfully verified/, qr/backup successfully verified/,
'multiple -i options work'); 'multiple -i options work');
# Verify that when -i is not used, both problems are reported. # Verify that when -i is not used, both problems are reported.
$result = IPC::Run::run ['pg_validatebackup', $backup_path ], $result = IPC::Run::run ['pg_verifybackup', $backup_path ],
'>', \$stdout, '2>', \$stderr; '>', \$stdout, '2>', \$stderr;
ok(!$result, "multiple problems: fails"); ok(!$result, "multiple problems: fails");
like($stderr, qr/pg_xact.*is present in the manifest but not on disk/, like($stderr, qr/pg_xact.*is present in the manifest but not on disk/,
...@@ -74,7 +74,7 @@ like($stderr, qr/checksum mismatch for file \"PG_VERSION\"/, ...@@ -74,7 +74,7 @@ like($stderr, qr/checksum mismatch for file \"PG_VERSION\"/,
"multiple problems: checksum mismatch reported"); "multiple problems: checksum mismatch reported");
# Verify that when -e is used, only the problem detected first is reported. # Verify that when -e is used, only the problem detected first is reported.
$result = IPC::Run::run ['pg_validatebackup', '-e', $backup_path ], $result = IPC::Run::run ['pg_verifybackup', '-e', $backup_path ],
'>', \$stdout, '2>', \$stderr; '>', \$stdout, '2>', \$stderr;
ok(!$result, "-e reports 1 error: fails"); ok(!$result, "-e reports 1 error: fails");
like($stderr, qr/pg_xact.*is present in the manifest but not on disk/, like($stderr, qr/pg_xact.*is present in the manifest but not on disk/,
...@@ -83,7 +83,7 @@ unlike($stderr, qr/checksum mismatch for file \"PG_VERSION\"/, ...@@ -83,7 +83,7 @@ unlike($stderr, qr/checksum mismatch for file \"PG_VERSION\"/,
"-e reports 1 error: checksum mismatch not reported"); "-e reports 1 error: checksum mismatch not reported");
# Test valid manifest with nonexistent backup directory. # Test valid manifest with nonexistent backup directory.
command_fails_like(['pg_validatebackup', '-m', "$backup_path/backup_manifest", command_fails_like(['pg_verifybackup', '-m', "$backup_path/backup_manifest",
"$backup_path/fake" ], "$backup_path/fake" ],
qr/could not open directory/, qr/could not open directory/,
'nonexistent backup directory'); 'nonexistent backup directory');
# Test the behavior of pg_validatebackup when the backup manifest has # Test the behavior of pg_verifybackup when the backup manifest has
# problems. # problems.
use strict; use strict;
...@@ -198,7 +198,7 @@ sub test_bad_manifest ...@@ -198,7 +198,7 @@ sub test_bad_manifest
print $fh $manifest_contents; print $fh $manifest_contents;
close($fh); close($fh);
command_fails_like(['pg_validatebackup', $tempdir], $regexp, command_fails_like(['pg_verifybackup', $tempdir], $regexp,
$test_name); $test_name);
return; return;
} }
# Verify that pg_validatebackup handles hex-encoded filenames correctly. # Verify that pg_verifybackup handles hex-encoded filenames correctly.
use strict; use strict;
use warnings; use warnings;
...@@ -22,6 +22,6 @@ my $count_of_encoded_path_in_manifest = ...@@ -22,6 +22,6 @@ my $count_of_encoded_path_in_manifest =
cmp_ok($count_of_encoded_path_in_manifest, '>', 100, cmp_ok($count_of_encoded_path_in_manifest, '>', 100,
"many paths are encoded in the manifest"); "many paths are encoded in the manifest");
command_like(['pg_validatebackup', '-s', $backup_path ], command_like(['pg_verifybackup', '-s', $backup_path ],
qr/backup successfully verified/, qr/backup successfully verified/,
'backup with forced encoding validated'); 'backup with forced encoding verified');
# Test pg_validatebackup's WAL validation. # Test pg_verifybackup's WAL verification.
use strict; use strict;
use warnings; use warnings;
...@@ -22,17 +22,17 @@ my $original_pg_wal = $backup_path . '/pg_wal'; ...@@ -22,17 +22,17 @@ my $original_pg_wal = $backup_path . '/pg_wal';
my $relocated_pg_wal = $master->backup_dir . '/relocated_pg_wal'; my $relocated_pg_wal = $master->backup_dir . '/relocated_pg_wal';
rename($original_pg_wal, $relocated_pg_wal) || die "rename pg_wal: $!"; rename($original_pg_wal, $relocated_pg_wal) || die "rename pg_wal: $!";
# WAL validation should fail. # WAL verification should fail.
command_fails_like(['pg_validatebackup', $backup_path ], command_fails_like(['pg_verifybackup', $backup_path ],
qr/WAL parsing failed for timeline 1/, qr/WAL parsing failed for timeline 1/,
'missing pg_wal causes failure'); 'missing pg_wal causes failure');
# Should work if we skip WAL verification. # Should work if we skip WAL verification.
command_ok(['pg_validatebackup', '-n', $backup_path ], command_ok(['pg_verifybackup', '-n', $backup_path ],
'missing pg_wal OK if not verifying WAL'); 'missing pg_wal OK if not verifying WAL');
# Should also work if we specify the correct WAL location. # Should also work if we specify the correct WAL location.
command_ok(['pg_validatebackup', '-w', $relocated_pg_wal, $backup_path ], command_ok(['pg_verifybackup', '-w', $relocated_pg_wal, $backup_path ],
'-w can be used to specify WAL directory'); '-w can be used to specify WAL directory');
# Move directory back to original location. # Move directory back to original location.
...@@ -49,7 +49,7 @@ open(my $fh, '>', $wal_corruption_target) ...@@ -49,7 +49,7 @@ open(my $fh, '>', $wal_corruption_target)
print $fh 'w' x $wal_size; print $fh 'w' x $wal_size;
close($fh); close($fh);
# WAL validation should fail. # WAL verification should fail.
command_fails_like(['pg_validatebackup', $backup_path ], command_fails_like(['pg_verifybackup', $backup_path ],
qr/WAL parsing failed for timeline 1/, qr/WAL parsing failed for timeline 1/,
'corrupt WAL file causes failure'); 'corrupt WAL file causes failure');
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment