22 #ifdef HAVE_SYS_SELECT_H 23 #include <sys/select.h> 45 #define ERRCODE_DATA_CORRUPTED "XX001" 104 #define MINIMUM_VERSION_FOR_PG_WAL 100000 109 #define MINIMUM_VERSION_FOR_TEMP_SLOTS 100000 114 #define MINIMUM_VERSION_FOR_MANIFESTS 130000 131 static char *
label =
"pg_basebackup base backup";
189 static void usage(
void);
198 void *callback_data);
201 void *callback_data);
204 void *callback_data);
208 bool segment_finished);
232 pg_log_error(
"failed to remove contents of data directory");
245 pg_log_error(
"failed to remove contents of WAL directory");
258 pg_log_info(
"changes to tablespace directories will not be undone");
295 for (arg_ptr = arg; *arg_ptr; arg_ptr++)
303 if (*arg_ptr ==
'\\' && *(arg_ptr + 1) ==
'=')
305 else if (*arg_ptr ==
'=' && (arg_ptr == arg || *(arg_ptr - 1) !=
'\\'))
309 pg_log_error(
"multiple \"=\" signs in tablespace mapping");
316 *dst_ptr++ = *arg_ptr;
321 pg_log_error(
"invalid tablespace mapping format \"%s\", must be \"OLDDIR=NEWDIR\"", arg);
333 pg_log_error(
"old directory is not an absolute path in tablespace mapping: %s",
340 pg_log_error(
"new directory is not an absolute path in tablespace mapping: %s",
353 if (tablespace_dirs.
tail)
356 tablespace_dirs.
head = cell;
357 tablespace_dirs.
tail = cell;
363 get_gz_error(gzFile gzf)
368 errmsg = gzerror(gzf, &errnum);
369 if (errnum == Z_ERRNO)
379 printf(
_(
"%s takes a base backup of a running PostgreSQL server.\n\n"),
383 printf(
_(
"\nOptions controlling the output:\n"));
384 printf(
_(
" -D, --pgdata=DIRECTORY receive base backup into directory\n"));
385 printf(
_(
" -F, --format=p|t output format (plain (default), tar)\n"));
386 printf(
_(
" -r, --max-rate=RATE maximum transfer rate to transfer data directory\n" 387 " (in kB/s, or use suffix \"k\" or \"M\")\n"));
388 printf(
_(
" -R, --write-recovery-conf\n" 389 " write configuration for replication\n"));
390 printf(
_(
" -T, --tablespace-mapping=OLDDIR=NEWDIR\n" 391 " relocate tablespace in OLDDIR to NEWDIR\n"));
392 printf(
_(
" --waldir=WALDIR location for the write-ahead log directory\n"));
393 printf(
_(
" -X, --wal-method=none|fetch|stream\n" 394 " include required WAL files with specified method\n"));
395 printf(
_(
" -z, --gzip compress tar output\n"));
396 printf(
_(
" -Z, --compress=0-9 compress tar output with given compression level\n"));
397 printf(
_(
"\nGeneral options:\n"));
398 printf(
_(
" -c, --checkpoint=fast|spread\n" 399 " set fast or spread checkpointing\n"));
400 printf(
_(
" -C, --create-slot create replication slot\n"));
401 printf(
_(
" -l, --label=LABEL set backup label\n"));
402 printf(
_(
" -n, --no-clean do not clean up after errors\n"));
403 printf(
_(
" -N, --no-sync do not wait for changes to be written safely to disk\n"));
404 printf(
_(
" -P, --progress show progress information\n"));
405 printf(
_(
" -S, --slot=SLOTNAME replication slot to use\n"));
406 printf(
_(
" -v, --verbose output verbose messages\n"));
407 printf(
_(
" -V, --version output version information, then exit\n"));
408 printf(
_(
" --manifest-checksums=SHA{224,256,384,512}|CRC32C|NONE\n" 409 " use algorithm for manifest checksums\n"));
410 printf(
_(
" --manifest-force-encode\n" 411 " hex encode all file names in manifest\n"));
412 printf(
_(
" --no-estimate-size do not estimate backup size in server side\n"));
413 printf(
_(
" --no-manifest suppress generation of backup manifest\n"));
414 printf(
_(
" --no-slot prevent creation of temporary replication slot\n"));
415 printf(
_(
" --no-verify-checksums\n" 416 " do not verify checksums\n"));
417 printf(
_(
" -?, --help show this help, then exit\n"));
418 printf(
_(
"\nConnection options:\n"));
419 printf(
_(
" -d, --dbname=CONNSTR connection string\n"));
420 printf(
_(
" -h, --host=HOSTNAME database server host or socket directory\n"));
421 printf(
_(
" -p, --port=PORT database server port number\n"));
422 printf(
_(
" -s, --status-interval=INTERVAL\n" 423 " time between status packets sent to server (in seconds)\n"));
424 printf(
_(
" -U, --username=NAME connect as specified database user\n"));
425 printf(
_(
" -w, --no-password never prompt for password\n"));
426 printf(
_(
" -W, --password force password prompt (should happen automatically)\n"));
427 printf(
_(
"\nReport bugs to <%s>.\n"), PACKAGE_BUGREPORT);
428 printf(
_(
"%s home page: <%s>\n"), PACKAGE_NAME, PACKAGE_URL);
442 bool segment_finished)
458 MemSet(&tv, 0,
sizeof(tv));
467 MemSet(xlogend, 0,
sizeof(xlogend));
468 r =
read(
bgpipe[0], xlogend,
sizeof(xlogend) - 1);
475 if (sscanf(xlogend,
"%X/%X", &hi, &lo) != 2)
477 pg_log_error(
"could not parse write-ahead log location \"%s\"",
537 MemSet(&stream, 0,
sizeof(stream));
606 if (sscanf(startpos,
"%X/%X", &hi, &lo) != 2)
608 pg_log_error(
"could not parse write-ahead log location \"%s\"",
612 param->
startptr = ((uint64) hi) << 32 | lo;
620 pg_log_error(
"could not create pipe for background process: %m");
635 "pg_xlog" :
"pg_wal");
655 pg_log_info(
"created temporary replication slot \"%s\"",
671 snprintf(statusdir,
sizeof(statusdir),
"%s/%s/archive_status",
674 "pg_xlog" :
"pg_wal");
678 pg_log_error(
"could not create directory \"%s\": %m", statusdir);
696 pg_log_error(
"could not create background process: %m");
731 pg_log_error(
"could not create directory \"%s\": %m", dirname);
752 pg_log_error(
"directory \"%s\" exists but is not empty", dirname);
759 pg_log_error(
"could not access directory \"%s\": %m", dirname);
777 bool force,
bool finished)
780 char totaldone_str[32];
781 char totalsize_str[32];
814 #define VERBOSE_FILENAME_LENGTH 35 824 ngettext(
"%*s/%s kB (100%%), %d/%d tablespace %*s",
825 "%*s/%s kB (100%%), %d/%d tablespaces %*s",
827 (
int) strlen(totalsize_str),
828 totaldone_str, totalsize_str,
836 ngettext(
"%*s/%s kB (%d%%), %d/%d tablespace (%s%-*.*s)",
837 "%*s/%s kB (%d%%), %d/%d tablespaces (%s%-*.*s)",
839 (
int) strlen(totalsize_str),
840 totaldone_str, totalsize_str, percent,
843 truncate ?
"..." :
"",
852 ngettext(
"%*s/%s kB (%d%%), %d/%d tablespace",
853 "%*s/%s kB (%d%%), %d/%d tablespaces",
855 (
int) strlen(totalsize_str),
856 totaldone_str, totalsize_str, percent,
863 fputc((!finished && isatty(fileno(stderr))) ?
'\r' :
'\n', stderr);
874 result = strtod(src, &after_num);
875 if (src == after_num)
877 pg_log_error(
"transfer rate \"%s\" is not a valid value", src);
891 pg_log_error(
"transfer rate must be greater than zero");
899 while (*after_num !=
'\0' && isspace((
unsigned char) *after_num))
902 if (*after_num !=
'\0')
905 if (*after_num ==
'k')
910 else if (*after_num ==
'M')
918 while (*after_num !=
'\0' && isspace((
unsigned char) *after_num))
921 if (*after_num !=
'\0')
923 pg_log_error(
"invalid --max-rate unit: \"%s\"", suffix);
928 if ((uint64) result != (uint64) ((
uint32) result))
930 pg_log_error(
"transfer rate \"%s\" exceeds integer range", src);
940 pg_log_error(
"transfer rate \"%s\" is out of range", src);
944 return (
int32) result;
986 (*callback) (r,
copybuf, callback_data);
999 if (state->ztarfile != NULL)
1002 if (gzwrite(state->ztarfile, buf, r) != r)
1007 pg_log_error(
"could not write to compressed file \"%s\": %s",
1008 state->
filename, get_gz_error(state->ztarfile));
1016 if (fwrite(buf, r, 1, state->
tarfile) != 1)
1044 memset(&state, 0,
sizeof(state));
1058 if (strcmp(
basedir,
"-") == 0)
1061 _setmode(fileno(
stdout), _O_BINARY);
1075 state.ztarfile = gzdopen(fd,
"wb");
1076 if (state.ztarfile == NULL)
1083 Z_DEFAULT_STRATEGY) != Z_OK)
1102 state.ztarfile = gzopen(state.
filename,
"wb");
1104 Z_DEFAULT_STRATEGY) != Z_OK)
1131 state.ztarfile = gzopen(state.
filename,
"wb");
1133 Z_DEFAULT_STRATEGY) != Z_OK)
1152 if (!state.ztarfile)
1155 pg_log_error(
"could not create compressed file \"%s\": %s",
1156 state.
filename, get_gz_error(state.ztarfile));
1182 MemSet(zerobuf, 0,
sizeof(zerobuf));
1201 recoveryconfcontents->
len,
1209 recoveryconfcontents->
len);
1263 if (state.ztarfile != NULL)
1265 if (gzclose(state.ztarfile) != 0)
1267 pg_log_error(
"could not close compressed file \"%s\": %s",
1268 state.
filename, get_gz_error(state.ztarfile));
1275 if (strcmp(
basedir,
"-") != 0)
1277 if (fclose(state.
tarfile) != 0)
1346 bytes2copy = (rr > hdrleft ? hdrleft : rr);
1368 (strcmp(&state->
tarhdr[0],
"standby.signal") == 0);
1370 (strcmp(&state->
tarhdr[0],
"postgresql.auto.conf") == 0);
1374 (strcmp(&state->
tarhdr[0],
"recovery.conf") == 0);
1388 state->
filesz + recoveryconfcontents->
len,
1425 bytes2write = (state->
filesz > rr ? rr : state->
filesz);
1432 state->
filesz -= bytes2write;
1446 recoveryconfcontents->
len);
1452 MemSet(zerobuf, 0,
sizeof(zerobuf));
1494 strlcpy(canon_dir, dir,
sizeof(canon_dir));
1497 for (cell = tablespace_dirs.
head; cell; cell = cell->
next)
1498 if (strcmp(canon_dir, cell->
old_dir) == 0)
1518 bool basetablespace;
1520 memset(&state, 0,
sizeof(state));
1539 if (state.
file != NULL)
1541 pg_log_error(
"COPY stream ended before last file was finished");
1559 if (state->
file == NULL)
1598 if (copybuf[156] ==
'5')
1626 if (chmod(state->
filename, (mode_t) filemode))
1627 pg_log_error(
"could not set permissions on directory \"%s\": %m",
1631 else if (copybuf[156] ==
'2')
1651 pg_log_error(
"could not create symbolic link from \"%s\" to \"%s\": %m",
1676 if (chmod(state->
filename, (mode_t) filemode))
1677 pg_log_error(
"could not set permissions on file \"%s\": %m",
1686 fclose(state->
file);
1702 fclose(state->
file);
1709 if (fwrite(copybuf, r, 1, state->
file) != 1)
1727 fclose(state->
file);
1743 "%s/backup_manifest.tmp",
basedir);
1745 if (state.
file == NULL)
1765 if (fwrite(copybuf, r, 1, state->
file) != 1)
1789 void *callback_data)
1800 char *sysidentifier;
1805 char *maxrate_clause = NULL;
1806 char *manifest_clause = NULL;
1807 char *manifest_checksums_clause =
"";
1815 int writing_to_stdout;
1823 minServerMajor = 901;
1824 maxServerMajor = PG_VERSION_NUM / 100;
1826 serverMajor = serverVersion / 100;
1827 if (serverMajor < minServerMajor || serverMajor > maxServerMajor)
1832 serverver ? serverver :
"'unknown'");
1846 pg_log_info(
"HINT: use -X none or -X fetch to disable log streaming");
1873 manifest_clause =
"MANIFEST 'force-encode'";
1875 manifest_clause =
"MANIFEST 'yes'";
1877 manifest_checksums_clause =
psprintf(
"MANIFEST_CHECKSUMS '%s'",
1882 pg_log_info(
"initiating base backup, waiting for checkpoint to complete");
1886 fprintf(stderr,
"waiting for checkpoint");
1887 if (isatty(fileno(stderr)))
1894 psprintf(
"BASE_BACKUP LABEL '%s' %s %s %s %s %s %s %s %s %s",
1900 maxrate_clause ? maxrate_clause :
"",
1901 format ==
't' ?
"TABLESPACE_MAP" :
"",
1903 manifest_clause ? manifest_clause :
"",
1904 manifest_checksums_clause);
1908 pg_log_error(
"could not send replication command \"%s\": %s",
1925 pg_log_error(
"server returned unexpected response to BASE_BACKUP command; got %d rows and %d fields, expected %d rows and %d fields",
1943 starttli = latesttli;
1945 MemSet(xlogend, 0,
sizeof(xlogend));
1948 pg_log_info(
"write-ahead log start point: %s on timeline %u",
1949 xlogstart, starttli);
1992 writing_to_stdout =
format ==
't' && strcmp(
basedir,
"-") == 0;
1993 if (writing_to_stdout &&
PQntuples(res) > 1)
1995 pg_log_error(
"can only write single tablespace to stdout, database has %d",
2032 if (!writing_to_stdout &&
manifest)
2046 pg_log_error(
"could not get write-ahead log end position from server: %s",
2052 pg_log_error(
"no write-ahead log end position returned from server");
2057 pg_log_info(
"write-ahead log end point: %s", xlogend);
2091 intptr_t bgchild_handle =
bgchild;
2097 pg_log_info(
"waiting for background process to finish streaming ...");
2100 if (
write(
bgpipe[1], xlogend, strlen(xlogend)) != strlen(xlogend))
2102 pg_log_info(
"could not send command to background pipe: %m");
2107 r = waitpid(
bgchild, &status, 0);
2108 if (r == (pid_t) -1)
2131 if (sscanf(xlogend,
"%X/%X", &hi, &lo) != 2)
2133 pg_log_error(
"could not parse write-ahead log location \"%s\"",
2141 if (WaitForSingleObjectEx((HANDLE) bgchild_handle, INFINITE, FALSE) !=
2148 if (GetExitCodeThread((HANDLE) bgchild_handle, &status) == 0)
2151 pg_log_error(
"could not get child thread exit status: %m");
2157 (
unsigned int) status);
2187 if (strcmp(
basedir,
"-") != 0)
2188 (void) fsync_dir_recurse(
basedir);
2192 (void) fsync_pgdata(
basedir, serverVersion);
2203 if (!writing_to_stdout &&
manifest)
2209 pg_log_info(
"renaming backup_manifest.tmp to backup_manifest");
2227 static struct option long_options[] = {
2272 if (strcmp(argv[1],
"--help") == 0 || strcmp(argv[1],
"-?") == 0)
2277 else if (strcmp(argv[1],
"-V") == 0
2278 || strcmp(argv[1],
"--version") == 0)
2280 puts(
"pg_basebackup (PostgreSQL) " PG_VERSION);
2287 while ((c =
getopt_long(argc, argv,
"CD:F:r:RS:T:X:l:nNzZ:d:c:h:p:U:s:wWkvP",
2288 long_options, &option_index)) != -1)
2299 if (strcmp(
optarg,
"p") == 0 || strcmp(
optarg,
"plain") == 0)
2301 else if (strcmp(
optarg,
"t") == 0 || strcmp(
optarg,
"tar") == 0)
2305 pg_log_error(
"invalid output format \"%s\", must be \"plain\" or \"tar\"",
2332 if (strcmp(
optarg,
"n") == 0 ||
2333 strcmp(
optarg,
"none") == 0)
2337 else if (strcmp(
optarg,
"f") == 0 ||
2338 strcmp(
optarg,
"fetch") == 0)
2342 else if (strcmp(
optarg,
"s") == 0 ||
2343 strcmp(
optarg,
"stream") == 0)
2349 pg_log_error(
"invalid wal-method option \"%s\", must be \"fetch\", \"stream\", or \"none\"",
2375 if (compresslevel < 0 || compresslevel > 9)
2388 pg_log_error(
"invalid checkpoint argument \"%s\", must be \"fast\" or \"spread\"",
2445 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2456 pg_log_error(
"too many command-line arguments (first is \"%s\")",
2458 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2469 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2479 pg_log_error(
"only tar mode backups can be compressed");
2480 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2487 pg_log_error(
"cannot stream write-ahead logs in tar mode to stdout");
2488 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2495 pg_log_error(
"replication slots can only be used with WAL streaming");
2496 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2505 pg_log_error(
"--no-slot cannot be used with slot name");
2506 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2517 pg_log_error(
"%s needs a slot to be specified using --slot",
2519 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2527 "--create-slot",
"--no-slot");
2528 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2538 pg_log_error(
"WAL directory location can only be specified in plain mode");
2539 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2548 pg_log_error(
"WAL directory location must be an absolute path");
2549 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2558 pg_log_error(
"this build does not support compression");
2566 "--progress",
"--no-estimate-size");
2567 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2575 "--no-manifest",
"--manifest-checksums");
2576 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2584 "--no-manifest",
"--manifest-force-encode");
2585 fprintf(stderr,
_(
"Try \"%s --help\" for more information.\n"),
2638 "pg_xlog" :
"pg_wal");
2643 pg_log_error(
"could not create symbolic link \"%s\": %m", linkloc);
2647 pg_log_error(
"symlinks are not supported on this platform");
bool found_postgresql_auto_conf
int PQnfields(const PGresult *res)
char current_path[MAXPGPATH]
static PQExpBuffer recoveryconfcontents
static IncludeWal includewal
char * PQerrorMessage(const PGconn *conn)
#define Z_DEFAULT_COMPRESSION
static bool verify_checksums
static bool found_existing_pgdata
bool is_recovery_guc_supported
static bool found_tablespace_dirs
const char * mapped_tblspc_path
char * PQgetvalue(const PGresult *res, int tup_num, int field_num)
const char * PQparameterStatus(const PGconn *conn, const char *paramName)
bool pg_str_endswith(const char *str, const char *end)
int pg_mkdir_p(char *path, int omode)
static TablespaceList tablespace_dirs
const char * get_progname(const char *argv0)
void termPQExpBuffer(PQExpBuffer str)
uint64 read_tar_number(const char *s, int len)
#define pg_log_error(...)
int getopt_long(int argc, char *const argv[], const char *optstring, const struct option *longopts, int *longindex)
static int32 parse_max_rate(char *src)
static bool manifest_force_encode
void pg_logging_init(const char *argv0)
char * psprintf(const char *fmt,...)
char tarhdr[TAR_BLOCK_SIZE]
void WriteRecoveryConfig(PGconn *pgconn, char *target_dir, PQExpBuffer contents)
static pg_time_t last_progress_report
static int tablespacecount
static void writeTarData(WriteTarState *state, char *buf, int r)
void _dosmaperr(unsigned long)
bool RunIdentifySystem(PGconn *conn, char **sysid, TimeLineID *starttli, XLogRecPtr *startpos, char **db_name)
#define VERBOSE_FILENAME_LENGTH
struct UnpackTarState UnpackTarState
void canonicalize_path(char *path)
static bool writerecoveryconf
void PQfinish(PGconn *conn)
static bool checksum_failure
#define MemSet(start, val, len)
#define MINIMUM_VERSION_FOR_RECOVERY_GUC
static void ReceiveBackupManifest(PGconn *conn)
int pg_strcasecmp(const char *s1, const char *s2)
int PQserverVersion(const PGconn *conn)
int PQntuples(const PGresult *res)
static bool reached_end_position(XLogRecPtr segendpos, uint32 timeline, bool segment_finished)
char * wait_result_to_str(int exitstatus)
static int fd(const char *x, int i)
struct TablespaceListCell TablespaceListCell
WalWriteMethod * CreateWalDirectoryMethod(const char *basedir, int compression, bool sync)
ExecStatusType PQresultStatus(const PGresult *res)
static void ReceiveBackupManifestInMemory(PGconn *conn, PQExpBuffer buf)
int PQgetCopyData(PGconn *conn, char **buffer, int async)
int main(int argc, char **argv)
static void BaseBackup(void)
int PQsendQuery(PGconn *conn, const char *query)
void destroyPQExpBuffer(PQExpBuffer str)
#define required_argument
static void ReceiveTarAndUnpackCopyChunk(size_t r, char *copybuf, void *callback_data)
static void ReceiveCopyData(PGconn *conn, WriteDataCallback callback, void *callback_data)
struct TablespaceList TablespaceList
bool is_postgresql_auto_conf
bool RetrieveWalSegSize(PGconn *conn)
void * pg_malloc0(size_t size)
void appendPQExpBuffer(PQExpBuffer str, const char *fmt,...)
static void callback(struct sockaddr *addr, struct sockaddr *mask, void *unused)
#define MINIMUM_VERSION_FOR_PG_WAL
static bool found_existing_xlogdir
#define symlink(oldpath, newpath)
static int has_xlogendptr
static bool made_new_pgdata
#define is_absolute_path(filename)
char * pg_strdup(const char *in)
size_t PQescapeStringConn(PGconn *conn, char *to, const char *from, size_t length, int *error)
#define select(n, r, w, e, timeout)
static char * manifest_checksums
static const char * get_tablespace_mapping(const char *dir)
static void ReceiveBackupManifestChunk(size_t r, char *copybuf, void *callback_data)
int durable_rename(const char *oldfile, const char *newfile, int elevel)
PQExpBuffer GenerateRecoveryConfig(PGconn *pgconn, char *replication_slot)
stream_stop_callback stream_stop
#define ERRCODE_DATA_CORRUPTED
WalWriteMethod * walmethod
#define unconstify(underlying_type, expr)
bool rmtree(const char *path, bool rmtopdir)
static int standby_message_timeout
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)
void FreeWalTarMethod(void)
#define ngettext(s, p, n)
#define PG_TEXTDOMAIN(domain)
static bool temp_replication_slot
int PQbackendPID(const PGconn *conn)
static void ReceiveTarFile(PGconn *conn, PGresult *res, int rownum)
struct TablespaceListCell * next
#define XLogSegmentOffset(xlogptr, wal_segsz_bytes)
static size_t tarPaddingBytesRequired(size_t len)
static void disconnect_atexit(void)
static void StartLogStreamer(char *startpos, uint32 timeline, char *sysidentifier)
TablespaceListCell * tail
static void cleanup_directories_atexit(void)
void PQclear(PGresult *res)
static void ReceiveBackupManifestInMemoryChunk(size_t r, char *copybuf, void *callback_data)
static bool in_log_streamer
#define MINIMUM_VERSION_FOR_MANIFESTS
size_t strlcpy(char *dst, const char *src, size_t siz)
PGconn * GetConnection(UserMapping *user, bool will_prep_stmt)
#define PQExpBufferDataBroken(buf)
char * PQresultErrorField(const PGresult *res, int fieldcode)
static void ReceiveTarCopyChunk(size_t r, char *copybuf, void *callback_data)
#define Assert(condition)
WalWriteMethod * CreateWalTarMethod(const char *tarbase, int compression, bool sync)
static void ReceiveAndUnpackTarFile(PGconn *conn, PGresult *res, int rownum)
void(* WriteDataCallback)(size_t nbytes, char *buf, void *callback_data)
bool ReceiveXlogStream(PGconn *conn, StreamCtl *stream)
static void kill_bgchild_atexit(void)
static XLogRecPtr xlogendptr
static XLogRecPtr startpos
TablespaceListCell * head
struct WriteManifestState WriteManifestState
static void header(const char *fmt,...) pg_attribute_printf(1
static bool made_new_xlogdir
static void CreateReplicationSlot(CreateReplicationSlotCmd *cmd)
static bool fastcheckpoint
static void tablespace_list_append(const char *arg)
static bool made_tablespace_dirs
void set_pglocale_pgservice(const char *argv0, const char *app)
int errmsg(const char *fmt,...)
static uint64 totalsize_kb
struct WriteTarState WriteTarState
int pg_check_dir(const char *dir)
int standby_message_timeout
static void verify_dir_is_empty_or_create(char *dirname, bool *created, bool *found)
static char * replication_slot
static void static void status(const char *fmt,...) pg_attribute_printf(1
static int LogStreamerMain(logstreamer_param *param)
int PQgetisnull(const PGresult *res, int tup_num, int field_num)
void PQfreemem(void *ptr)
Datum now(PG_FUNCTION_ARGS)
PGresult * PQgetResult(PGconn *conn)
#define MINIMUM_VERSION_FOR_TEMP_SLOTS
void initPQExpBuffer(PQExpBuffer str)
void FreeWalDirectoryMethod(void)
bool CheckServerVersionForStreaming(PGconn *conn)
static void progress_report(int tablespacenum, const char *filename, bool force, bool finished)