26 #include "catalog/pg_tablespace_d.h"
60 #define SINK_BUFFER_LENGTH Max(32768, BLCKSZ)
84 static int64
sendDir(
bbsink *sink,
const char *path,
int basepathlen,
bool sizeonly,
85 List *tablespaces,
bool sendtblspclinks,
88 static 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;
302 foreach(lc,
state.tablespaces)
306 if (tmp->
path == NULL)
314 state.bytes_total_is_valid =
true;
321 foreach(lc,
state.tablespaces)
325 if (ti->
path == NULL)
328 bool sendtblspclinks =
true;
344 sendtblspclinks =
false;
355 errmsg(
"could not stat file \"%s\": %m",
384 "BLCKSZ too small for 2 tar blocks");
443 while ((de =
ReadDir(dir,
"pg_wal")) != NULL)
447 strcmp(de->
d_name + 8, firstoff + 8) >= 0 &&
448 strcmp(de->
d_name + 8, lastoff + 8) <= 0)
477 if (walFileList ==
NIL)
479 (
errmsg(
"could not find any WAL files")));
487 if (segno != startsegno)
494 (
errmsg(
"could not find WAL file \"%s\"", startfname)));
496 foreach(lc, walFileList)
498 char *walFileName = (
char *)
lfirst(lc);
503 if (!(nextsegno == segno || currsegno == segno))
509 (
errmsg(
"could not find WAL file \"%s\"", nextfname)));
512 if (segno != endsegno)
518 (
errmsg(
"could not find WAL file \"%s\"", endfname)));
522 foreach(lc, walFileList)
524 char *walFileName = (
char *)
lfirst(lc);
535 int save_errno = errno;
547 errmsg(
"could not open file \"%s\": %m", pathbuf)));
553 errmsg(
"could not stat file \"%s\": %m",
560 errmsg(
"unexpected WAL file size \"%s\"", walFileName)));
569 len, pathbuf,
true)) > 0)
585 errmsg(
"unexpected WAL file size \"%s\"", walFileName)));
615 foreach(lc, historyFileList)
621 if (
lstat(pathbuf, &statbuf) != 0)
624 errmsg(
"could not stat file \"%s\": %m", pathbuf)));
626 sendFile(sink, pathbuf, pathbuf, &statbuf,
false,
637 "BLCKSZ too small for 2 tar blocks");
657 "%lld total checksum verification failures",
663 errmsg(
"checksum verification failure during base backup")));
686 char *fna = (
char *)
lfirst(
a);
687 char *fnb = (
char *)
lfirst(
b);
689 return strcmp(fna + 8, fnb + 8);
699 bool o_label =
false;
700 bool o_progress =
false;
701 bool o_checkpoint =
false;
702 bool o_nowait =
false;
704 bool o_incremental =
false;
705 bool o_maxrate =
false;
706 bool o_tablespace_map =
false;
707 bool o_noverify_checksums =
false;
708 bool o_manifest =
false;
709 bool o_manifest_checksums =
false;
710 bool o_target =
false;
711 bool o_target_detail =
false;
712 char *target_str = NULL;
713 char *target_detail_str = NULL;
714 bool o_compression =
false;
715 bool o_compression_detail =
false;
716 char *compression_detail_str = NULL;
718 MemSet(opt, 0,
sizeof(*opt));
728 if (strcmp(defel->
defname,
"label") == 0)
732 (
errcode(ERRCODE_SYNTAX_ERROR),
737 else if (strcmp(defel->
defname,
"progress") == 0)
741 (
errcode(ERRCODE_SYNTAX_ERROR),
746 else if (strcmp(defel->
defname,
"checkpoint") == 0)
752 (
errcode(ERRCODE_SYNTAX_ERROR),
760 (
errcode(ERRCODE_SYNTAX_ERROR),
761 errmsg(
"unrecognized checkpoint type: \"%s\"",
765 else if (strcmp(defel->
defname,
"wait") == 0)
769 (
errcode(ERRCODE_SYNTAX_ERROR),
774 else if (strcmp(defel->
defname,
"wal") == 0)
778 (
errcode(ERRCODE_SYNTAX_ERROR),
783 else if (strcmp(defel->
defname,
"incremental") == 0)
787 (
errcode(ERRCODE_SYNTAX_ERROR),
792 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
793 errmsg(
"incremental backups cannot be taken unless WAL summarization is enabled")));
794 o_incremental =
true;
796 else if (strcmp(defel->
defname,
"max_rate") == 0)
802 (
errcode(ERRCODE_SYNTAX_ERROR),
808 (
errcode(ERRCODE_NUMERIC_VALUE_OUT_OF_RANGE),
809 errmsg(
"%d is outside the valid range for parameter \"%s\" (%d .. %d)",
815 else if (strcmp(defel->
defname,
"tablespace_map") == 0)
817 if (o_tablespace_map)
819 (
errcode(ERRCODE_SYNTAX_ERROR),
822 o_tablespace_map =
true;
824 else if (strcmp(defel->
defname,
"verify_checksums") == 0)
826 if (o_noverify_checksums)
828 (
errcode(ERRCODE_SYNTAX_ERROR),
831 o_noverify_checksums =
true;
833 else if (strcmp(defel->
defname,
"manifest") == 0)
840 (
errcode(ERRCODE_SYNTAX_ERROR),
853 (
errcode(ERRCODE_SYNTAX_ERROR),
854 errmsg(
"unrecognized manifest option: \"%s\"",
858 else if (strcmp(defel->
defname,
"manifest_checksums") == 0)
862 if (o_manifest_checksums)
864 (
errcode(ERRCODE_SYNTAX_ERROR),
869 (
errcode(ERRCODE_SYNTAX_ERROR),
870 errmsg(
"unrecognized checksum algorithm: \"%s\"",
872 o_manifest_checksums =
true;
874 else if (strcmp(defel->
defname,
"target") == 0)
878 (
errcode(ERRCODE_SYNTAX_ERROR),
883 else if (strcmp(defel->
defname,
"target_detail") == 0)
889 (
errcode(ERRCODE_SYNTAX_ERROR),
891 target_detail_str = optval;
892 o_target_detail =
true;
894 else if (strcmp(defel->
defname,
"compression") == 0)
900 (
errcode(ERRCODE_SYNTAX_ERROR),
904 (
errcode(ERRCODE_SYNTAX_ERROR),
905 errmsg(
"unrecognized compression algorithm: \"%s\"",
907 o_compression =
true;
909 else if (strcmp(defel->
defname,
"compression_detail") == 0)
911 if (o_compression_detail)
913 (
errcode(ERRCODE_SYNTAX_ERROR),
916 o_compression_detail =
true;
920 (
errcode(ERRCODE_SYNTAX_ERROR),
921 errmsg(
"unrecognized base backup option: \"%s\"",
925 if (opt->
label == NULL)
926 opt->
label =
"base backup";
929 if (o_manifest_checksums)
931 (
errcode(ERRCODE_SYNTAX_ERROR),
932 errmsg(
"manifest checksums require a backup manifest")));
936 if (target_str == NULL)
938 if (target_detail_str != NULL)
940 (
errcode(ERRCODE_SYNTAX_ERROR),
941 errmsg(
"target detail cannot be used without target")));
945 else if (strcmp(target_str,
"client") == 0)
947 if (target_detail_str != NULL)
949 (
errcode(ERRCODE_SYNTAX_ERROR),
950 errmsg(
"target \"%s\" does not accept a target detail",
958 if (o_compression_detail && !o_compression)
960 (
errcode(ERRCODE_SYNTAX_ERROR),
961 errmsg(
"compression detail cannot be specified unless compression is enabled")));
971 if (error_detail != NULL)
974 errmsg(
"invalid compression specification: %s",
996 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
997 errmsg(
"a backup is already in progress in this session")));
1005 char activitymsg[50];
1007 snprintf(activitymsg,
sizeof(activitymsg),
"sending backup \"%s\"",
1021 else if (ib == NULL)
1023 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1024 errmsg(
"must UPLOAD_MANIFEST before performing an incremental BASE_BACKUP")));
1076 struct stat statbuf;
1081 elog(
ERROR,
"could not initialize checksum of file \"%s\"",
1085 len = strlen(content);
1096 statbuf.
st_uid = geteuid();
1097 statbuf.
st_gid = getegid();
1106 elog(
ERROR,
"could not update checksum of file \"%s\"",
1109 while (bytes_done <
len)
1116 bytes_done += nbytes;
1139 struct stat statbuf;
1145 snprintf(pathbuf,
sizeof(pathbuf),
"%s/%s", path,
1152 if (
lstat(pathbuf, &statbuf) != 0)
1154 if (errno != ENOENT)
1157 errmsg(
"could not stat file or directory \"%s\": %m",
1194 struct stat statbuf;
1196 const char *lastDir;
1197 bool isRelationDir =
false;
1198 bool isGlobalDir =
false;
1219 if (lastDir != NULL &&
1220 strspn(lastDir + 1,
"0123456789") == strlen(lastDir + 1))
1223 int parentPathLen = lastDir - path;
1229 if (strncmp(path,
"./base", parentPathLen) == 0 ||
1235 isRelationDir =
true;
1236 dboid =
atooid(lastDir + 1);
1239 else if (strcmp(path,
"./global") == 0)
1241 isRelationDir =
true;
1246 while ((de =
ReadDir(dir, path)) != NULL)
1253 bool isRelationFile =
false;
1256 if (strcmp(de->
d_name,
".") == 0 || strcmp(de->
d_name,
"..") == 0)
1266 if (strcmp(de->
d_name,
".DS_Store") == 0)
1280 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1281 errmsg(
"the standby was promoted during online backup"),
1282 errhint(
"This means that the backup being taken is corrupt "
1283 "and should not be used. "
1284 "Try taking another online backup.")));
1287 excludeFound =
false;
1297 excludeFound =
true;
1313 &relForkNum, &segno);
1324 snprintf(initForkFile,
sizeof(initForkFile),
"%s/%u_init",
1325 path, relfilenumber);
1327 if (
lstat(initForkFile, &statbuf) == 0)
1330 "unlogged relation file \"%s\" excluded from backup",
1341 "temporary relation file \"%s\" excluded from backup",
1350 if (strcmp(pathbuf,
"./global/pg_control") == 0)
1353 if (
lstat(pathbuf, &statbuf) != 0)
1355 if (errno != ENOENT)
1358 errmsg(
"could not stat file or directory \"%s\": %m",
1366 excludeFound =
false;
1371 elog(
DEBUG1,
"contents of directory \"%s\" excluded from backup", de->
d_name);
1374 &statbuf, sizeonly);
1375 excludeFound =
true;
1388 if (strcmp(pathbuf,
"./pg_wal") == 0)
1393 &statbuf, sizeonly);
1400 &statbuf, sizeonly);
1402 &statbuf, sizeonly);
1408 if (strcmp(path,
"./pg_tblspc") == 0 &&
S_ISLNK(statbuf.
st_mode))
1413 rllen =
readlink(pathbuf, linkpath,
sizeof(linkpath));
1417 errmsg(
"could not read symbolic link \"%s\": %m",
1419 if (rllen >=
sizeof(linkpath))
1421 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1422 errmsg(
"symbolic link \"%s\" target is too long",
1424 linkpath[rllen] =
'\0';
1427 &statbuf, sizeonly);
1431 bool skip_this_dir =
false;
1445 foreach(lc, tablespaces)
1456 if (ti->
rpath && strcmp(ti->
rpath, pathbuf + 2) == 0)
1458 skip_this_dir =
true;
1466 if (strcmp(pathbuf,
"./pg_tblspc") == 0 && !sendtblspclinks)
1467 skip_this_dir =
true;
1470 size +=
sendDir(sink, pathbuf, basepathlen, sizeonly, tablespaces,
1471 sendtblspclinks,
manifest, spcoid, ib);
1476 unsigned num_blocks_required = 0;
1477 unsigned truncation_block_length = 0;
1479 char *tarfilename = pathbuf + basepathlen + 1;
1482 if (ib != NULL && isRelationFile)
1490 lookup_path =
psprintf(
"pg_tblspc/%u/%s", spcoid,
1496 relspcoid = GLOBALTABLESPACE_OID;
1498 relspcoid = DEFAULTTABLESPACE_OID;
1499 lookup_path =
pstrdup(tarfilename);
1503 relfilenumber, relForkNum,
1505 &num_blocks_required,
1506 relative_block_numbers,
1507 &truncation_block_length);
1512 snprintf(tarfilenamebuf,
sizeof(tarfilenamebuf),
1513 "%s/INCREMENTAL.%s",
1514 path + basepathlen + 1,
1516 tarfilename = tarfilenamebuf;
1523 sent =
sendFile(sink, pathbuf, tarfilename, &statbuf,
1524 true, dboid, spcoid,
1526 num_blocks_required,
1528 truncation_block_length);
1530 if (sent || sizeonly)
1544 (
errmsg(
"skipping special file \"%s\"", pathbuf)));
1547 if (relative_block_numbers != NULL)
1548 pfree(relative_block_numbers);
1573 struct stat *statbuf,
bool missing_ok,
Oid dboid,
Oid spcoid,
1576 BlockNumber *incremental_blocks,
unsigned truncation_block_length)
1580 int checksum_failures = 0;
1583 bool verify_checksum =
false;
1588 elog(
ERROR,
"could not initialize checksum of file \"%s\"",
1594 if (errno == ENOENT && missing_ok)
1598 errmsg(
"could not open file \"%s\": %m", readfilename)));
1616 verify_checksum =
true;
1621 if (incremental_blocks != NULL)
1624 size_t header_bytes_done = 0;
1625 char padding[BLCKSZ];
1630 &magic,
sizeof(magic));
1632 &num_incremental_blocks,
sizeof(num_incremental_blocks));
1634 &truncation_block_length,
sizeof(truncation_block_length));
1646 if ((num_incremental_blocks > 0) && (header_bytes_done % BLCKSZ != 0))
1648 paddinglen = (BLCKSZ - (header_bytes_done % BLCKSZ));
1650 memset(padding, 0, paddinglen);
1651 bytes_done += paddinglen;
1654 padding, paddinglen);
1658 if (header_bytes_done > 0)
1663 header_bytes_done) < 0)
1664 elog(
ERROR,
"could not update checksum of base backup");
1668 bytes_done +=
sizeof(magic);
1669 bytes_done +=
sizeof(num_incremental_blocks);
1670 bytes_done +=
sizeof(truncation_block_length);
1671 bytes_done +=
sizeof(
BlockNumber) * num_incremental_blocks;
1686 if (incremental_blocks == NULL)
1694 if (bytes_done >= statbuf->
st_size)
1703 blkno + segno * RELSEG_SIZE,
1705 &checksum_failures);
1714 if (ibindex >= num_incremental_blocks)
1721 relative_blkno = incremental_blocks[ibindex++];
1723 relative_blkno * BLCKSZ,
1725 relative_blkno + segno * RELSEG_SIZE,
1727 &checksum_failures);
1748 if (verify_checksum && (cnt % BLCKSZ != 0))
1751 (
errmsg(
"could not verify checksum in file \"%s\", block "
1752 "%u: read buffer size %d and page size %d "
1754 readfilename, blkno, (
int) cnt, BLCKSZ)));
1755 verify_checksum =
false;
1767 blkno += cnt / BLCKSZ;
1774 Assert(!((incremental_blocks != NULL && num_incremental_blocks > 0) &&
1775 (bytes_done % BLCKSZ != 0)));
1783 elog(
ERROR,
"could not update checksum of base backup");
1787 while (bytes_done < statbuf->
st_size)
1796 elog(
ERROR,
"could not update checksum of base backup");
1798 bytes_done += nbytes;
1810 if (checksum_failures > 1)
1813 (
errmsg_plural(
"file \"%s\" has a total of %d checksum verification failure",
1814 "file \"%s\" has a total of %d checksum verification failures",
1816 readfilename, checksum_failures)));
1849 bool verify_checksum,
int *checksum_failures)
1858 offset, readfilename,
true);
1861 if (!verify_checksum || (cnt % BLCKSZ) != 0)
1865 for (
i = 0;
i < cnt / BLCKSZ;
i++)
1868 uint16 expected_checksum;
1874 &expected_checksum))
1895 BLCKSZ, offset + BLCKSZ *
i,
1896 readfilename,
false);
1897 if (reread_cnt == 0)
1910 &expected_checksum))
1914 (*checksum_failures)++;
1915 if (*checksum_failures <= 5)
1917 (
errmsg(
"checksum verification failed in "
1918 "file \"%s\", block %u: calculated "
1919 "%X but expected %X",
1920 readfilename, blkno +
i, expected_checksum,
1922 if (*checksum_failures == 5)
1924 (
errmsg(
"further checksum verification "
1925 "failures in file \"%s\" will not "
1926 "be reported", readfilename)));
1951 size_t *bytes_done,
void *
data,
size_t length)
1955 size_t bytes_to_copy;
1961 if (length < sink->bbs_buffer_length - *bytes_done)
1965 *bytes_done += length;
1972 data = ((
char *)
data) + bytes_to_copy;
1973 length -= bytes_to_copy;
1977 elog(
ERROR,
"could not update checksum");
1992 uint16 *expected_checksum)
2014 *expected_checksum = checksum;
2020 struct stat *statbuf,
bool sizeonly)
2034 "BLCKSZ too small for tar block");
2048 (
errmsg(
"file name too long for tar format: \"%s\"",
2053 (
errmsg(
"symbolic link target too long for tar format: "
2054 "file name \"%s\", target \"%s\"",
2058 elog(
ERROR,
"unrecognized tar error: %d", rc);
2112 const char *
filename,
bool partial_read_ok)
2124 if (!partial_read_ok && rc > 0 && rc != nbytes)
2127 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(Page 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