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)
 
int64 sendTablespace (char *path, bool sizeonly)
 

Macro Definition Documentation

◆ MAX_RATE_LOWER

#define MAX_RATE_LOWER   32

Definition at line 20 of file basebackup.h.

Referenced by parse_basebackup_options().

◆ MAX_RATE_UPPER

#define MAX_RATE_UPPER   1048576

Definition at line 21 of file basebackup.h.

Referenced by parse_basebackup_options(), and parse_max_rate().

Function Documentation

◆ SendBaseBackup()

void SendBaseBackup ( BaseBackupCmd cmd)

Definition at line 832 of file basebackup.c.

References basebackup_options::label, BaseBackupCmd::options, parse_basebackup_options(), perform_base_backup(), set_ps_display(), snprintf, update_process_title, WalSndSetState(), and WALSNDSTATE_BACKUP.

Referenced by exec_replication_command().

833 {
834  basebackup_options opt;
835 
836  parse_basebackup_options(cmd->options, &opt);
837 
839 
841  {
842  char activitymsg[50];
843 
844  snprintf(activitymsg, sizeof(activitymsg), "sending backup \"%s\"",
845  opt.label);
846  set_ps_display(activitymsg);
847  }
848 
849  perform_base_backup(&opt);
850 }
List * options
Definition: replnodes.h:44
bool update_process_title
Definition: ps_status.c:36
static void parse_basebackup_options(List *options, basebackup_options *opt)
Definition: basebackup.c:716
void set_ps_display(const char *activity)
Definition: ps_status.c:349
const char * label
Definition: basebackup.c:48
static void perform_base_backup(basebackup_options *opt)
Definition: basebackup.c:250
void WalSndSetState(WalSndState state)
Definition: walsender.c:3145
#define snprintf
Definition: port.h:192

◆ sendTablespace()

int64 sendTablespace ( char *  path,
bool  sizeonly 
)

Definition at line 1045 of file basebackup.c.

References _tarWriteHeader(), ereport, errcode_for_file_access(), errmsg(), ERROR, lstat, MAXPGPATH, NIL, sendDir(), snprintf, stat, and TABLESPACE_VERSION_DIRECTORY.

Referenced by do_pg_start_backup(), and perform_base_backup().

1046 {
1047  int64 size;
1048  char pathbuf[MAXPGPATH];
1049  struct stat statbuf;
1050 
1051  /*
1052  * 'path' points to the tablespace location, but we only want to include
1053  * the version directory in it that belongs to us.
1054  */
1055  snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path,
1057 
1058  /*
1059  * Store a directory entry in the tar file so we get the permissions
1060  * right.
1061  */
1062  if (lstat(pathbuf, &statbuf) != 0)
1063  {
1064  if (errno != ENOENT)
1065  ereport(ERROR,
1067  errmsg("could not stat file or directory \"%s\": %m",
1068  pathbuf)));
1069 
1070  /* If the tablespace went away while scanning, it's no error. */
1071  return 0;
1072  }
1073 
1074  size = _tarWriteHeader(TABLESPACE_VERSION_DIRECTORY, NULL, &statbuf,
1075  sizeonly);
1076 
1077  /* Send all the files in the tablespace version directory */
1078  size += sendDir(pathbuf, strlen(path), sizeonly, NIL, true);
1079 
1080  return size;
1081 }
#define NIL
Definition: pg_list.h:65
#define ERROR
Definition: elog.h:43
#define MAXPGPATH
#define TABLESPACE_VERSION_DIRECTORY
Definition: relpath.h:26
int errcode_for_file_access(void)
Definition: elog.c:633
static int64 _tarWriteHeader(const char *filename, const char *linktarget, struct stat *statbuf, bool sizeonly)
Definition: basebackup.c:1705
#define stat(a, b)
Definition: win32_port.h:255
#define ereport(elevel,...)
Definition: elog.h:144
#define lstat(path, sb)
Definition: win32_port.h:244
static int64 sendDir(const char *path, int basepathlen, bool sizeonly, List *tablespaces, bool sendtblspclinks)
Definition: basebackup.c:1096
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define snprintf
Definition: port.h:192