PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
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

#define MAX_RATE_LOWER   32

Definition at line 20 of file basebackup.h.

Referenced by parse_basebackup_options().

#define MAX_RATE_UPPER   1048576

Definition at line 21 of file basebackup.h.

Referenced by parse_basebackup_options(), and parse_max_rate().

Function Documentation

void SendBaseBackup ( BaseBackupCmd cmd)

Definition at line 690 of file basebackup.c.

References AllocateDir(), ereport, errmsg(), ERROR, FreeDir(), 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().

691 {
692  DIR *dir;
693  basebackup_options opt;
694 
695  parse_basebackup_options(cmd->options, &opt);
696 
698 
700  {
701  char activitymsg[50];
702 
703  snprintf(activitymsg, sizeof(activitymsg), "sending backup \"%s\"",
704  opt.label);
705  set_ps_display(activitymsg, false);
706  }
707 
708  /* Make sure we can open the directory with tablespaces in it */
709  dir = AllocateDir("pg_tblspc");
710  if (!dir)
711  ereport(ERROR,
712  (errmsg("could not open directory \"%s\": %m", "pg_tblspc")));
713 
714  perform_base_backup(&opt, dir);
715 
716  FreeDir(dir);
717 }
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:326
static void parse_basebackup_options(List *options, basebackup_options *opt)
Definition: basebackup.c:584
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
Definition: dirent.c:25
#define ERROR
Definition: elog.h:43
static void perform_base_backup(basebackup_options *opt, DIR *tblspcdir)
Definition: basebackup.c:187
const char * label
Definition: basebackup.c:44
DIR * AllocateDir(const char *dirname)
Definition: fd.c:2367
#define ereport(elevel, rest)
Definition: elog.h:122
void WalSndSetState(WalSndState state)
Definition: walsender.c:3097
int errmsg(const char *fmt,...)
Definition: elog.c:797
int FreeDir(DIR *dir)
Definition: fd.c:2476
int64 sendTablespace ( char *  path,
bool  sizeonly 
)

Definition at line 910 of file basebackup.c.

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

Referenced by do_pg_start_backup(), and perform_base_backup().

911 {
912  int64 size;
913  char pathbuf[MAXPGPATH];
914  struct stat statbuf;
915 
916  /*
917  * 'path' points to the tablespace location, but we only want to include
918  * the version directory in it that belongs to us.
919  */
920  snprintf(pathbuf, sizeof(pathbuf), "%s/%s", path,
922 
923  /*
924  * Store a directory entry in the tar file so we get the permissions
925  * right.
926  */
927  if (lstat(pathbuf, &statbuf) != 0)
928  {
929  if (errno != ENOENT)
930  ereport(ERROR,
932  errmsg("could not stat file or directory \"%s\": %m",
933  pathbuf)));
934 
935  /* If the tablespace went away while scanning, it's no error. */
936  return 0;
937  }
938 
939  size = _tarWriteHeader(TABLESPACE_VERSION_DIRECTORY, NULL, &statbuf,
940  sizeonly);
941 
942  /* Send all the files in the tablespace version directory */
943  size += sendDir(pathbuf, strlen(path), sizeonly, NIL, true);
944 
945  return size;
946 }
static int64 sendDir(char *path, int basepathlen, bool sizeonly, List *tablespaces, bool sendtblspclinks)
Definition: basebackup.c:961
#define NIL
Definition: pg_list.h:69
int snprintf(char *str, size_t count, const char *fmt,...) pg_attribute_printf(3
#define ERROR
Definition: elog.h:43
#define MAXPGPATH
int errcode_for_file_access(void)
Definition: elog.c:598
static int64 _tarWriteHeader(const char *filename, const char *linktarget, struct stat *statbuf, bool sizeonly)
Definition: basebackup.c:1279
#define ereport(elevel, rest)
Definition: elog.h:122
#define TABLESPACE_VERSION_DIRECTORY
Definition: catalog.h:26
int errmsg(const char *fmt,...)
Definition: elog.c:797
#define lstat(path, sb)
Definition: win32.h:262