26#include "catalog/pg_tablespace_d.h"
60#define SINK_BUFFER_LENGTH Max(32768, BLCKSZ)
85 List *tablespaces,
bool sendtblspclinks,
88static bool sendFile(
bbsink *sink,
const char *readfilename,
const char *tarfilename,
89 struct stat *statbuf,
bool missing_ok,
93 unsigned num_incremental_blocks,
95 unsigned truncation_block_length);
97 const char *readfilename,
int fd,
98 off_t offset,
size_t length,
100 bool verify_checksum,
101 int *checksum_failures);
103 size_t *bytes_done,
void *
data,
size_t length);
106 uint16 *expected_checksum);
108 const char *content,
int len,
111 const char *linktarget,
struct stat *statbuf,
120 const char *
filename,
bool partial_read_ok);
218 {
"backup_manifest",
false},
220 {
"postmaster.pid",
false},
221 {
"postmaster.opts",
false},
246 state.tablespace_num = 0;
247 state.bytes_done = 0;
248 state.bytes_total = 0;
249 state.bytes_total_is_valid =
false;
304 foreach(lc,
state.tablespaces)
308 if (tmp->
path == NULL)
316 state.bytes_total_is_valid =
true;
323 foreach(lc,
state.tablespaces)
327 if (ti->
path == NULL)
330 bool sendtblspclinks =
true;
346 sendtblspclinks =
false;
357 errmsg(
"could not stat file \"%s\": %m",
386 "BLCKSZ too small for 2 tar blocks");
445 while ((de =
ReadDir(dir,
"pg_wal")) != NULL)
449 strcmp(de->
d_name + 8, firstoff + 8) >= 0 &&
450 strcmp(de->
d_name + 8, lastoff + 8) <= 0)
479 if (walFileList ==
NIL)
481 (
errmsg(
"could not find any WAL files")));
489 if (segno != startsegno)
496 (
errmsg(
"could not find WAL file \"%s\"", startfname)));
498 foreach(lc, walFileList)
500 char *walFileName = (
char *)
lfirst(lc);
505 if (!(nextsegno == segno || currsegno == segno))
511 (
errmsg(
"could not find WAL file \"%s\"", nextfname)));
514 if (segno != endsegno)
520 (
errmsg(
"could not find WAL file \"%s\"", endfname)));
524 foreach(lc, walFileList)
526 char *walFileName = (
char *)
lfirst(lc);
537 int save_errno = errno;
549 errmsg(
"could not open file \"%s\": %m", pathbuf)));
555 errmsg(
"could not stat file \"%s\": %m",
562 errmsg(
"unexpected WAL file size \"%s\"", walFileName)));
571 len, pathbuf,
true)) > 0)
587 errmsg(
"unexpected WAL file size \"%s\"", walFileName)));
617 foreach(lc, historyFileList)
623 if (
lstat(pathbuf, &statbuf) != 0)
626 errmsg(
"could not stat file \"%s\": %m", pathbuf)));
628 sendFile(sink, pathbuf, pathbuf, &statbuf,
false,
639 "BLCKSZ too small for 2 tar blocks");
659 "%lld total checksum verification failures",
665 errmsg(
"checksum verification failure during base backup")));
688 char *fna = (
char *)
lfirst(
a);
689 char *fnb = (
char *)
lfirst(
b);
691 return strcmp(fna + 8, fnb + 8);
701 bool o_label =
false;
702 bool o_progress =
false;
703 bool o_checkpoint =
false;
704 bool o_nowait =
false;
706 bool o_incremental =
false;
707 bool o_maxrate =
false;
708 bool o_tablespace_map =
false;
709 bool o_noverify_checksums =
false;
710 bool o_manifest =
false;
711 bool o_manifest_checksums =
false;
712 bool o_target =
false;
713 bool o_target_detail =
false;
714 char *target_str = NULL;
715 char *target_detail_str = NULL;
716 bool o_compression =
false;
717 bool o_compression_detail =
false;
718 char *compression_detail_str = NULL;
720 MemSet(opt, 0,
sizeof(*opt));
730 if (strcmp(defel->
defname,
"label") == 0)
734 (
errcode(ERRCODE_SYNTAX_ERROR),
739 else if (strcmp(defel->
defname,
"progress") == 0)
743 (
errcode(ERRCODE_SYNTAX_ERROR),
748 else if (strcmp(defel->
defname,
"checkpoint") == 0)
754 (
errcode(ERRCODE_SYNTAX_ERROR),
762 (
errcode(ERRCODE_SYNTAX_ERROR),
763 errmsg(
"unrecognized checkpoint type: \"%s\"",
767 else if (strcmp(defel->
defname,
"wait") == 0)
771 (
errcode(ERRCODE_SYNTAX_ERROR),
776 else if (strcmp(defel->
defname,
"wal") == 0)
780 (
errcode(ERRCODE_SYNTAX_ERROR),
785 else if (strcmp(defel->
defname,
"incremental") == 0)
789 (
errcode(ERRCODE_SYNTAX_ERROR),
794 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
795 errmsg(
"incremental backups cannot be taken unless WAL summarization is enabled")));
796 o_incremental =
true;
798 else if (strcmp(defel->
defname,
"max_rate") == 0)
804 (
errcode(ERRCODE_SYNTAX_ERROR),
810 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
811 errmsg(
"%d is outside the valid range for parameter \"%s\" (%d .. %d)",
817 else if (strcmp(defel->
defname,
"tablespace_map") == 0)
819 if (o_tablespace_map)
821 (
errcode(ERRCODE_SYNTAX_ERROR),
824 o_tablespace_map =
true;
826 else if (strcmp(defel->
defname,
"verify_checksums") == 0)
828 if (o_noverify_checksums)
830 (
errcode(ERRCODE_SYNTAX_ERROR),
833 o_noverify_checksums =
true;
835 else if (strcmp(defel->
defname,
"manifest") == 0)
842 (
errcode(ERRCODE_SYNTAX_ERROR),
855 (
errcode(ERRCODE_SYNTAX_ERROR),
856 errmsg(
"unrecognized manifest option: \"%s\"",
860 else if (strcmp(defel->
defname,
"manifest_checksums") == 0)
864 if (o_manifest_checksums)
866 (
errcode(ERRCODE_SYNTAX_ERROR),
871 (
errcode(ERRCODE_SYNTAX_ERROR),
872 errmsg(
"unrecognized checksum algorithm: \"%s\"",
874 o_manifest_checksums =
true;
876 else if (strcmp(defel->
defname,
"target") == 0)
880 (
errcode(ERRCODE_SYNTAX_ERROR),
885 else if (strcmp(defel->
defname,
"target_detail") == 0)
891 (
errcode(ERRCODE_SYNTAX_ERROR),
893 target_detail_str = optval;
894 o_target_detail =
true;
896 else if (strcmp(defel->
defname,
"compression") == 0)
902 (
errcode(ERRCODE_SYNTAX_ERROR),
906 (
errcode(ERRCODE_SYNTAX_ERROR),
907 errmsg(
"unrecognized compression algorithm: \"%s\"",
909 o_compression =
true;
911 else if (strcmp(defel->
defname,
"compression_detail") == 0)
913 if (o_compression_detail)
915 (
errcode(ERRCODE_SYNTAX_ERROR),
918 o_compression_detail =
true;
922 (
errcode(ERRCODE_SYNTAX_ERROR),
923 errmsg(
"unrecognized base backup option: \"%s\"",
927 if (opt->
label == NULL)
928 opt->
label =
"base backup";
931 if (o_manifest_checksums)
933 (
errcode(ERRCODE_SYNTAX_ERROR),
934 errmsg(
"manifest checksums require a backup manifest")));
938 if (target_str == NULL)
940 if (target_detail_str != NULL)
942 (
errcode(ERRCODE_SYNTAX_ERROR),
943 errmsg(
"target detail cannot be used without target")));
947 else if (strcmp(target_str,
"client") == 0)
949 if (target_detail_str != NULL)
951 (
errcode(ERRCODE_SYNTAX_ERROR),
952 errmsg(
"target \"%s\" does not accept a target detail",
960 if (o_compression_detail && !o_compression)
962 (
errcode(ERRCODE_SYNTAX_ERROR),
963 errmsg(
"compression detail cannot be specified unless compression is enabled")));
973 if (error_detail != NULL)
976 errmsg(
"invalid compression specification: %s",
998 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
999 errmsg(
"a backup is already in progress in this session")));
1007 char activitymsg[50];
1009 snprintf(activitymsg,
sizeof(activitymsg),
"sending backup \"%s\"",
1023 else if (ib == NULL)
1025 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1026 errmsg(
"must UPLOAD_MANIFEST before performing an incremental BASE_BACKUP")));
1078 struct stat statbuf;
1083 elog(
ERROR,
"could not initialize checksum of file \"%s\"",
1087 len = strlen(content);
1098 statbuf.
st_uid = geteuid();
1099 statbuf.
st_gid = getegid();
1108 elog(
ERROR,
"could not update checksum of file \"%s\"",
1111 while (bytes_done <
len)
1118 bytes_done += nbytes;
1141 struct stat statbuf;
1147 snprintf(pathbuf,
sizeof(pathbuf),
"%s/%s", path,
1154 if (
lstat(pathbuf, &statbuf) != 0)
1156 if (errno != ENOENT)
1159 errmsg(
"could not stat file or directory \"%s\": %m",
1196 struct stat statbuf;
1198 const char *lastDir;
1199 bool isRelationDir =
false;
1200 bool isGlobalDir =
false;
1221 if (lastDir != NULL &&
1222 strspn(lastDir + 1,
"0123456789") == strlen(lastDir + 1))
1225 int parentPathLen = lastDir - path;
1231 if (strncmp(path,
"./base", parentPathLen) == 0 ||
1237 isRelationDir =
true;
1238 dboid =
atooid(lastDir + 1);
1241 else if (strcmp(path,
"./global") == 0)
1243 isRelationDir =
true;
1248 while ((de =
ReadDir(dir, path)) != NULL)
1255 bool isRelationFile =
false;
1258 if (strcmp(de->
d_name,
".") == 0 || strcmp(de->
d_name,
"..") == 0)
1268 if (strcmp(de->
d_name,
".DS_Store") == 0)
1282 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1283 errmsg(
"the standby was promoted during online backup"),
1284 errhint(
"This means that the backup being taken is corrupt "
1285 "and should not be used. "
1286 "Try taking another online backup.")));
1289 excludeFound =
false;
1299 excludeFound =
true;
1315 &relForkNum, &segno);
1326 snprintf(initForkFile,
sizeof(initForkFile),
"%s/%u_init",
1327 path, relfilenumber);
1329 if (
lstat(initForkFile, &statbuf) == 0)
1332 "unlogged relation file \"%s\" excluded from backup",
1343 "temporary relation file \"%s\" excluded from backup",
1352 if (strcmp(pathbuf,
"./global/pg_control") == 0)
1355 if (
lstat(pathbuf, &statbuf) != 0)
1357 if (errno != ENOENT)
1360 errmsg(
"could not stat file or directory \"%s\": %m",
1368 excludeFound =
false;
1373 elog(
DEBUG1,
"contents of directory \"%s\" excluded from backup", de->
d_name);
1376 &statbuf, sizeonly);
1377 excludeFound =
true;
1390 if (strcmp(pathbuf,
"./pg_wal") == 0)
1395 &statbuf, sizeonly);
1402 &statbuf, sizeonly);
1404 &statbuf, sizeonly);
1410 if (strcmp(path,
"./pg_tblspc") == 0 &&
S_ISLNK(statbuf.
st_mode))
1415 rllen =
readlink(pathbuf, linkpath,
sizeof(linkpath));
1419 errmsg(
"could not read symbolic link \"%s\": %m",
1421 if (rllen >=
sizeof(linkpath))
1423 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1424 errmsg(
"symbolic link \"%s\" target is too long",
1426 linkpath[rllen] =
'\0';
1429 &statbuf, sizeonly);
1433 bool skip_this_dir =
false;
1447 foreach(lc, tablespaces)
1458 if (ti->
rpath && strcmp(ti->
rpath, pathbuf + 2) == 0)
1460 skip_this_dir =
true;
1468 if (strcmp(pathbuf,
"./pg_tblspc") == 0 && !sendtblspclinks)
1469 skip_this_dir =
true;
1472 size +=
sendDir(sink, pathbuf, basepathlen, sizeonly, tablespaces,
1473 sendtblspclinks,
manifest, spcoid, ib);
1478 unsigned num_blocks_required = 0;
1479 unsigned truncation_block_length = 0;
1481 char *tarfilename = pathbuf + basepathlen + 1;
1484 if (ib != NULL && isRelationFile)
1498 relspcoid = GLOBALTABLESPACE_OID;
1500 relspcoid = DEFAULTTABLESPACE_OID;
1501 lookup_path =
pstrdup(tarfilename);
1505 relfilenumber, relForkNum,
1507 &num_blocks_required,
1508 relative_block_numbers,
1509 &truncation_block_length);
1514 snprintf(tarfilenamebuf,
sizeof(tarfilenamebuf),
1515 "%s/INCREMENTAL.%s",
1516 path + basepathlen + 1,
1518 tarfilename = tarfilenamebuf;
1525 sent =
sendFile(sink, pathbuf, tarfilename, &statbuf,
1526 true, dboid, spcoid,
1528 num_blocks_required,
1530 truncation_block_length);
1532 if (sent || sizeonly)
1546 (
errmsg(
"skipping special file \"%s\"", pathbuf)));
1549 if (relative_block_numbers != NULL)
1550 pfree(relative_block_numbers);
1575 struct stat *statbuf,
bool missing_ok,
Oid dboid,
Oid spcoid,
1578 BlockNumber *incremental_blocks,
unsigned truncation_block_length)
1582 int checksum_failures = 0;
1585 bool verify_checksum =
false;
1590 elog(
ERROR,
"could not initialize checksum of file \"%s\"",
1596 if (errno == ENOENT && missing_ok)
1600 errmsg(
"could not open file \"%s\": %m", readfilename)));
1618 verify_checksum =
true;
1623 if (incremental_blocks != NULL)
1626 size_t header_bytes_done = 0;
1627 char padding[BLCKSZ];
1632 &magic,
sizeof(magic));
1634 &num_incremental_blocks,
sizeof(num_incremental_blocks));
1636 &truncation_block_length,
sizeof(truncation_block_length));
1648 if ((num_incremental_blocks > 0) && (header_bytes_done % BLCKSZ != 0))
1650 paddinglen = (BLCKSZ - (header_bytes_done % BLCKSZ));
1652 memset(padding, 0, paddinglen);
1653 bytes_done += paddinglen;
1656 padding, paddinglen);
1660 if (header_bytes_done > 0)
1665 header_bytes_done) < 0)
1666 elog(
ERROR,
"could not update checksum of base backup");
1670 bytes_done +=
sizeof(magic);
1671 bytes_done +=
sizeof(num_incremental_blocks);
1672 bytes_done +=
sizeof(truncation_block_length);
1673 bytes_done +=
sizeof(
BlockNumber) * num_incremental_blocks;
1688 if (incremental_blocks == NULL)
1696 if (bytes_done >= statbuf->
st_size)
1705 blkno + segno * RELSEG_SIZE,
1707 &checksum_failures);
1716 if (ibindex >= num_incremental_blocks)
1723 relative_blkno = incremental_blocks[ibindex++];
1725 relative_blkno * BLCKSZ,
1727 relative_blkno + segno * RELSEG_SIZE,
1729 &checksum_failures);
1750 if (verify_checksum && (cnt % BLCKSZ != 0))
1753 (
errmsg(
"could not verify checksum in file \"%s\", block "
1754 "%u: read buffer size %d and page size %d "
1756 readfilename, blkno, (
int) cnt, BLCKSZ)));
1757 verify_checksum =
false;
1769 blkno += cnt / BLCKSZ;
1776 Assert(!((incremental_blocks != NULL && num_incremental_blocks > 0) &&
1777 (bytes_done % BLCKSZ != 0)));
1785 elog(
ERROR,
"could not update checksum of base backup");
1789 while (bytes_done < statbuf->
st_size)
1798 elog(
ERROR,
"could not update checksum of base backup");
1800 bytes_done += nbytes;
1812 if (checksum_failures > 1)
1815 (
errmsg_plural(
"file \"%s\" has a total of %d checksum verification failure",
1816 "file \"%s\" has a total of %d checksum verification failures",
1818 readfilename, checksum_failures)));
1851 bool verify_checksum,
int *checksum_failures)
1860 offset, readfilename,
true);
1863 if (!verify_checksum || (cnt % BLCKSZ) != 0)
1867 for (
i = 0;
i < cnt / BLCKSZ;
i++)
1870 uint16 expected_checksum;
1876 &expected_checksum))
1897 BLCKSZ, offset + BLCKSZ *
i,
1898 readfilename,
false);
1899 if (reread_cnt == 0)
1912 &expected_checksum))
1916 (*checksum_failures)++;
1917 if (*checksum_failures <= 5)
1919 (
errmsg(
"checksum verification failed in "
1920 "file \"%s\", block %u: calculated "
1921 "%X but expected %X",
1922 readfilename, blkno +
i, expected_checksum,
1924 if (*checksum_failures == 5)
1926 (
errmsg(
"further checksum verification "
1927 "failures in file \"%s\" will not "
1928 "be reported", readfilename)));
1953 size_t *bytes_done,
void *
data,
size_t length)
1957 size_t bytes_to_copy;
1963 if (length < sink->bbs_buffer_length - *bytes_done)
1967 *bytes_done += length;
1974 data = ((
char *)
data) + bytes_to_copy;
1975 length -= bytes_to_copy;
1979 elog(
ERROR,
"could not update checksum");
1994 uint16 *expected_checksum)
2016 *expected_checksum = checksum;
2022 struct stat *statbuf,
bool sizeonly)
2036 "BLCKSZ too small for tar block");
2050 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2051 errmsg(
"file name too long for tar format: \"%s\"",
2056 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
2057 errmsg(
"symbolic link target too long for tar format: "
2058 "file name \"%s\", target \"%s\"",
2062 elog(
ERROR,
"unrecognized tar error: %d", rc);
2116 const char *
filename,
bool partial_read_ok)
2128 if (!partial_read_ok && rc > 0 && rc != nbytes)
2131 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)
bbsink * bbsink_progress_new(bbsink *next, bool estimate_backup_size)
void basebackup_progress_wait_wal_archive(bbsink_state *state)
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)
BaseBackupTargetHandle * BaseBackupGetTargetHandle(char *target, char *target_detail)
bbsink * BaseBackupGetSink(BaseBackupTargetHandle *handle, bbsink *next_sink)
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)
char * validate_compress_specification(pg_compress_specification *spec)
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 * defGetString(DefElem *def)
bool defGetBoolean(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,...)
int CloseTransientFile(int fd)
DIR * AllocateDir(const char *dirname)
struct dirent * ReadDir(DIR *dir, const char *dirname)
bool looks_like_temp_rel_name(const char *name)
int OpenTransientFile(const char *fileName, int fileFlags)
#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)
List * lappend(List *list, void *datum)
void list_sort(List *list, list_sort_comparator cmp)
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)
void ReleaseAuxProcessResources(bool isCommit)
ResourceOwner CurrentResourceOwner
ResourceOwner AuxProcessResourceOwner
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)
#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