Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit72d422a

Browse files
committed
Map basebackup tablespaces using a tablespace_map file
Windows can't reliably restore symbolic links from a tar format, soinstead during backup start we create a tablespace_map file, which isused by the restoring postgres to create the correct links in pg_tblspc.The backup protocol also now has an option to request this file to beincluded in the backup stream, and this is used by pg_basebackup whenoperating in tar mode.This is done on all platforms, not just Windows.This means that pg_basebackup will not not work in tar mode against 9.4and older servers, as this protocol option isn't implemented there.Amit Kapila, reviewed by Dilip Kumar, with a little editing from me.
1 parentd02f164 commit72d422a

File tree

12 files changed

+519
-134
lines changed

12 files changed

+519
-134
lines changed

‎doc/src/sgml/backup.sgml

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -836,8 +836,11 @@ SELECT pg_start_backup('label');
836836
<function>pg_start_backup</> creates a <firstterm>backup label</> file,
837837
called <filename>backup_label</>, in the cluster directory with
838838
information about your backup, including the start time and label
839-
string. The file is critical to the integrity of the backup, should
840-
you need to restore from it.
839+
string. The function also creates a <firstterm>tablespace map</> file,
840+
called <filename>tablespace_map</>, in the cluster directory with
841+
information about tablespace symbolic links in <filename>pg_tblspc/</>
842+
if one or more such link is present. Both files are critical to the
843+
integrity of the backup, should you need to restore from it.
841844
</para>
842845

843846
<para>
@@ -965,17 +968,20 @@ SELECT pg_stop_backup();
965968

966969
<para>
967970
It's also worth noting that the <function>pg_start_backup</> function
968-
makes a file named <filename>backup_label</> in the database cluster
969-
directory, which is removed by <function>pg_stop_backup</>.
970-
This file will of course be archived as a part of your backup dump file.
971-
The backup label file includes the label string you gave to
972-
<function>pg_start_backup</>, as well as the time at which
973-
<function>pg_start_backup</> was run, and the name of the starting WAL
974-
file. In case of confusion it is therefore possible to look inside a
975-
backup dump file and determine exactly which backup session the dump file
976-
came from. However, this file is not merely for your information; its
977-
presence and contents are critical to the proper operation of the system's
978-
recovery process.
971+
makes files named <filename>backup_label</> and
972+
<filename>tablesapce_map</> in the database cluster directory,
973+
which are removed by <function>pg_stop_backup</>. These files will of
974+
course be archived as a part of your backup dump file. The backup label
975+
file includes the label string you gave to <function>pg_start_backup</>,
976+
as well as the time at which <function>pg_start_backup</> was run, and
977+
the name of the starting WAL file. In case of confusion it is therefore
978+
possible to look inside a backup dump file and determine exactly which
979+
backup session the dump file came from. The tablespace map file includes
980+
the symbolic link names as they exist in the directory
981+
<filename>pg_tblspc/</> and the full path of each symbolic link.
982+
These files are not merely for your information; their presence and
983+
contents are critical to the proper operation of the system's recovery
984+
process.
979985
</para>
980986

981987
<para>

‎doc/src/sgml/func.sgml

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16591,11 +16591,12 @@ SELECT set_config('log_statement_stats', 'off', false);
1659116591
<function>pg_start_backup</> accepts an
1659216592
arbitrary user-defined label for the backup. (Typically this would be
1659316593
the name under which the backup dump file will be stored.) The function
16594-
writes a backup label file (<filename>backup_label</>) into the
16595-
database cluster's data directory, performs a checkpoint,
16596-
and then returns the backup's starting transaction log location as text.
16597-
The user can ignore this result value, but it is
16598-
provided in case it is useful.
16594+
writes a backup label file (<filename>backup_label</>) and, if there
16595+
are any links in the <filename>pg_tblspc/</> directory, a tablespace map
16596+
file (<filename>tablespace_map</>) into the database cluster's data
16597+
directory, performs a checkpoint, and then returns the backup's starting
16598+
transaction log location as text. The user can ignore this result value,
16599+
but it is provided in case it is useful.
1659916600
<programlisting>
1660016601
postgres=# select pg_start_backup('label_goes_here');
1660116602
pg_start_backup
@@ -16610,7 +16611,8 @@ postgres=# select pg_start_backup('label_goes_here');
1661016611
</para>
1661116612

1661216613
<para>
16613-
<function>pg_stop_backup</> removes the label file created by
16614+
<function>pg_stop_backup</> removes the label file and, if it exists,
16615+
the <filename>tablespace_map</> file created by
1661416616
<function>pg_start_backup</>, and creates a backup history file in
1661516617
the transaction log archive area. The history file includes the label given to
1661616618
<function>pg_start_backup</>, the starting and ending transaction log locations for

‎doc/src/sgml/protocol.sgml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1882,7 +1882,7 @@ The commands accepted in walsender mode are:
18821882
</varlistentry>
18831883

18841884
<varlistentry>
1885-
<term>BASE_BACKUP [<literal>LABEL</literal> <replaceable>'label'</replaceable>] [<literal>PROGRESS</literal>] [<literal>FAST</literal>] [<literal>WAL</literal>] [<literal>NOWAIT</literal>] [<literal>MAX_RATE</literal> <replaceable>rate</replaceable>]
1885+
<term>BASE_BACKUP [<literal>LABEL</literal> <replaceable>'label'</replaceable>] [<literal>PROGRESS</literal>] [<literal>FAST</literal>] [<literal>WAL</literal>] [<literal>NOWAIT</literal>] [<literal>MAX_RATE</literal> <replaceable>rate</replaceable>] [<literal>TABLESPACE_MAP</literal>]
18861886
<indexterm><primary>BASE_BACKUP</primary></indexterm>
18871887
</term>
18881888
<listitem>
@@ -1968,6 +1968,19 @@ The commands accepted in walsender mode are:
19681968
</para>
19691969
</listitem>
19701970
</varlistentry>
1971+
1972+
<varlistentry>
1973+
<term><literal>TABLESPACE_MAP</literal></term>
1974+
<listitem>
1975+
<para>
1976+
Include information about symbolic links present in the directory
1977+
<filename>pg_tblspc</filename> in a file named
1978+
<filename>tablespace_map</filename>. The tablespace map file includes
1979+
each symbolic link name as it exists in the directory
1980+
<filename>pg_tblspc/</> and the full path of that symbolic link.
1981+
</para>
1982+
</listitem>
1983+
</varlistentry>
19711984
</variablelist>
19721985
</para>
19731986
<para>

‎doc/src/sgml/ref/pg_basebackup.sgml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,11 +587,23 @@ PostgreSQL documentation
587587
tablespaces.
588588
</para>
589589

590+
<para>
591+
When tar format mode is used, it is the user's responsibility to unpack each
592+
tar file before starting postgres. If there are additional tablespaces, the
593+
tar files for them need to be unpacked in the correct locations. In this
594+
case the symbolic links for those tablespaces will be created by Postgres
595+
according to the contents of the <filename>tablespace_map</> file that is
596+
included in the <filename>base.tar</> file.
597+
</para>
598+
590599
<para>
591600
<application>pg_basebackup</application> works with servers of the same
592601
or an older major version, down to 9.1. However, WAL streaming mode (-X
593-
stream) only works with server version 9.3 and later.
602+
stream) only works with server version 9.3 and later, and tar format mode
603+
(--format=tar) of the current version only works with server version 9.5
604+
or later.
594605
</para>
606+
595607
</refsect1>
596608

597609
<refsect1>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp