mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
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
This commit is contained in:
@ -27,7 +27,7 @@ SUBDIRS = \
|
||||
pg_test_fsync \
|
||||
pg_test_timing \
|
||||
pg_upgrade \
|
||||
pg_validatebackup \
|
||||
pg_verifybackup \
|
||||
pg_waldump \
|
||||
pgbench \
|
||||
psql \
|
||||
|
2
src/bin/pg_validatebackup/.gitignore
vendored
2
src/bin/pg_validatebackup/.gitignore
vendored
@ -1,2 +0,0 @@
|
||||
/pg_validatebackup
|
||||
/tmp_check/
|
2
src/bin/pg_verifybackup/.gitignore
vendored
Normal file
2
src/bin/pg_verifybackup/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/pg_verifybackup
|
||||
/tmp_check/
|
@ -1,9 +1,9 @@
|
||||
# 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
|
||||
|
||||
subdir = src/bin/pg_validatebackup
|
||||
subdir = src/bin/pg_verifybackup
|
||||
top_builddir = ../../..
|
||||
include $(top_builddir)/src/Makefile.global
|
||||
|
||||
@ -13,24 +13,24 @@ LDFLAGS_INTERNAL += -L$(top_builddir)/src/fe_utils -lpgfeutils $(libpq_pgport)
|
||||
OBJS = \
|
||||
$(WIN32RES) \
|
||||
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)
|
||||
|
||||
install: all installdirs
|
||||
$(INSTALL_PROGRAM) pg_validatebackup$(X) '$(DESTDIR)$(bindir)/pg_validatebackup$(X)'
|
||||
$(INSTALL_PROGRAM) pg_verifybackup$(X) '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
|
||||
|
||||
installdirs:
|
||||
$(MKDIR_P) '$(DESTDIR)$(bindir)'
|
||||
|
||||
uninstall:
|
||||
rm -f '$(DESTDIR)$(bindir)/pg_validatebackup$(X)'
|
||||
rm -f '$(DESTDIR)$(bindir)/pg_verifybackup$(X)'
|
||||
|
||||
clean distclean maintainer-clean:
|
||||
rm -f pg_validatebackup$(X) $(OBJS)
|
||||
rm -f pg_verifybackup$(X) $(OBJS)
|
||||
rm -rf tmp_check
|
||||
|
||||
check:
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
* 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,
|
||||
if (parse.state != JM_EXPECT_EOF)
|
||||
json_manifest_parse_failure(context, "manifest ended unexpectedly");
|
||||
|
||||
/* Validate the checksum. */
|
||||
/* Verify the manifest checksum. */
|
||||
verify_manifest_checksum(&parse, buffer, size);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/bin/pg_validatebackup/parse_manifest.h
|
||||
* src/bin/pg_verifybackup/parse_manifest.h
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
@ -1,12 +1,12 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pg_validatebackup.c
|
||||
* Validate a backup against a backup manifest.
|
||||
* pg_verifybackup.c
|
||||
* Verify a backup against a backup manifest.
|
||||
*
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* src/bin/pg_validatebackup/pg_validatebackup.c
|
||||
* src/bin/pg_verifybackup/pg_verifybackup.c
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -101,14 +101,14 @@ typedef struct parser_context
|
||||
/*
|
||||
* All of the context information we need while checking a backup manifest.
|
||||
*/
|
||||
typedef struct validator_context
|
||||
typedef struct verifier_context
|
||||
{
|
||||
manifest_files_hash *ht;
|
||||
char *backup_directory;
|
||||
SimpleStringList ignore_list;
|
||||
bool exit_on_error;
|
||||
bool saw_any_error;
|
||||
} validator_context;
|
||||
} verifier_context;
|
||||
|
||||
static void parse_manifest_file(char *manifest_path,
|
||||
manifest_files_hash **ht_p,
|
||||
@ -127,25 +127,25 @@ static void report_manifest_error(JsonManifestParseContext *context,
|
||||
char *fmt,...)
|
||||
pg_attribute_printf(2, 3) pg_attribute_noreturn();
|
||||
|
||||
static void validate_backup_directory(validator_context *context,
|
||||
char *relpath, char *fullpath);
|
||||
static void validate_backup_file(validator_context *context,
|
||||
char *relpath, char *fullpath);
|
||||
static void report_extra_backup_files(validator_context *context);
|
||||
static void validate_backup_checksums(validator_context *context);
|
||||
static void validate_file_checksum(validator_context *context,
|
||||
manifest_file *m, char *pathname);
|
||||
static void parse_required_wal(validator_context *context,
|
||||
static void verify_backup_directory(verifier_context *context,
|
||||
char *relpath, char *fullpath);
|
||||
static void verify_backup_file(verifier_context *context,
|
||||
char *relpath, char *fullpath);
|
||||
static void report_extra_backup_files(verifier_context *context);
|
||||
static void verify_backup_checksums(verifier_context *context);
|
||||
static void verify_file_checksum(verifier_context *context,
|
||||
manifest_file *m, char *pathname);
|
||||
static void parse_required_wal(verifier_context *context,
|
||||
char *pg_waldump_path,
|
||||
char *wal_directory,
|
||||
manifest_wal_range *first_wal_range);
|
||||
|
||||
static void report_backup_error(validator_context *context,
|
||||
static void report_backup_error(verifier_context *context,
|
||||
const char *pg_restrict fmt,...)
|
||||
pg_attribute_printf(2, 3);
|
||||
static void report_fatal_error(const char *pg_restrict fmt,...)
|
||||
pg_attribute_printf(1, 2) pg_attribute_noreturn();
|
||||
static bool should_ignore_relpath(validator_context *context, char *relpath);
|
||||
static bool should_ignore_relpath(verifier_context *context, char *relpath);
|
||||
|
||||
static void usage(void);
|
||||
|
||||
@ -170,7 +170,7 @@ main(int argc, char **argv)
|
||||
};
|
||||
|
||||
int c;
|
||||
validator_context context;
|
||||
verifier_context context;
|
||||
manifest_wal_range *first_wal_range;
|
||||
char *manifest_path = NULL;
|
||||
bool no_parse_wal = false;
|
||||
@ -180,7 +180,7 @@ main(int argc, char **argv)
|
||||
char *pg_waldump_path = NULL;
|
||||
|
||||
pg_logging_init(argv[0]);
|
||||
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_validatebackup"));
|
||||
set_pglocale_pgservice(argv[0], PG_TEXTDOMAIN("pg_verifybackup"));
|
||||
progname = get_progname(argv[0]);
|
||||
|
||||
memset(&context, 0, sizeof(context));
|
||||
@ -194,7 +194,7 @@ main(int argc, char **argv)
|
||||
}
|
||||
if (strcmp(argv[1], "--version") == 0 || strcmp(argv[1], "-V") == 0)
|
||||
{
|
||||
puts("pg_validatebackup (PostgreSQL) " PG_VERSION);
|
||||
puts("pg_verifybackup (PostgreSQL) " PG_VERSION);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
@ -207,7 +207,7 @@ main(int argc, char **argv)
|
||||
*
|
||||
* Ignore the pg_wal directory, because those files are not included in
|
||||
* the backup manifest either, since they are fetched separately from the
|
||||
* backup itself, and validated via a separate mechanism.
|
||||
* backup itself, and verified via a separate mechanism.
|
||||
*
|
||||
* Ignore postgresql.auto.conf, recovery.signal, and standby.signal,
|
||||
* because we expect that those files may sometimes be created or changed
|
||||
@ -299,12 +299,12 @@ main(int argc, char **argv)
|
||||
pg_log_fatal("The program \"%s\" is needed by %s but was\n"
|
||||
"not found in the same directory as \"%s\".\n"
|
||||
"Check your installation.",
|
||||
"pg_waldump", "pg_validatebackup", full_path);
|
||||
"pg_waldump", "pg_verifybackup", full_path);
|
||||
else
|
||||
pg_log_fatal("The program \"%s\" was found by \"%s\" but was\n"
|
||||
"not the same version as %s.\n"
|
||||
"Check your installation.",
|
||||
"pg_waldump", full_path, "pg_validatebackup");
|
||||
"pg_waldump", full_path, "pg_verifybackup");
|
||||
}
|
||||
}
|
||||
|
||||
@ -320,7 +320,7 @@ main(int argc, char **argv)
|
||||
/*
|
||||
* Try to read the manifest. We treat any errors encountered while parsing
|
||||
* the manifest as fatal; there doesn't seem to be much point in trying to
|
||||
* validate the backup directory against a corrupted manifest.
|
||||
* verify the backup directory against a corrupted manifest.
|
||||
*/
|
||||
parse_manifest_file(manifest_path, &context.ht, &first_wal_range);
|
||||
|
||||
@ -330,7 +330,7 @@ main(int argc, char **argv)
|
||||
* match. We also set the "matched" flag on every manifest entry that
|
||||
* corresponds to a file on disk.
|
||||
*/
|
||||
validate_backup_directory(&context, NULL, context.backup_directory);
|
||||
verify_backup_directory(&context, NULL, context.backup_directory);
|
||||
|
||||
/*
|
||||
* The "matched" flag should now be set on every entry in the hash table.
|
||||
@ -344,7 +344,7 @@ main(int argc, char **argv)
|
||||
* told to skip it.
|
||||
*/
|
||||
if (!skip_checksums)
|
||||
validate_backup_checksums(&context);
|
||||
verify_backup_checksums(&context);
|
||||
|
||||
/*
|
||||
* Try to parse the required ranges of WAL records, unless we were told
|
||||
@ -512,17 +512,17 @@ record_manifest_details_for_wal_range(JsonManifestParseContext *context,
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate one directory.
|
||||
* Verify one directory.
|
||||
*
|
||||
* 'relpath' is NULL if we are to validate the top-level backup directory,
|
||||
* and otherwise the relative path to the directory that is to be validated.
|
||||
* 'relpath' is NULL if we are to verify the top-level backup directory,
|
||||
* and otherwise the relative path to the directory that is to be verified.
|
||||
*
|
||||
* 'fullpath' is the backup directory with 'relpath' appended; i.e. the actual
|
||||
* filesystem path at which it can be found.
|
||||
*/
|
||||
static void
|
||||
validate_backup_directory(validator_context *context, char *relpath,
|
||||
char *fullpath)
|
||||
verify_backup_directory(verifier_context *context, char *relpath,
|
||||
char *fullpath)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *dirent;
|
||||
@ -565,7 +565,7 @@ validate_backup_directory(validator_context *context, char *relpath,
|
||||
newrelpath = psprintf("%s/%s", relpath, filename);
|
||||
|
||||
if (!should_ignore_relpath(context, newrelpath))
|
||||
validate_backup_file(context, newrelpath, newfullpath);
|
||||
verify_backup_file(context, newrelpath, newfullpath);
|
||||
|
||||
pfree(newfullpath);
|
||||
pfree(newrelpath);
|
||||
@ -580,13 +580,13 @@ validate_backup_directory(validator_context *context, char *relpath,
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate one file (which might actually be a directory or a symlink).
|
||||
* Verify one file (which might actually be a directory or a symlink).
|
||||
*
|
||||
* The arguments to this function have the same meaning as the arguments to
|
||||
* validate_backup_directory.
|
||||
* verify_backup_directory.
|
||||
*/
|
||||
static void
|
||||
validate_backup_file(validator_context *context, char *relpath, char *fullpath)
|
||||
verify_backup_file(verifier_context *context, char *relpath, char *fullpath)
|
||||
{
|
||||
struct stat sb;
|
||||
manifest_file *m;
|
||||
@ -609,7 +609,7 @@ validate_backup_file(validator_context *context, char *relpath, char *fullpath)
|
||||
/* If it's a directory, just recurse. */
|
||||
if (S_ISDIR(sb.st_mode))
|
||||
{
|
||||
validate_backup_directory(context, relpath, fullpath);
|
||||
verify_backup_directory(context, relpath, fullpath);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -645,7 +645,7 @@ validate_backup_file(validator_context *context, char *relpath, char *fullpath)
|
||||
}
|
||||
|
||||
/*
|
||||
* We don't validate checksums at this stage. We first finish validating
|
||||
* We don't verify checksums at this stage. We first finish verifying
|
||||
* that we have the expected set of files with the expected sizes, and
|
||||
* only afterwards verify the checksums. That's because computing
|
||||
* checksums may take a while, and we'd like to report more obvious
|
||||
@ -658,7 +658,7 @@ validate_backup_file(validator_context *context, char *relpath, char *fullpath)
|
||||
* that such files are present in the manifest but not on disk.
|
||||
*/
|
||||
static void
|
||||
report_extra_backup_files(validator_context *context)
|
||||
report_extra_backup_files(verifier_context *context)
|
||||
{
|
||||
manifest_files_iterator it;
|
||||
manifest_file *m;
|
||||
@ -672,12 +672,12 @@ report_extra_backup_files(validator_context *context)
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate checksums for hash table entries that are otherwise unproblematic.
|
||||
* Verify checksums for hash table entries that are otherwise unproblematic.
|
||||
* If we've already reported some problem related to a hash table entry, or
|
||||
* if it has no checksum, just skip it.
|
||||
*/
|
||||
static void
|
||||
validate_backup_checksums(validator_context *context)
|
||||
verify_backup_checksums(verifier_context *context)
|
||||
{
|
||||
manifest_files_iterator it;
|
||||
manifest_file *m;
|
||||
@ -694,8 +694,8 @@ validate_backup_checksums(validator_context *context)
|
||||
fullpath = psprintf("%s/%s", context->backup_directory,
|
||||
m->pathname);
|
||||
|
||||
/* Do the actual checksum validation. */
|
||||
validate_file_checksum(context, m, fullpath);
|
||||
/* Do the actual checksum verification. */
|
||||
verify_file_checksum(context, m, fullpath);
|
||||
|
||||
/* Avoid leaking memory. */
|
||||
pfree(fullpath);
|
||||
@ -704,10 +704,10 @@ validate_backup_checksums(validator_context *context)
|
||||
}
|
||||
|
||||
/*
|
||||
* Validate the checksum of a single file.
|
||||
* Verify the checksum of a single file.
|
||||
*/
|
||||
static void
|
||||
validate_file_checksum(validator_context *context, manifest_file *m,
|
||||
verify_file_checksum(verifier_context *context, manifest_file *m,
|
||||
char *fullpath)
|
||||
{
|
||||
pg_checksum_context checksum_ctx;
|
||||
@ -754,7 +754,7 @@ validate_file_checksum(validator_context *context, manifest_file *m,
|
||||
|
||||
/*
|
||||
* Double-check that we read the expected number of bytes from the file.
|
||||
* Normally, a file size mismatch would be caught in validate_backup_file
|
||||
* Normally, a file size mismatch would be caught in verify_backup_file
|
||||
* and this check would never be reached, but this provides additional
|
||||
* safety and clarity in the event of concurrent modifications or
|
||||
* filesystem misbehavior.
|
||||
@ -786,7 +786,7 @@ validate_file_checksum(validator_context *context, manifest_file *m,
|
||||
* pg_waldump.
|
||||
*/
|
||||
static void
|
||||
parse_required_wal(validator_context *context, char *pg_waldump_path,
|
||||
parse_required_wal(verifier_context *context, char *pg_waldump_path,
|
||||
char *wal_directory, manifest_wal_range *first_wal_range)
|
||||
{
|
||||
manifest_wal_range *this_wal_range = first_wal_range;
|
||||
@ -817,7 +817,7 @@ parse_required_wal(validator_context *context, char *pg_waldump_path,
|
||||
* context says we should.
|
||||
*/
|
||||
static void
|
||||
report_backup_error(validator_context *context, const char *pg_restrict fmt,...)
|
||||
report_backup_error(verifier_context *context, const char *pg_restrict fmt,...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
@ -853,7 +853,7 @@ report_fatal_error(const char *pg_restrict fmt,...)
|
||||
* "aa/bb" is not a prefix of "aa/bbb", but it is a prefix of "aa/bb/cc".
|
||||
*/
|
||||
static bool
|
||||
should_ignore_relpath(validator_context *context, char *relpath)
|
||||
should_ignore_relpath(verifier_context *context, char *relpath)
|
||||
{
|
||||
SimpleStringListCell *cell;
|
||||
|
||||
@ -889,7 +889,7 @@ hash_string_pointer(char *s)
|
||||
static void
|
||||
usage(void)
|
||||
{
|
||||
printf(_("%s validates a backup against the backup manifest.\n\n"), progname);
|
||||
printf(_("%s verifies a backup against the backup manifest.\n\n"), progname);
|
||||
printf(_("Usage:\n %s [OPTION]... BACKUPDIR\n\n"), progname);
|
||||
printf(_("Options:\n"));
|
||||
printf(_(" -e, --exit-on-error exit immediately on error\n"));
|
@ -5,17 +5,17 @@ use Test::More tests => 16;
|
||||
|
||||
my $tempdir = TestLib::tempdir;
|
||||
|
||||
program_help_ok('pg_validatebackup');
|
||||
program_version_ok('pg_validatebackup');
|
||||
program_options_handling_ok('pg_validatebackup');
|
||||
program_help_ok('pg_verifybackup');
|
||||
program_version_ok('pg_verifybackup');
|
||||
program_options_handling_ok('pg_verifybackup');
|
||||
|
||||
command_fails_like(['pg_validatebackup'],
|
||||
command_fails_like(['pg_verifybackup'],
|
||||
qr/no backup directory 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\"/,
|
||||
'pg_validatebackup requires a manifest');
|
||||
command_fails_like(['pg_validatebackup', $tempdir, $tempdir],
|
||||
'pg_verifybackup requires a manifest');
|
||||
command_fails_like(['pg_verifybackup', $tempdir, $tempdir],
|
||||
qr/too many command-line arguments/,
|
||||
'multiple target directories not allowed');
|
||||
|
||||
@ -24,7 +24,7 @@ open(my $fh, '>', "$tempdir/backup_manifest") || die "open: $!";
|
||||
close($fh);
|
||||
|
||||
# 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],
|
||||
qr/could not open file.*\/not_the_manifest\"/,
|
||||
'pg_validatebackup respects -m flag');
|
||||
'pg_verifybackup respects -m flag');
|
@ -1,4 +1,4 @@
|
||||
# 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 warnings;
|
||||
@ -19,7 +19,7 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
|
||||
my @backup = ('pg_basebackup', '-D', $backup_path,
|
||||
'--manifest-checksums', $algorithm,
|
||||
'--no-sync');
|
||||
my @validate = ('pg_validatebackup', '-e', $backup_path);
|
||||
my @verify = ('pg_verifybackup', '-e', $backup_path);
|
||||
|
||||
# A backup with a bogus algorithm should fail.
|
||||
if ($algorithm eq 'bogus')
|
||||
@ -49,9 +49,9 @@ for my $algorithm (qw(bogus none crc32c sha224 sha256 sha384 sha512))
|
||||
"$algorithm is mentioned many times in the manifest");
|
||||
}
|
||||
|
||||
# Make sure that it validates OK.
|
||||
$master->command_ok(\@validate,
|
||||
"validate backup with algorithm \"$algorithm\"");
|
||||
# Make sure that it verifies OK.
|
||||
$master->command_ok(\@verify,
|
||||
"verify backup with algorithm \"$algorithm\"");
|
||||
|
||||
# Remove backup immediately to save disk space.
|
||||
rmtree($backup_path);
|
@ -1,4 +1,4 @@
|
||||
# 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 warnings;
|
||||
@ -105,7 +105,7 @@ for my $scenario (@scenario)
|
||||
skip "unix-style permissions not supported on Windows", 4
|
||||
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_ts_path = TestLib::perl2host(TestLib::tempdir_short());
|
||||
# The tablespace map parameter confuses Msys2, which tries to mangle
|
||||
@ -115,16 +115,16 @@ for my $scenario (@scenario)
|
||||
$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync',
|
||||
'-T', "${source_ts_path}=${backup_ts_path}"],
|
||||
"base backup ok");
|
||||
command_ok(['pg_validatebackup', $backup_path ],
|
||||
"intact backup validated");
|
||||
command_ok(['pg_verifybackup', $backup_path ],
|
||||
"intact backup verified");
|
||||
|
||||
# Mutilate the backup in some way.
|
||||
$scenario->{'mutilate'}->($backup_path);
|
||||
|
||||
# Now check that the backup no longer validates.
|
||||
command_fails_like(['pg_validatebackup', $backup_path ],
|
||||
# Now check that the backup no longer verifies.
|
||||
command_fails_like(['pg_verifybackup', $backup_path ],
|
||||
$scenario->{'fails_like'},
|
||||
"corrupt backup fails validation: $name");
|
||||
"corrupt backup fails verification: $name");
|
||||
|
||||
# Run cleanup hook, if provided.
|
||||
$scenario->{'cleanup'}->($backup_path)
|
@ -1,4 +1,4 @@
|
||||
# Verify the behavior of assorted pg_validatebackup options.
|
||||
# Verify the behavior of assorted pg_verifybackup options.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -17,10 +17,10 @@ my $backup_path = $master->backup_dir . '/test_options';
|
||||
$master->command_ok(['pg_basebackup', '-D', $backup_path, '--no-sync' ],
|
||||
"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 $stderr;
|
||||
my $result = IPC::Run::run ['pg_validatebackup', '-q', $backup_path ],
|
||||
my $result = IPC::Run::run ['pg_verifybackup', '-q', $backup_path ],
|
||||
'>', \$stdout, '2>', \$stderr;
|
||||
ok($result, "-q succeeds: exit code 0");
|
||||
is($stdout, '', "-q succeeds: no stdout");
|
||||
@ -33,19 +33,19 @@ open(my $fh, '>', $version_pathname) || die "open $version_pathname: $!";
|
||||
print $fh 'q' x length($version_contents);
|
||||
close($fh);
|
||||
|
||||
# Verify that pg_validatebackup -q now fails.
|
||||
command_fails_like(['pg_validatebackup', '-q', $backup_path ],
|
||||
# Verify that pg_verifybackup -q now fails.
|
||||
command_fails_like(['pg_verifybackup', '-q', $backup_path ],
|
||||
qr/checksum mismatch for file \"PG_VERSION\"/,
|
||||
'-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.
|
||||
command_like(['pg_validatebackup', '-s', $backup_path ],
|
||||
command_like(['pg_verifybackup', '-s', $backup_path ],
|
||||
qr/backup successfully verified/,
|
||||
'-s skips checksumming');
|
||||
|
||||
# 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/,
|
||||
'-i ignores problem file');
|
||||
|
||||
@ -53,19 +53,19 @@ command_like(['pg_validatebackup', '-i', 'PG_VERSION', $backup_path ],
|
||||
rmtree($backup_path . "/pg_xact");
|
||||
|
||||
# We're ignoring the problem with PG_VERSION, but not the problem with
|
||||
# pg_xact, so validation should fail here.
|
||||
command_fails_like(['pg_validatebackup', '-i', 'PG_VERSION', $backup_path ],
|
||||
# pg_xact, so verification should fail here.
|
||||
command_fails_like(['pg_verifybackup', '-i', 'PG_VERSION', $backup_path ],
|
||||
qr/pg_xact.*is present in the manifest but not on disk/,
|
||||
'-i does not ignore all 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 ],
|
||||
qr/backup successfully verified/,
|
||||
'multiple -i options work');
|
||||
|
||||
# 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;
|
||||
ok(!$result, "multiple problems: fails");
|
||||
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\"/,
|
||||
"multiple problems: checksum mismatch 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;
|
||||
ok(!$result, "-e reports 1 error: fails");
|
||||
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\"/,
|
||||
"-e reports 1 error: checksum mismatch not reported");
|
||||
|
||||
# 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" ],
|
||||
qr/could not open directory/,
|
||||
'nonexistent backup directory');
|
@ -1,4 +1,4 @@
|
||||
# Test the behavior of pg_validatebackup when the backup manifest has
|
||||
# Test the behavior of pg_verifybackup when the backup manifest has
|
||||
# problems.
|
||||
|
||||
use strict;
|
||||
@ -198,7 +198,7 @@ sub test_bad_manifest
|
||||
print $fh $manifest_contents;
|
||||
close($fh);
|
||||
|
||||
command_fails_like(['pg_validatebackup', $tempdir], $regexp,
|
||||
command_fails_like(['pg_verifybackup', $tempdir], $regexp,
|
||||
$test_name);
|
||||
return;
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
# Verify that pg_validatebackup handles hex-encoded filenames correctly.
|
||||
# Verify that pg_verifybackup handles hex-encoded filenames correctly.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -22,6 +22,6 @@ my $count_of_encoded_path_in_manifest =
|
||||
cmp_ok($count_of_encoded_path_in_manifest, '>', 100,
|
||||
"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/,
|
||||
'backup with forced encoding validated');
|
||||
'backup with forced encoding verified');
|
@ -1,4 +1,4 @@
|
||||
# Test pg_validatebackup's WAL validation.
|
||||
# Test pg_verifybackup's WAL verification.
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
@ -22,17 +22,17 @@ my $original_pg_wal = $backup_path . '/pg_wal';
|
||||
my $relocated_pg_wal = $master->backup_dir . '/relocated_pg_wal';
|
||||
rename($original_pg_wal, $relocated_pg_wal) || die "rename pg_wal: $!";
|
||||
|
||||
# WAL validation should fail.
|
||||
command_fails_like(['pg_validatebackup', $backup_path ],
|
||||
# WAL verification should fail.
|
||||
command_fails_like(['pg_verifybackup', $backup_path ],
|
||||
qr/WAL parsing failed for timeline 1/,
|
||||
'missing pg_wal causes failure');
|
||||
|
||||
# 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');
|
||||
|
||||
# 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');
|
||||
|
||||
# Move directory back to original location.
|
||||
@ -49,7 +49,7 @@ open(my $fh, '>', $wal_corruption_target)
|
||||
print $fh 'w' x $wal_size;
|
||||
close($fh);
|
||||
|
||||
# WAL validation should fail.
|
||||
command_fails_like(['pg_validatebackup', $backup_path ],
|
||||
# WAL verification should fail.
|
||||
command_fails_like(['pg_verifybackup', $backup_path ],
|
||||
qr/WAL parsing failed for timeline 1/,
|
||||
'corrupt WAL file causes failure');
|
Reference in New Issue
Block a user