PostgreSQL Source Code
git master
|
#include "postgres_fe.h"
#include <dirent.h>
#include <fcntl.h>
#include <limits.h>
#include "backup_label.h"
#include "common/blkreftable.h"
#include "common/checksum_helper.h"
#include "common/controldata_utils.h"
#include "common/file_perm.h"
#include "common/file_utils.h"
#include "common/logging.h"
#include "copy_file.h"
#include "fe_utils/option_utils.h"
#include "getopt_long.h"
#include "lib/stringinfo.h"
#include "load_manifest.h"
#include "reconstruct.h"
#include "write_manifest.h"
Go to the source code of this file.
Data Structures | |
struct | cb_cleanup_dir |
struct | cb_tablespace_mapping |
struct | cb_options |
struct | cb_tablespace |
Macros | |
#define | INCREMENTAL_PREFIX "INCREMENTAL." |
#define | INCREMENTAL_PREFIX_LENGTH (sizeof(INCREMENTAL_PREFIX) - 1) |
Typedefs | |
typedef struct cb_cleanup_dir | cb_cleanup_dir |
typedef struct cb_tablespace_mapping | cb_tablespace_mapping |
typedef struct cb_options | cb_options |
typedef struct cb_tablespace | cb_tablespace |
Functions | |
static void | add_tablespace_mapping (cb_options *opt, char *arg) |
static StringInfo | check_backup_label_files (int n_backups, char **backup_dirs) |
static uint64 | check_control_files (int n_backups, char **backup_dirs) |
static void | check_input_dir_permissions (char *dir) |
static void | cleanup_directories_atexit (void) |
static void | create_output_directory (char *dirname, cb_options *opt) |
static void | help (const char *progname) |
static bool | parse_oid (char *s, Oid *result) |
static void | process_directory_recursively (Oid tsoid, char *input_directory, char *output_directory, char *relative_path, int n_prior_backups, char **prior_backup_dirs, manifest_data **manifests, manifest_writer *mwriter, cb_options *opt) |
static int | read_pg_version_file (char *directory) |
static void | remember_to_cleanup_directory (char *target_path, bool rmtopdir) |
static void | reset_directory_cleanup_list (void) |
static cb_tablespace * | scan_for_existing_tablespaces (char *pathname, cb_options *opt) |
static void | slurp_file (int fd, char *filename, StringInfo buf, int maxlen) |
int | main (int argc, char *argv[]) |
Variables | |
static cb_cleanup_dir * | cleanup_dir_list = NULL |
#define INCREMENTAL_PREFIX "INCREMENTAL." |
Definition at line 43 of file pg_combinebackup.c.
#define INCREMENTAL_PREFIX_LENGTH (sizeof(INCREMENTAL_PREFIX) - 1) |
Definition at line 44 of file pg_combinebackup.c.
typedef struct cb_cleanup_dir cb_cleanup_dir |
typedef struct cb_options cb_options |
typedef struct cb_tablespace cb_tablespace |
typedef struct cb_tablespace_mapping cb_tablespace_mapping |
|
static |
Definition at line 436 of file pg_combinebackup.c.
References arg, canonicalize_path(), is_absolute_path, MAXPGPATH, cb_tablespace_mapping::new_dir, cb_tablespace_mapping::next, cb_tablespace_mapping::old_dir, pg_fatal, pg_malloc0(), and cb_options::tsmappings.
Referenced by main().
|
static |
Definition at line 501 of file pg_combinebackup.c.
References buf, close, destroyStringInfo(), fd(), i, InvalidXLogRecPtr, LSN_FORMAT_ARGS, makeStringInfo(), MAXPGPATH, parse_backup_label(), pg_fatal, pg_log_debug, resetStringInfo(), slurp_file(), and snprintf.
Referenced by main().
|
static |
Definition at line 594 of file pg_combinebackup.c.
References ControlFileData::data_checksum_version, get_controlfile_by_exact_path(), i, pfree(), PG_CONTROL_VERSION, ControlFileData::pg_control_version, pg_fatal, pg_log_debug, pg_log_warning, pg_log_warning_hint, psprintf(), and ControlFileData::system_identifier.
Referenced by main().
|
static |
Definition at line 671 of file pg_combinebackup.c.
References pg_fatal, SetDataDirectoryCreatePerm(), stat::st_mode, and stat.
Referenced by main().
|
static |
Definition at line 685 of file pg_combinebackup.c.
References cleanup_dir_list, cb_cleanup_dir::next, pfree(), pg_log_error, pg_log_info, cb_cleanup_dir::rmtopdir, rmtree(), and cb_cleanup_dir::target_path.
Referenced by main().
|
static |
Definition at line 718 of file pg_combinebackup.c.
References cb_options::dry_run, pg_check_dir(), pg_dir_create_mode, pg_fatal, pg_log_debug, pg_mkdir_p(), and remember_to_cleanup_directory().
Referenced by main().
|
static |
int main | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 130 of file pg_combinebackup.c.
References add_tablespace_mapping(), check_backup_label_files(), check_control_files(), check_input_dir_permissions(), CHECKSUM_TYPE_CRC32C, CHECKSUM_TYPE_NONE, cleanup_directories_atexit(), cb_options::copy_method, COPY_METHOD_CLONE, COPY_METHOD_COPY, COPY_METHOD_COPY_FILE_RANGE, create_manifest_writer(), create_output_directory(), StringInfoData::cursor, DATA_DIR_SYNC_METHOD_FSYNC, cb_options::debug, cb_options::dry_run, exit(), finalize_manifest(), get_progname(), getopt_long(), handle_help_version_opts(), help(), i, cb_tablespace::in_place, InvalidOid, load_backup_manifests(), cb_options::manifest_checksums, MAXPGPATH, cb_tablespace::new_dir, cb_tablespace::next, no_argument, cb_options::no_manifest, cb_options::no_sync, cb_tablespace::oid, cb_tablespace::old_dir, optarg, optind, cb_options::output, parse_sync_method(), pg_checksum_parse_type(), pg_dir_create_mode, pg_fatal, pg_log_debug, pg_log_error, pg_log_error_hint, pg_logging_increase_verbosity(), pg_logging_init(), pg_mkdir_p(), PG_TBLSPC_DIR, PG_TEXTDOMAIN, process_directory_recursively(), progname, psprintf(), read_pg_version_file(), required_argument, reset_directory_cleanup_list(), scan_for_existing_tablespaces(), set_pglocale_pgservice(), snprintf, symlink, cb_options::sync_method, and write_backup_label().
Definition at line 789 of file pg_combinebackup.c.
References PG_UINT32_MAX.
Referenced by process_directory_recursively(), and scan_for_existing_tablespaces().
|
static |
Definition at line 823 of file pg_combinebackup.c.
References add_file_to_manifest(), manifest_file::checksum_length, manifest_file::checksum_payload, manifest_file::checksum_type, CHECKSUM_TYPE_NONE, closedir(), copy_file(), cb_options::copy_method, dirent::d_name, cb_options::debug, cb_options::dry_run, exit(), manifest_data::files, get_dirent_type(), INCREMENTAL_PREFIX, INCREMENTAL_PREFIX_LENGTH, InvalidOid, cb_options::manifest_checksums, MAXPGPATH, mkdir, OidIsValid, opendir(), parse_oid(), pfree(), pg_checksum_final(), pg_checksum_init(), PG_CHECKSUM_MAX_LENGTH, pg_dir_create_mode, pg_fatal, pg_log_debug, PG_LOG_ERROR, pg_log_warning, pg_malloc(), PG_TBLSPC_DIR, PG_TBLSPC_DIR_SLASH, PGFILETYPE_DIR, PGFILETYPE_ERROR, PGFILETYPE_LNK, PGFILETYPE_REG, psprintf(), readdir(), reconstruct_from_incremental_file(), snprintf, stat::st_mtime, stat::st_size, stat, strlcpy(), type, and pg_checksum_context::type.
Referenced by main().
|
static |
Definition at line 1154 of file pg_combinebackup.c.
References buf, close, directory, fd(), filename, initStringInfo(), MAXPGPATH, pfree(), pg_fatal, pg_log_debug, slurp_file(), and snprintf.
Referenced by main().
|
static |
Definition at line 1205 of file pg_combinebackup.c.
References cleanup_dir_list, cb_cleanup_dir::next, pg_malloc(), cb_cleanup_dir::rmtopdir, and cb_cleanup_dir::target_path.
Referenced by create_output_directory().
|
static |
Definition at line 1226 of file pg_combinebackup.c.
References cleanup_dir_list, cb_cleanup_dir::next, and pfree().
Referenced by main().
|
static |
Definition at line 1245 of file pg_combinebackup.c.
References canonicalize_path(), closedir(), dirent::d_name, exit(), get_dirent_type(), cb_tablespace::in_place, is_absolute_path, MAXPGPATH, cb_tablespace_mapping::new_dir, cb_tablespace::new_dir, cb_tablespace_mapping::next, cb_tablespace::next, cb_tablespace::oid, cb_tablespace_mapping::old_dir, cb_tablespace::old_dir, opendir(), cb_options::output, parse_oid(), pg_fatal, pg_log_debug, PG_LOG_ERROR, pg_malloc0(), PG_TBLSPC_DIR, PGFILETYPE_DIR, PGFILETYPE_ERROR, PGFILETYPE_LNK, readdir(), readlink, snprintf, strlcpy(), cb_options::tsmappings, and type.
Referenced by main().
|
static |
Definition at line 1376 of file pg_combinebackup.c.
References buf, enlargeStringInfo(), fd(), filename, fstat, pg_fatal, read, and stat::st_size.
Referenced by check_backup_label_files(), and read_pg_version_file().
|
static |
Definition at line 100 of file pg_combinebackup.c.
Referenced by cleanup_directories_atexit(), remember_to_cleanup_directory(), and reset_directory_cleanup_list().