PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <dirent.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <time.h>
#include "common/hashfn.h"
#include "common/logging.h"
#include "fe_utils/simple_list.h"
#include "getopt_long.h"
#include "parse_manifest.h"
#include "pgtime.h"
#include "lib/simplehash.h"
Go to the source code of this file.
Data Structures | |
struct | manifest_file |
struct | manifest_wal_range |
struct | parser_context |
struct | verifier_context |
Macros | |
#define | ESTIMATED_BYTES_PER_MANIFEST_LINE 100 |
#define | READ_CHUNK_SIZE 4096 |
#define | should_verify_checksum(m) (((m)->matched) && !((m)->bad) && (((m)->checksum_type) != CHECKSUM_TYPE_NONE)) |
#define | SH_PREFIX manifest_files |
#define | SH_ELEMENT_TYPE manifest_file |
#define | SH_KEY_TYPE char * |
#define | SH_KEY pathname |
#define | SH_HASH_KEY(tb, key) hash_string_pointer(key) |
#define | SH_EQUAL(tb, a, b) (strcmp(a, b) == 0) |
#define | SH_SCOPE static inline |
#define | SH_RAW_ALLOCATOR pg_malloc0 |
#define | SH_DECLARE |
#define | SH_DEFINE |
Typedefs | |
typedef struct manifest_file | manifest_file |
typedef struct manifest_wal_range | manifest_wal_range |
typedef struct parser_context | parser_context |
typedef struct verifier_context | verifier_context |
Functions | |
static uint32 | hash_string_pointer (char *s) |
static void | parse_manifest_file (char *manifest_path, manifest_files_hash **ht_p, manifest_wal_range **first_wal_range_p) |
static void | record_manifest_details_for_file (JsonManifestParseContext *context, char *pathname, size_t size, pg_checksum_type checksum_type, int checksum_length, uint8 *checksum_payload) |
static void | record_manifest_details_for_wal_range (JsonManifestParseContext *context, TimeLineID tli, XLogRecPtr start_lsn, XLogRecPtr end_lsn) |
static void | report_manifest_error (JsonManifestParseContext *context, const char *fmt,...) pg_attribute_printf(2 |
static void | pg_attribute_noreturn () |
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 *fullpath) |
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 (verifier_context *context, const char *pg_restrict fmt,...) pg_attribute_printf(2 |
static void static void | report_fatal_error (const char *pg_restrict fmt,...) pg_attribute_printf(1 |
static bool | should_ignore_relpath (verifier_context *context, char *relpath) |
static void | progress_report (bool finished) |
static void | usage (void) |
int | main (int argc, char **argv) |
Variables | |
static const char * | progname |
static bool | show_progress = false |
static bool | skip_checksums = false |
static uint64 | total_size = 0 |
static uint64 | done_size = 0 |
#define ESTIMATED_BYTES_PER_MANIFEST_LINE 100 |
Definition at line 40 of file pg_verifybackup.c.
#define READ_CHUNK_SIZE 4096 |
Definition at line 45 of file pg_verifybackup.c.
#define SH_DECLARE |
Definition at line 79 of file pg_verifybackup.c.
#define SH_DEFINE |
Definition at line 80 of file pg_verifybackup.c.
#define SH_ELEMENT_TYPE manifest_file |
Definition at line 72 of file pg_verifybackup.c.
#define SH_HASH_KEY | ( | tb, | |
key | |||
) | hash_string_pointer(key) |
Definition at line 75 of file pg_verifybackup.c.
#define SH_KEY pathname |
Definition at line 74 of file pg_verifybackup.c.
#define SH_KEY_TYPE char * |
Definition at line 73 of file pg_verifybackup.c.
#define SH_PREFIX manifest_files |
Definition at line 71 of file pg_verifybackup.c.
#define SH_RAW_ALLOCATOR pg_malloc0 |
Definition at line 78 of file pg_verifybackup.c.
#define SH_SCOPE static inline |
Definition at line 77 of file pg_verifybackup.c.
#define should_verify_checksum | ( | m | ) | (((m)->matched) && !((m)->bad) && (((m)->checksum_type) != CHECKSUM_TYPE_NONE)) |
Definition at line 63 of file pg_verifybackup.c.
typedef struct manifest_file manifest_file |
typedef struct manifest_wal_range manifest_wal_range |
typedef struct parser_context parser_context |
typedef struct verifier_context verifier_context |
|
static |
int main | ( | int | argc, |
char ** | argv | ||
) |
Definition at line 172 of file pg_verifybackup.c.
References _, arg, canonicalize_path(), exit(), find_my_exec(), find_other_exec(), get_progname(), getopt_long(), MAXPGPATH, no_argument, optarg, optind, parse_manifest_file(), parse_required_wal(), pg_fatal, pg_log_error, pg_log_error_hint, pg_logging_init(), pg_malloc(), PG_TEXTDOMAIN, printf, progname, psprintf(), pstrdup(), report_extra_backup_files(), required_argument, set_pglocale_pgservice(), show_progress, simple_string_list_append(), skip_checksums, strlcpy(), usage(), verify_backup_checksums(), and verify_backup_directory().
|
static |
Definition at line 389 of file pg_verifybackup.c.
References close, JsonManifestParseContext::error_cb, ESTIMATED_BYTES_PER_MANIFEST_LINE, fd(), parser_context::first_wal_range, fstat, parser_context::ht, json_parse_manifest(), parser_context::last_wal_range, Max, Min, JsonManifestParseContext::perfile_cb, JsonManifestParseContext::perwalrange_cb, pfree(), PG_BINARY, pg_malloc(), PG_UINT32_MAX, JsonManifestParseContext::private_data, read, record_manifest_details_for_file(), record_manifest_details_for_wal_range(), report_fatal_error(), report_manifest_error(), and stat::st_size.
Referenced by main().
|
static |
Definition at line 835 of file pg_verifybackup.c.
References manifest_wal_range::end_lsn, fflush(), LSN_FORMAT_ARGS, manifest_wal_range::next, psprintf(), report_backup_error(), manifest_wal_range::start_lsn, and manifest_wal_range::tli.
Referenced by main().
static void pg_attribute_noreturn | ( | ) |
|
static |
Definition at line 941 of file pg_verifybackup.c.
References _, done_size, fprintf, last_progress_report, now(), show_progress, snprintf, total_size, and UINT64_FORMAT.
Referenced by verify_backup_checksums(), and verify_file_checksum().
|
static |
Definition at line 478 of file pg_verifybackup.c.
References manifest_file::bad, manifest_file::checksum_length, manifest_file::checksum_payload, manifest_file::checksum_type, parser_context::ht, manifest_file::matched, JsonManifestParseContext::private_data, report_fatal_error(), and manifest_file::size.
Referenced by parse_manifest_file().
|
static |
Definition at line 507 of file pg_verifybackup.c.
References parser_context::first_wal_range, parser_context::last_wal_range, manifest_wal_range::next, palloc(), JsonManifestParseContext::private_data, and range().
Referenced by parse_manifest_file().
|
static |
Definition at line 865 of file pg_verifybackup.c.
References exit(), verifier_context::exit_on_error, fmt, gettext, PG_LOG_ERROR, pg_log_generic_v(), PG_LOG_PRIMARY, verifier_context::saw_any_error, va_end(), and va_start().
Referenced by parse_required_wal(), report_extra_backup_files(), verify_backup_directory(), verify_backup_file(), and verify_file_checksum().
|
static |
Definition at line 680 of file pg_verifybackup.c.
References verifier_context::ht, manifest_file::matched, manifest_file::pathname, report_backup_error(), and should_ignore_relpath().
Referenced by main().
|
static |
Definition at line 882 of file pg_verifybackup.c.
References exit(), fmt, gettext, PG_LOG_ERROR, pg_log_generic_v(), PG_LOG_PRIMARY, va_end(), and va_start().
Referenced by parse_manifest_file(), record_manifest_details_for_file(), and verify_backup_directory().
|
static |
Definition at line 463 of file pg_verifybackup.c.
References exit(), fmt, gettext, PG_LOG_ERROR, pg_log_generic_v(), PG_LOG_PRIMARY, va_end(), and va_start().
Referenced by parse_manifest_file().
|
static |
Definition at line 901 of file pg_verifybackup.c.
References SimpleStringList::head, verifier_context::ignore_list, SimpleStringListCell::next, relpath, and SimpleStringListCell::val.
Referenced by report_extra_backup_files(), verify_backup_checksums(), and verify_backup_directory().
|
static |
|
static |
Definition at line 699 of file pg_verifybackup.c.
References verifier_context::backup_directory, verifier_context::ht, manifest_file::pathname, pfree(), progress_report(), psprintf(), should_ignore_relpath(), should_verify_checksum, and verify_file_checksum().
Referenced by main().
|
static |
Definition at line 540 of file pg_verifybackup.c.
References closedir(), dirent::d_name, filename, verifier_context::ignore_list, opendir(), pfree(), psprintf(), pstrdup(), readdir(), relpath, report_backup_error(), report_fatal_error(), should_ignore_relpath(), simple_string_list_append(), and verify_backup_file().
Referenced by main(), and verify_backup_file().
|
static |
Definition at line 605 of file pg_verifybackup.c.
References verifier_context::ht, verifier_context::ignore_list, relpath, report_backup_error(), S_ISDIR, S_ISREG, should_verify_checksum, show_progress, simple_string_list_append(), skip_checksums, stat::st_mode, stat::st_size, stat, total_size, and verify_backup_directory().
Referenced by verify_backup_directory().
|
static |
Definition at line 733 of file pg_verifybackup.c.
References manifest_file::checksum_length, manifest_file::checksum_payload, manifest_file::checksum_type, close, done_size, fd(), manifest_file::pathname, PG_BINARY, pg_checksum_final(), pg_checksum_init(), PG_CHECKSUM_MAX_LENGTH, pg_checksum_update(), progress_report(), read, READ_CHUNK_SIZE, relpath, report_backup_error(), and manifest_file::size.
Referenced by verify_backup_checksums().
|
static |
Definition at line 166 of file pg_verifybackup.c.
Referenced by progress_report(), and verify_file_checksum().
|
static |
Definition at line 158 of file pg_verifybackup.c.
Definition at line 161 of file pg_verifybackup.c.
Referenced by main(), progress_report(), and verify_backup_file().
Definition at line 162 of file pg_verifybackup.c.
Referenced by main(), and verify_backup_file().
|
static |
Definition at line 165 of file pg_verifybackup.c.
Referenced by progress_report(), and verify_backup_file().