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, struct IncrementalBackupInfo *ib)
 

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,
struct IncrementalBackupInfo ib 
)

Definition at line 989 of file basebackup.c.

990 {
991  basebackup_options opt;
992  bbsink *sink;
994 
995  if (status == SESSION_BACKUP_RUNNING)
996  ereport(ERROR,
997  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
998  errmsg("a backup is already in progress in this session")));
999 
1000  parse_basebackup_options(cmd->options, &opt);
1001 
1003 
1005  {
1006  char activitymsg[50];
1007 
1008  snprintf(activitymsg, sizeof(activitymsg), "sending backup \"%s\"",
1009  opt.label);
1010  set_ps_display(activitymsg);
1011  }
1012 
1013  /*
1014  * If we're asked to perform an incremental backup and the user has not
1015  * supplied a manifest, that's an ERROR.
1016  *
1017  * If we're asked to perform a full backup and the user did supply a
1018  * manifest, just ignore it.
1019  */
1020  if (!opt.incremental)
1021  ib = NULL;
1022  else if (ib == NULL)
1023  ereport(ERROR,
1024  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1025  errmsg("must UPLOAD_MANIFEST before performing an incremental BASE_BACKUP")));
1026 
1027  /*
1028  * If the target is specifically 'client' then set up to stream the backup
1029  * to the client; otherwise, it's being sent someplace else and should not
1030  * be sent to the client. BaseBackupGetSink has the job of setting up a
1031  * sink to send the backup data wherever it needs to go.
1032  */
1034  if (opt.target_handle != NULL)
1035  sink = BaseBackupGetSink(opt.target_handle, sink);
1036 
1037  /* Set up network throttling, if client requested it */
1038  if (opt.maxrate > 0)
1039  sink = bbsink_throttle_new(sink, opt.maxrate);
1040 
1041  /* Set up server-side compression, if client requested it */
1042  if (opt.compression == PG_COMPRESSION_GZIP)
1043  sink = bbsink_gzip_new(sink, &opt.compression_specification);
1044  else if (opt.compression == PG_COMPRESSION_LZ4)
1045  sink = bbsink_lz4_new(sink, &opt.compression_specification);
1046  else if (opt.compression == PG_COMPRESSION_ZSTD)
1047  sink = bbsink_zstd_new(sink, &opt.compression_specification);
1048 
1049  /* Set up progress reporting. */
1050  sink = bbsink_progress_new(sink, opt.progress);
1051 
1052  /*
1053  * Perform the base backup, but make sure we clean up the bbsink even if
1054  * an error occurs.
1055  */
1056  PG_TRY();
1057  {
1058  perform_base_backup(&opt, sink, ib);
1059  }
1060  PG_FINALLY();
1061  {
1062  bbsink_cleanup(sink);
1063  }
1064  PG_END_TRY();
1065 }
static void parse_basebackup_options(List *options, basebackup_options *opt)
Definition: basebackup.c:697
static void perform_base_backup(basebackup_options *opt, bbsink *sink, IncrementalBackupInfo *ib)
Definition: basebackup.c:235
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:24
@ PG_COMPRESSION_LZ4
Definition: compression.h:25
@ PG_COMPRESSION_ZSTD
Definition: compression.h:26
int errcode(int sqlerrcode)
Definition: elog.c:853
int errmsg(const char *fmt,...)
Definition: elog.c:1070
#define PG_TRY(...)
Definition: elog.h:371
#define PG_END_TRY(...)
Definition: elog.h:396
#define ERROR
Definition: elog.h:39
#define PG_FINALLY(...)
Definition: elog.h:388
#define ereport(elevel,...)
Definition: elog.h:149
#define snprintf
Definition: port.h:238
bool update_process_title
Definition: ps_status.c:29
static void set_ps_display(const char *activity)
Definition: ps_status.h:40
List * options
Definition: replnodes.h:44
pg_compress_specification compression_specification
Definition: basebackup.c:78
const char * label
Definition: basebackup.c:65
pg_compress_algorithm compression
Definition: basebackup.c:77
BaseBackupTargetHandle * target_handle
Definition: basebackup.c:75
void WalSndSetState(WalSndState state)
Definition: walsender.c:3812
@ WALSNDSTATE_BACKUP
SessionBackupState get_backup_status(void)
Definition: xlog.c:9093
SessionBackupState
Definition: xlog.h:285
@ SESSION_BACKUP_RUNNING
Definition: xlog.h:287

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, ereport, errcode(), errmsg(), ERROR, get_backup_status(), basebackup_options::incremental, 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, SESSION_BACKUP_RUNNING, set_ps_display(), snprintf, basebackup_options::target_handle, update_process_title, WalSndSetState(), and WALSNDSTATE_BACKUP.

Referenced by exec_replication_command().