PostgreSQL Source Code  git master
basebackup.h File Reference
#include "nodes/replnodes.h"
Include dependency graph for basebackup.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  tablespaceinfo
 

Macros

#define MAX_RATE_LOWER   32
 
#define MAX_RATE_UPPER   1048576
 

Functions

void SendBaseBackup (BaseBackupCmd *cmd)
 

Macro Definition Documentation

◆ MAX_RATE_LOWER

#define MAX_RATE_LOWER   32

Definition at line 20 of file basebackup.h.

◆ MAX_RATE_UPPER

#define MAX_RATE_UPPER   1048576

Definition at line 21 of file basebackup.h.

Function Documentation

◆ SendBaseBackup()

void SendBaseBackup ( BaseBackupCmd cmd)

Definition at line 948 of file basebackup.c.

949 {
950  basebackup_options opt;
951  bbsink *sink;
952 
953  parse_basebackup_options(cmd->options, &opt);
954 
956 
958  {
959  char activitymsg[50];
960 
961  snprintf(activitymsg, sizeof(activitymsg), "sending backup \"%s\"",
962  opt.label);
963  set_ps_display(activitymsg);
964  }
965 
966  /*
967  * If the target is specifically 'client' then set up to stream the backup
968  * to the client; otherwise, it's being sent someplace else and should not
969  * be sent to the client. BaseBackupGetSink has the job of setting up a
970  * sink to send the backup data wherever it needs to go.
971  */
973  if (opt.target_handle != NULL)
974  sink = BaseBackupGetSink(opt.target_handle, sink);
975 
976  /* Set up network throttling, if client requested it */
977  if (opt.maxrate > 0)
978  sink = bbsink_throttle_new(sink, opt.maxrate);
979 
980  /* Set up server-side compression, if client requested it */
981  if (opt.compression == PG_COMPRESSION_GZIP)
982  sink = bbsink_gzip_new(sink, &opt.compression_specification);
983  else if (opt.compression == PG_COMPRESSION_LZ4)
984  sink = bbsink_lz4_new(sink, &opt.compression_specification);
985  else if (opt.compression == PG_COMPRESSION_ZSTD)
986  sink = bbsink_zstd_new(sink, &opt.compression_specification);
987 
988  /* Set up progress reporting. */
989  sink = bbsink_progress_new(sink, opt.progress);
990 
991  /*
992  * Perform the base backup, but make sure we clean up the bbsink even if
993  * an error occurs.
994  */
995  PG_TRY();
996  {
997  perform_base_backup(&opt, sink);
998  }
999  PG_FINALLY();
1000  {
1001  bbsink_cleanup(sink);
1002  }
1003  PG_END_TRY();
1004 }
static void parse_basebackup_options(List *options, basebackup_options *opt)
Definition: basebackup.c:670
static void perform_base_backup(basebackup_options *opt, bbsink *sink)
Definition: basebackup.c:228
bbsink * bbsink_copystream_new(bool send_to_client)
bbsink * bbsink_gzip_new(bbsink *next, pg_compress_specification *compress)
bbsink * bbsink_lz4_new(bbsink *next, pg_compress_specification *compress)
bbsink * bbsink_progress_new(bbsink *next, bool estimate_backup_size)
static void bbsink_cleanup(bbsink *sink)
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)
@ PG_COMPRESSION_GZIP
Definition: compression.h:20
@ PG_COMPRESSION_LZ4
Definition: compression.h:21
@ PG_COMPRESSION_ZSTD
Definition: compression.h:22
#define PG_END_TRY()
Definition: elog.h:324
#define PG_TRY()
Definition: elog.h:299
#define PG_FINALLY()
Definition: elog.h:316
#define snprintf
Definition: port.h:225
bool update_process_title
Definition: ps_status.c:36
void set_ps_display(const char *activity)
Definition: ps_status.c:349
List * options
Definition: replnodes.h:44
pg_compress_specification compression_specification
Definition: basebackup.c:72
const char * label
Definition: basebackup.c:60
pg_compress_algorithm compression
Definition: basebackup.c:71
BaseBackupTargetHandle * target_handle
Definition: basebackup.c:69
void WalSndSetState(WalSndState state)
Definition: walsender.c:3418
@ WALSNDSTATE_BACKUP

References BaseBackupGetSink(), bbsink_cleanup(), bbsink_copystream_new(), bbsink_gzip_new(), bbsink_lz4_new(), bbsink_progress_new(), bbsink_throttle_new(), bbsink_zstd_new(), basebackup_options::compression, basebackup_options::compression_specification, basebackup_options::label, basebackup_options::maxrate, BaseBackupCmd::options, parse_basebackup_options(), perform_base_backup(), PG_COMPRESSION_GZIP, PG_COMPRESSION_LZ4, PG_COMPRESSION_ZSTD, PG_END_TRY, PG_FINALLY, PG_TRY, basebackup_options::progress, basebackup_options::send_to_client, set_ps_display(), snprintf, basebackup_options::target_handle, update_process_title, WalSndSetState(), and WALSNDSTATE_BACKUP.

Referenced by exec_replication_command().