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 759 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().

760 {
761  basebackup_options opt;
762 
763  parse_basebackup_options(cmd->options, &opt);
764 
766 
768  {
769  char activitymsg[50];
770 
771  snprintf(activitymsg, sizeof(activitymsg), "sending backup \"%s\"",
772  opt.label);
773  set_ps_display(activitymsg, false);
774  }
775 
776  perform_base_backup(&opt);
777 }
List * options
Definition: replnodes.h:44
bool update_process_title
Definition: ps_status.c:35
void set_ps_display(const char *activity, bool force)
Definition: ps_status.c:331
static void parse_basebackup_options(List *options, basebackup_options *opt)
Definition: basebackup.c:643
const char * label
Definition: basebackup.c:47
static void perform_base_backup(basebackup_options *opt)
Definition: basebackup.c:237
void WalSndSetState(WalSndState state)
Definition: walsender.c:3126
#define snprintf
Definition: port.h:192

◆ sendTablespace()

int64 sendTablespace ( char *  path,
bool  sizeonly 
)

Definition at line 970 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().

971 {
972  int64 size;
973  char pathbuf[MAXPGPATH];
974  struct stat statbuf;
975 
976  /*
977  * 'path' points to the tablespace location, but we only want to include
978  * the version directory in it that belongs to us.
979  */
980  snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path,
982 
983  /*
984  * Store a directory entry in the tar file so we get the permissions
985  * right.
986  */
987  if (lstat(pathbuf, &statbuf) != 0)
988  {
989  if (errno != ENOENT)
990  ereport(ERROR,
992  errmsg("could not stat file or directory \"%s\": %m",
993  pathbuf)));
994 
995  /* If the tablespace went away while scanning, it's no error. */
996  return 0;
997  }
998 
999  size = _tarWriteHeader(TABLESPACE_VERSION_DIRECTORY, NULL, &statbuf,
1000  sizeonly);
1001 
1002  /* Send all the files in the tablespace version directory */
1003  size += sendDir(pathbuf, strlen(path), sizeonly, NIL, true);
1004 
1005  return size;
1006 }
#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:631
static int64 _tarWriteHeader(const char *filename, const char *linktarget, struct stat *statbuf, bool sizeonly)
Definition: basebackup.c:1616
#define ereport(elevel, rest)
Definition: elog.h:141
#define stat(a, b)
Definition: win32_port.h:255
#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:1021
int errmsg(const char *fmt,...)
Definition: elog.c:822
#define snprintf
Definition: port.h:192