Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 0eb59c4

Browse files
committed
Backend support for streaming base backups
Add BASE_BACKUP command to walsender, allowing it to stream a base backup to the client (in tar format). The syntax is still far from ideal, that will be fixed in the switch to use a proper grammar for walsender. No client included yet, will come as a separate commit. Magnus Hagander and Heikki Linnakangas
1 parent be0c3ea commit 0eb59c4

File tree

5 files changed

+679
-1
lines changed

5 files changed

+679
-1
lines changed

doc/src/sgml/protocol.sgml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1458,6 +1458,98 @@ The commands accepted in walsender mode are:
14581458
</para>
14591459
</listitem>
14601460
</varlistentry>
1461+
1462+
<varlistentry>
1463+
<term>BASE_BACKUP <replaceable>options</><literal>;</><replaceable>label</></term>
1464+
<listitem>
1465+
<para>
1466+
Instructs the server to start streaming a base backup.
1467+
The system will automatically be put in backup mode with the label
1468+
specified in <replaceable>label</> before the backup is started, and
1469+
taken out of it when the backup is complete. The following options
1470+
are accepted:
1471+
<variablelist>
1472+
<varlistentry>
1473+
<term><literal>PROGRESS</></term>
1474+
<listitem>
1475+
<para>
1476+
Request information required to generate a progress report. This will
1477+
send back an approximate size in the header of each tablespace, which
1478+
can be used to calculate how far along the stream is done. This is
1479+
calculated by enumerating all the file sizes once before the transfer
1480+
is even started, and may as such have a negative impact on the
1481+
performance - in particular it may take longer before the first data
1482+
is streamed. Since the database files can change during the backup,
1483+
the size is only approximate and may both grow and shrink between
1484+
the time of approximation and the sending of the actual files.
1485+
</para>
1486+
</listitem>
1487+
</varlistentry>
1488+
</variablelist>
1489+
</para>
1490+
<para>
1491+
When the backup is started, the server will first send a header in
1492+
ordinary result set format, followed by one or more CopyResponse
1493+
results, one for PGDATA and one for each additional tablespace other
1494+
than <literal>pg_default</> and <literal>pg_global</>. The data in
1495+
the CopyResponse results will be a tar format (using ustar00
1496+
extensions) dump of the tablespace contents.
1497+
</para>
1498+
<para>
1499+
The header is an ordinary resultset with one row for each tablespace.
1500+
The fields in this row are:
1501+
<variablelist>
1502+
<varlistentry>
1503+
<term>spcoid</term>
1504+
<listitem>
1505+
<para>
1506+
The oid of the tablespace, or <literal>NULL</> if it's the base
1507+
directory.
1508+
</para>
1509+
</listitem>
1510+
</varlistentry>
1511+
<varlistentry>
1512+
<term>spclocation</term>
1513+
<listitem>
1514+
<para>
1515+
The full path of the tablespace directory, or <literal>NULL</>
1516+
if it's the base directory.
1517+
</para>
1518+
</listitem>
1519+
</varlistentry>
1520+
<varlistentry>
1521+
<term>size</term>
1522+
<listitem>
1523+
<para>
1524+
The approximate size of the tablespace, if progress report has
1525+
been requested; otherwise it's <literal>NULL</>.
1526+
</para>
1527+
</listitem>
1528+
</varlistentry>
1529+
</variablelist>
1530+
</para>
1531+
<para>
1532+
The tar archive for the data directory and each tablespace will contain
1533+
all files in the directories, regardless of whether they are
1534+
<productname>PostgreSQL</> files or other files added to the same
1535+
directory. The only excluded files are:
1536+
<itemizedlist spacing="compact" mark="bullet">
1537+
<listitem>
1538+
<para>
1539+
<filename>postmaster.pid</>
1540+
</para>
1541+
</listitem>
1542+
<listitem>
1543+
<para>
1544+
<filename>pg_xlog</> (including subdirectories)
1545+
</para>
1546+
</listitem>
1547+
</itemizedlist>
1548+
Owner, group and file mode are set if the underlying filesystem on
1549+
the server supports it.
1550+
</para>
1551+
</listitem>
1552+
</varlistentry>
14611553
</variablelist>
14621554

14631555
</para>

src/backend/replication/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@ subdir = src/backend/replication
1212
top_builddir = ../../..
1313
include $(top_builddir)/src/Makefile.global
1414

15-
OBJS = walsender.o walreceiverfuncs.o walreceiver.o
15+
OBJS = walsender.o walreceiverfuncs.o walreceiver.o basebackup.o
1616

1717
include $(top_srcdir)/src/backend/common.mk

0 commit comments

Comments
 (0)