26 #include "catalog/pg_tablespace_d.h"
61 #define SINK_BUFFER_LENGTH Max(32768, BLCKSZ)
85 static int64
sendDir(
bbsink *sink,
const char *path,
int basepathlen,
bool sizeonly,
86 List *tablespaces,
bool sendtblspclinks,
89 static bool sendFile(
bbsink *sink,
const char *readfilename,
const char *tarfilename,
90 struct stat *statbuf,
bool missing_ok,
94 unsigned num_incremental_blocks,
96 unsigned truncation_block_length);
98 const char *readfilename,
int fd,
99 off_t offset,
size_t length,
101 bool verify_checksum,
102 int *checksum_failures);
104 size_t *bytes_done,
void *
data,
size_t length);
107 uint16 *expected_checksum);
109 const char *content,
int len,
112 const char *linktarget,
struct stat *statbuf,
121 const char *
filename,
bool partial_read_ok);
219 {
"backup_manifest",
false},
221 {
"postmaster.pid",
false},
222 {
"postmaster.opts",
false},
247 state.tablespace_num = 0;
248 state.bytes_done = 0;
249 state.bytes_total = 0;
250 state.bytes_total_is_valid =
false;
303 foreach(lc,
state.tablespaces)
307 if (tmp->
path == NULL)
315 state.bytes_total_is_valid =
true;
322 foreach(lc,
state.tablespaces)
326 if (ti->
path == NULL)
329 bool sendtblspclinks =
true;
345 sendtblspclinks =
false;
356 errmsg(
"could not stat file \"%s\": %m",
385 "BLCKSZ too small for 2 tar blocks");
444 while ((de =
ReadDir(dir,
"pg_wal")) != NULL)
448 strcmp(de->
d_name + 8, firstoff + 8) >= 0 &&
449 strcmp(de->
d_name + 8, lastoff + 8) <= 0)
478 if (walFileList ==
NIL)
480 (
errmsg(
"could not find any WAL files")));
488 if (segno != startsegno)
495 (
errmsg(
"could not find WAL file \"%s\"", startfname)));
497 foreach(lc, walFileList)
499 char *walFileName = (
char *)
lfirst(lc);
504 if (!(nextsegno == segno || currsegno == segno))
510 (
errmsg(
"could not find WAL file \"%s\"", nextfname)));
513 if (segno != endsegno)
519 (
errmsg(
"could not find WAL file \"%s\"", endfname)));
523 foreach(lc, walFileList)
525 char *walFileName = (
char *)
lfirst(lc);
536 int save_errno = errno;
548 errmsg(
"could not open file \"%s\": %m", pathbuf)));
554 errmsg(
"could not stat file \"%s\": %m",
561 errmsg(
"unexpected WAL file size \"%s\"", walFileName)));
570 len, pathbuf,
true)) > 0)
586 errmsg(
"unexpected WAL file size \"%s\"", walFileName)));
616 foreach(lc, historyFileList)
622 if (
lstat(pathbuf, &statbuf) != 0)
625 errmsg(
"could not stat file \"%s\": %m", pathbuf)));
627 sendFile(sink, pathbuf, pathbuf, &statbuf,
false,
638 "BLCKSZ too small for 2 tar blocks");
658 "%lld total checksum verification failures",
664 errmsg(
"checksum verification failure during base backup")));
687 char *fna = (
char *)
lfirst(
a);
688 char *fnb = (
char *)
lfirst(
b);
690 return strcmp(fna + 8, fnb + 8);
700 bool o_label =
false;
701 bool o_progress =
false;
702 bool o_checkpoint =
false;
703 bool o_nowait =
false;
705 bool o_incremental =
false;
706 bool o_maxrate =
false;
707 bool o_tablespace_map =
false;
708 bool o_noverify_checksums =
false;
709 bool o_manifest =
false;
710 bool o_manifest_checksums =
false;
711 bool o_target =
false;
712 bool o_target_detail =
false;
713 char *target_str = NULL;
714 char *target_detail_str = NULL;
715 bool o_compression =
false;
716 bool o_compression_detail =
false;
717 char *compression_detail_str = NULL;
719 MemSet(opt, 0,
sizeof(*opt));
729 if (strcmp(defel->
defname,
"label") == 0)
733 (
errcode(ERRCODE_SYNTAX_ERROR),
738 else if (strcmp(defel->
defname,
"progress") == 0)
742 (
errcode(ERRCODE_SYNTAX_ERROR),
747 else if (strcmp(defel->
defname,
"checkpoint") == 0)
753 (
errcode(ERRCODE_SYNTAX_ERROR),
761 (
errcode(ERRCODE_SYNTAX_ERROR),
762 errmsg(
"unrecognized checkpoint type: \"%s\"",
766 else if (strcmp(defel->
defname,
"wait") == 0)
770 (
errcode(ERRCODE_SYNTAX_ERROR),
775 else if (strcmp(defel->
defname,
"wal") == 0)
779 (
errcode(ERRCODE_SYNTAX_ERROR),
784 else if (strcmp(defel->
defname,
"incremental") == 0)
788 (
errcode(ERRCODE_SYNTAX_ERROR),
793 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
794 errmsg(
"incremental backups cannot be taken unless WAL summarization is enabled")));
795 o_incremental =
true;
797 else if (strcmp(defel->
defname,
"max_rate") == 0)
803 (
errcode(ERRCODE_SYNTAX_ERROR),
809 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
810 errmsg(
"%d is outside the valid range for parameter \"%s\" (%d .. %d)",
816 else if (strcmp(defel->
defname,
"tablespace_map") == 0)
818 if (o_tablespace_map)
820 (
errcode(ERRCODE_SYNTAX_ERROR),
823 o_tablespace_map =
true;
825 else if (strcmp(defel->
defname,
"verify_checksums") == 0)
827 if (o_noverify_checksums)
829 (
errcode(ERRCODE_SYNTAX_ERROR),
832 o_noverify_checksums =
true;
834 else if (strcmp(defel->
defname,
"manifest") == 0)
841 (
errcode(ERRCODE_SYNTAX_ERROR),
854 (
errcode(ERRCODE_SYNTAX_ERROR),
855 errmsg(
"unrecognized manifest option: \"%s\"",
859 else if (strcmp(defel->
defname,
"manifest_checksums") == 0)
863 if (o_manifest_checksums)
865 (
errcode(ERRCODE_SYNTAX_ERROR),
870 (
errcode(ERRCODE_SYNTAX_ERROR),
871 errmsg(
"unrecognized checksum algorithm: \"%s\"",
873 o_manifest_checksums =
true;
875 else if (strcmp(defel->
defname,
"target") == 0)
879 (
errcode(ERRCODE_SYNTAX_ERROR),
884 else if (strcmp(defel->
defname,
"target_detail") == 0)
890 (
errcode(ERRCODE_SYNTAX_ERROR),
892 target_detail_str = optval;
893 o_target_detail =
true;
895 else if (strcmp(defel->
defname,
"compression") == 0)
901 (
errcode(ERRCODE_SYNTAX_ERROR),
905 (
errcode(ERRCODE_SYNTAX_ERROR),
906 errmsg(
"unrecognized compression algorithm: \"%s\"",
908 o_compression =
true;
910 else if (strcmp(defel->
defname,
"compression_detail") == 0)
912 if (o_compression_detail)
914 (
errcode(ERRCODE_SYNTAX_ERROR),
917 o_compression_detail =
true;
921 (
errcode(ERRCODE_SYNTAX_ERROR),
922 errmsg(
"unrecognized base backup option: \"%s\"",
926 if (opt->
label == NULL)
927 opt->
label =
"base backup";
930 if (o_manifest_checksums)
932 (
errcode(ERRCODE_SYNTAX_ERROR),
933 errmsg(
"manifest checksums require a backup manifest")));
937 if (target_str == NULL)
939 if (target_detail_str != NULL)
941 (
errcode(ERRCODE_SYNTAX_ERROR),
942 errmsg(
"target detail cannot be used without target")));
946 else if (strcmp(target_str,
"client") == 0)
948 if (target_detail_str != NULL)
950 (
errcode(ERRCODE_SYNTAX_ERROR),
951 errmsg(
"target \"%s\" does not accept a target detail",
959 if (o_compression_detail && !o_compression)
961 (
errcode(ERRCODE_SYNTAX_ERROR),
962 errmsg(
"compression detail cannot be specified unless compression is enabled")));
972 if (error_detail != NULL)
975 errmsg(
"invalid compression specification: %s",
997 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
998 errmsg(
"a backup is already in progress in this session")));
1006 char activitymsg[50];
1008 snprintf(activitymsg,
sizeof(activitymsg),
"sending backup \"%s\"",
1022 else if (ib == NULL)
1024 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1025 errmsg(
"must UPLOAD_MANIFEST before performing an incremental BASE_BACKUP")));
1077 struct stat statbuf;
1082 elog(
ERROR,
"could not initialize checksum of file \"%s\"",
1086 len = strlen(content);
1097 statbuf.
st_uid = geteuid();
1098 statbuf.
st_gid = getegid();
1107 elog(
ERROR,
"could not update checksum of file \"%s\"",
1110 while (bytes_done <
len)
1117 bytes_done += nbytes;
1140 struct stat statbuf;
1146 snprintf(pathbuf,
sizeof(pathbuf),
"%s/%s", path,
1153 if (
lstat(pathbuf, &statbuf) != 0)
1155 if (errno != ENOENT)
1158 errmsg(
"could not stat file or directory \"%s\": %m",
1195 struct stat statbuf;
1197 const char *lastDir;
1198 bool isRelationDir =
false;
1199 bool isGlobalDir =
false;
1220 if (lastDir != NULL &&
1221 strspn(lastDir + 1,
"0123456789") == strlen(lastDir + 1))
1224 int parentPathLen = lastDir - path;
1230 if (strncmp(path,
"./base", parentPathLen) == 0 ||
1236 isRelationDir =
true;
1237 dboid =
atooid(lastDir + 1);
1240 else if (strcmp(path,
"./global") == 0)
1242 isRelationDir =
true;
1247 while ((de =
ReadDir(dir, path)) != NULL)
1254 bool isRelationFile =
false;
1257 if (strcmp(de->
d_name,
".") == 0 || strcmp(de->
d_name,
"..") == 0)
1267 if (strcmp(de->
d_name,
".DS_Store") == 0)
1281 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1282 errmsg(
"the standby was promoted during online backup"),
1283 errhint(
"This means that the backup being taken is corrupt "
1284 "and should not be used. "
1285 "Try taking another online backup.")));
1288 excludeFound =
false;
1298 excludeFound =
true;
1314 &relForkNum, &segno);
1325 snprintf(initForkFile,
sizeof(initForkFile),
"%s/%u_init",
1326 path, relfilenumber);
1328 if (
lstat(initForkFile, &statbuf) == 0)
1331 "unlogged relation file \"%s\" excluded from backup",
1342 "temporary relation file \"%s\" excluded from backup",
1351 if (strcmp(pathbuf,
"./global/pg_control") == 0)
1354 if (
lstat(pathbuf, &statbuf) != 0)
1356 if (errno != ENOENT)
1359 errmsg(
"could not stat file or directory \"%s\": %m",
1367 excludeFound =
false;
1372 elog(
DEBUG1,
"contents of directory \"%s\" excluded from backup", de->
d_name);
1375 &statbuf, sizeonly);
1376 excludeFound =
true;
1389 if (strcmp(pathbuf,
"./pg_wal") == 0)
1394 &statbuf, sizeonly);
1401 &statbuf, sizeonly);
1403 &statbuf, sizeonly);
1409 if (strcmp(path,
"./pg_tblspc") == 0 &&
S_ISLNK(statbuf.
st_mode))
1414 rllen =
readlink(pathbuf, linkpath,
sizeof(linkpath));
1418 errmsg(
"could not read symbolic link \"%s\": %m",
1420 if (rllen >=
sizeof(linkpath))
1422 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1423 errmsg(
"symbolic link \"%s\" target is too long",
1425 linkpath[rllen] =
'\0';
1428 &statbuf, sizeonly);
1432 bool skip_this_dir =
false;
1446 foreach(lc, tablespaces)
1457 if (ti->
rpath && strcmp(ti->
rpath, pathbuf + 2) == 0)
1459 skip_this_dir =
true;
1467 if (strcmp(pathbuf,
"./pg_tblspc") == 0 && !sendtblspclinks)
1468 skip_this_dir =
true;
1471 size +=
sendDir(sink, pathbuf, basepathlen, sizeonly, tablespaces,
1472 sendtblspclinks,
manifest, spcoid, ib);
1477 unsigned num_blocks_required = 0;
1478 unsigned truncation_block_length = 0;
1480 char *tarfilename = pathbuf + basepathlen + 1;
1483 if (ib != NULL && isRelationFile)
1497 relspcoid = GLOBALTABLESPACE_OID;
1499 relspcoid = DEFAULTTABLESPACE_OID;
1500 lookup_path =
pstrdup(tarfilename);
1504 relfilenumber, relForkNum,
1506 &num_blocks_required,
1507 relative_block_numbers,
1508 &truncation_block_length);
1513 snprintf(tarfilenamebuf,
sizeof(tarfilenamebuf),
1514 "%s/INCREMENTAL.%s",
1515 path + basepathlen + 1,
1517 tarfilename = tarfilenamebuf;
1524 sent =
sendFile(sink, pathbuf, tarfilename, &statbuf,
1525 true, dboid, spcoid,
1527 num_blocks_required,
1529 truncation_block_length);
1531 if (sent || sizeonly)
1545 (
errmsg(
"skipping special file \"%s\"", pathbuf)));
1548 if (relative_block_numbers != NULL)
1549 pfree(relative_block_numbers);
1574 struct stat *statbuf,
bool missing_ok,
Oid dboid,
Oid spcoid,
1577 BlockNumber *incremental_blocks,
unsigned truncation_block_length)
1581 int checksum_failures = 0;
1584 bool verify_checksum =
false;
1589 elog(
ERROR,
"could not initialize checksum of file \"%s\"",
1595 if (errno == ENOENT && missing_ok)
1599 errmsg(
"could not open file \"%s\": %m", readfilename)));
1617 verify_checksum =
true;
1622 if (incremental_blocks != NULL)
1625 size_t header_bytes_done = 0;
1626 char padding[BLCKSZ];
1631 &magic,
sizeof(magic));
1633 &num_incremental_blocks,
sizeof(num_incremental_blocks));
1635 &truncation_block_length,
sizeof(truncation_block_length));
1647 if ((num_incremental_blocks > 0) && (header_bytes_done % BLCKSZ != 0))
1649 paddinglen = (BLCKSZ - (header_bytes_done % BLCKSZ));
1651 memset(padding, 0, paddinglen);
1652 bytes_done += paddinglen;
1655 padding, paddinglen);
1659 if (header_bytes_done > 0)
1664 header_bytes_done) < 0)
1665 elog(
ERROR,
"could not update checksum of base backup");
1669 bytes_done +=
sizeof(magic);
1670 bytes_done +=
sizeof(num_incremental_blocks);
1671 bytes_done +=
sizeof(truncation_block_length);
1672 bytes_done +=
sizeof(
BlockNumber) * num_incremental_blocks;
1687 if (incremental_blocks == NULL)
1695 if (bytes_done >= statbuf->
st_size)
1704 blkno + segno * RELSEG_SIZE,
1706 &checksum_failures);
1715 if (ibindex >= num_incremental_blocks)
1722 relative_blkno = incremental_blocks[ibindex++];
1724 relative_blkno * BLCKSZ,
1726 relative_blkno + segno * RELSEG_SIZE,
1728 &checksum_failures);
1749 if (verify_checksum && (cnt % BLCKSZ != 0))
1752 (
errmsg(
"could not verify checksum in file \"%s\", block "
1753 "%u: read buffer size %d and page size %d "
1755 readfilename, blkno, (
int) cnt, BLCKSZ)));
1756 verify_checksum =
false;
1768 blkno += cnt / BLCKSZ;
1775 Assert(!((incremental_blocks != NULL && num_incremental_blocks > 0) &&
1776 (bytes_done % BLCKSZ != 0)));
1784 elog(
ERROR,
"could not update checksum of base backup");
1788 while (bytes_done < statbuf->
st_size)
1797 elog(
ERROR,
"could not update checksum of base backup");
1799 bytes_done += nbytes;
1811 if (checksum_failures > 1)
1814 (
errmsg_plural(
"file \"%s\" has a total of %d checksum verification failure",
1815 "file \"%s\" has a total of %d checksum verification failures",
1817 readfilename, checksum_failures)));
1850 bool verify_checksum,
int *checksum_failures)
1859 offset, readfilename,
true);
1862 if (!verify_checksum || (cnt % BLCKSZ) != 0)
1866 for (
i = 0;
i < cnt / BLCKSZ;
i++)
1869 uint16 expected_checksum;
1875 &expected_checksum))
1896 BLCKSZ, offset + BLCKSZ *
i,
1897 readfilename,
false);
1898 if (reread_cnt == 0)
1911 &expected_checksum))
1915 (*checksum_failures)++;
1916 if (*checksum_failures <= 5)
1918 (
errmsg(
"checksum verification failed in "
1919 "file \"%s\", block %u: calculated "
1920 "%X but expected %X",
1921 readfilename, blkno +
i, expected_checksum,
1923 if (*checksum_failures == 5)
1925 (
errmsg(
"further checksum verification "
1926 "failures in file \"%s\" will not "
1927 "be reported", readfilename)));
1952 size_t *bytes_done,
void *
data,
size_t length)
1956 size_t bytes_to_copy;
1962 if (length < sink->bbs_buffer_length - *bytes_done)
1966 *bytes_done += length;
1973 data = ((
char *)
data) + bytes_to_copy;
1974 length -= bytes_to_copy;
1978 elog(
ERROR,
"could not update checksum");
1993 uint16 *expected_checksum)
2015 *expected_checksum = checksum;
2021 struct stat *statbuf,
bool sizeonly)
2035 "BLCKSZ too small for tar block");
2049 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2050 errmsg(
"file name too long for tar format: \"%s\"",
2055 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2056 errmsg(
"symbolic link target too long for tar format: "
2057 "file name \"%s\", target \"%s\"",
2061 elog(
ERROR,
"unrecognized tar error: %d", rc);
2115 const char *
filename,
bool partial_read_ok)
2127 if (!partial_read_ok && rc > 0 && rc != nbytes)
2130 errmsg(
"could not read file \"%s\": read %zd of %zu",
void InitializeBackupManifest(backup_manifest_info *manifest, backup_manifest_option want_manifest, pg_checksum_type manifest_checksum_type)
void AddFileToBackupManifest(backup_manifest_info *manifest, Oid spcoid, const char *pathname, size_t size, pg_time_t mtime, pg_checksum_context *checksum_ctx)
void AddWALInfoToBackupManifest(backup_manifest_info *manifest, XLogRecPtr startptr, TimeLineID starttli, XLogRecPtr endptr, TimeLineID endtli)
void SendBackupManifest(backup_manifest_info *manifest, bbsink *sink)
void FreeBackupManifest(backup_manifest_info *manifest)
@ MANIFEST_OPTION_FORCE_ENCODE
enum manifest_option backup_manifest_option
static bool sendFile(bbsink *sink, const char *readfilename, const char *tarfilename, struct stat *statbuf, bool missing_ok, Oid dboid, Oid spcoid, RelFileNumber relfilenumber, unsigned segno, backup_manifest_info *manifest, unsigned num_incremental_blocks, BlockNumber *incremental_blocks, unsigned truncation_block_length)
static const struct exclude_list_item excludeFiles[]
static int compareWalFileNames(const ListCell *a, const ListCell *b)
static void sendFileWithContent(bbsink *sink, const char *filename, const char *content, int len, backup_manifest_info *manifest)
static off_t read_file_data_into_buffer(bbsink *sink, const char *readfilename, int fd, off_t offset, size_t length, BlockNumber blkno, bool verify_checksum, int *checksum_failures)
static void push_to_sink(bbsink *sink, pg_checksum_context *checksum_ctx, size_t *bytes_done, void *data, size_t length)
static int64 sendDir(bbsink *sink, const char *path, int basepathlen, bool sizeonly, List *tablespaces, bool sendtblspclinks, backup_manifest_info *manifest, Oid spcoid, IncrementalBackupInfo *ib)
#define SINK_BUFFER_LENGTH
static void parse_basebackup_options(List *options, basebackup_options *opt)
static const char *const excludeDirContents[]
static void convert_link_to_directory(const char *pathbuf, struct stat *statbuf)
void SendBaseBackup(BaseBackupCmd *cmd, IncrementalBackupInfo *ib)
static bool backup_started_in_recovery
static int64 _tarWriteHeader(bbsink *sink, const char *filename, const char *linktarget, struct stat *statbuf, bool sizeonly)
static void perform_base_backup(basebackup_options *opt, bbsink *sink, IncrementalBackupInfo *ib)
static int64 sendTablespace(bbsink *sink, char *path, Oid spcoid, bool sizeonly, struct backup_manifest_info *manifest, IncrementalBackupInfo *ib)
static bool noverify_checksums
static void _tarWritePadding(bbsink *sink, int len)
static bool verify_page_checksum(Page page, XLogRecPtr start_lsn, BlockNumber blkno, uint16 *expected_checksum)
static ssize_t basebackup_read_file(int fd, char *buf, size_t nbytes, off_t offset, const char *filename, bool partial_read_ok)
static long long int total_checksum_failures
bbsink * bbsink_copystream_new(bool send_to_client)
bbsink * bbsink_gzip_new(bbsink *next, pg_compress_specification *compress)
size_t GetIncrementalFileSize(unsigned num_blocks_required)
FileBackupMethod GetFileBackupMethod(IncrementalBackupInfo *ib, const char *path, Oid dboid, Oid spcoid, RelFileNumber relfilenumber, ForkNumber forknum, unsigned segno, size_t size, unsigned *num_blocks_required, BlockNumber *relative_block_numbers, unsigned *truncation_block_length)
void PrepareForIncrementalBackup(IncrementalBackupInfo *ib, BackupState *backup_state)
#define INCREMENTAL_MAGIC
@ BACK_UP_FILE_INCREMENTALLY
bbsink * bbsink_lz4_new(bbsink *next, pg_compress_specification *compress)
void basebackup_progress_wait_checkpoint(void)
void basebackup_progress_wait_wal_archive(bbsink_state *state)
bbsink * bbsink_progress_new(bbsink *next, bool estimate_backup_size)
void basebackup_progress_done(void)
void basebackup_progress_transfer_wal(void)
void basebackup_progress_estimate_backup_size(void)
static void bbsink_begin_backup(bbsink *sink, bbsink_state *state, int buffer_length)
static void bbsink_begin_archive(bbsink *sink, const char *archive_name)
static void bbsink_end_archive(bbsink *sink)
static void bbsink_end_backup(bbsink *sink, XLogRecPtr endptr, TimeLineID endtli)
static void bbsink_cleanup(bbsink *sink)
static void bbsink_archive_contents(bbsink *sink, size_t len)
bbsink * BaseBackupGetSink(BaseBackupTargetHandle *handle, bbsink *next_sink)
BaseBackupTargetHandle * BaseBackupGetTargetHandle(char *target, char *target_detail)
bbsink * bbsink_throttle_new(bbsink *next, uint32 maxrate)
bbsink * bbsink_zstd_new(bbsink *next, pg_compress_specification *compress)
bool parse_bool(const char *value, bool *result)
PageHeaderData * PageHeader
static bool PageIsNew(Page page)
static XLogRecPtr PageGetLSN(const char *page)
#define Assert(condition)
#define MemSet(start, val, len)
#define StaticAssertDecl(condition, errmessage)
#define StaticAssertStmt(condition, errmessage)
#define OidIsValid(objectId)
uint16 pg_checksum_page(char *page, BlockNumber blkno)
bool pg_checksum_parse_type(char *name, pg_checksum_type *type)
int pg_checksum_update(pg_checksum_context *context, const uint8 *input, size_t len)
int pg_checksum_init(pg_checksum_context *context, pg_checksum_type type)
bool parse_compress_algorithm(char *name, pg_compress_algorithm *algorithm)
void parse_compress_specification(pg_compress_algorithm algorithm, char *specification, pg_compress_specification *result)
char * validate_compress_specification(pg_compress_specification *spec)
bool defGetBoolean(DefElem *def)
char * defGetString(DefElem *def)
int64 defGetInt64(DefElem *def)
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errcode_for_file_access(void)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define ereport(elevel,...)
struct dirent * ReadDir(DIR *dir, const char *dirname)
int CloseTransientFile(int fd)
bool looks_like_temp_rel_name(const char *name)
int OpenTransientFile(const char *fileName, int fileFlags)
DIR * AllocateDir(const char *dirname)
#define PG_TEMP_FILE_PREFIX
#define PG_AUTOCONF_FILENAME
#define PG_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
#define PG_END_ENSURE_ERROR_CLEANUP(cleanup_function, arg)
void list_sort(List *list, list_sort_comparator cmp)
List * lappend(List *list, void *datum)
char * pstrdup(const char *in)
void pfree(void *pointer)
void * palloc0(Size size)
#define CHECK_FOR_INTERRUPTS()
#define ERRCODE_DATA_CORRUPTED
static ListCell * lnext(const List *l, const ListCell *c)
void pgstat_report_checksum_failures_in_db(Oid dboid, int failurecount)
static size_t tarPaddingBytesRequired(size_t len)
enum tarError tarCreateHeader(char *h, const char *filename, const char *linktarget, pgoff_t size, mode_t mode, uid_t uid, gid_t gid, time_t mtime)
char * last_dir_separator(const char *filename)
int pg_strcasecmp(const char *s1, const char *s2)
static Datum BoolGetDatum(bool X)
static int fd(const char *x, int i)
bool update_process_title
static void set_ps_display(const char *activity)
char * psprintf(const char *fmt,...)
bool parse_filename_for_nontemp_relation(const char *name, RelFileNumber *relnumber, ForkNumber *fork, unsigned *segno)
#define RELCACHE_INIT_FILENAME
#define InvalidRelFileNumber
#define TABLESPACE_VERSION_DIRECTORY
#define RelFileNumberIsValid(relnumber)
ResourceOwner ResourceOwnerCreate(ResourceOwner parent, const char *name)
ResourceOwner CurrentResourceOwner
static pg_noinline void Size size
void destroyStringInfo(StringInfo str)
StringInfo makeStringInfo(void)
pg_compress_specification compression_specification
pg_checksum_type manifest_checksum_type
pg_compress_algorithm compression
backup_manifest_option manifest
BaseBackupTargetHandle * target_handle
pg_compress_algorithm algorithm
#define LOG_METAINFO_DATAFILE_TMP
static void pgstat_report_wait_start(uint32 wait_event_info)
static void pgstat_report_wait_end(void)
void WalSndSetState(WalSndState state)
void WalSndResourceCleanup(bool isCommit)
#define readlink(path, buf, size)
bool RecoveryInProgress(void)
void do_pg_abort_backup(int code, Datum arg)
SessionBackupState get_backup_status(void)
void CheckXLogRemoved(XLogSegNo segno, TimeLineID tli)
bool DataChecksumsEnabled(void)
void do_pg_backup_start(const char *backupidstr, bool fast, List **tablespaces, BackupState *state, StringInfo tblspcmapfile)
void do_pg_backup_stop(BackupState *state, bool waitforarchive)
#define BACKUP_LABEL_FILE
#define XLOG_CONTROL_FILE
static bool IsXLogFileName(const char *fname)
static void XLogFromFileName(const char *fname, TimeLineID *tli, XLogSegNo *logSegNo, int wal_segsz_bytes)
#define XLByteToPrevSeg(xlrp, logSegNo, wal_segsz_bytes)
static bool IsTLHistoryFileName(const char *fname)
static void StatusFilePath(char *path, const char *xlog, const char *suffix)
#define XLByteToSeg(xlrp, logSegNo, wal_segsz_bytes)
static void XLogFileName(char *fname, TimeLineID tli, XLogSegNo logSegNo, int wal_segsz_bytes)
char * build_backup_content(BackupState *state, bool ishistoryfile)
static BackupState * backup_state
static StringInfo tablespace_map