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

Commit 6ad8ac6

Browse files
committed
Exclude additional directories in pg_basebackup
The list of files and directories that pg_basebackup excludes from the backup was somewhat incomplete and unorganized. Change that with having the exclusion driven from tables. Clean up some code around it. Also document the exclusions in more detail so that users of pg_start_backup can make use of it as well. The contents of these directories are now excluded from the backup: pg_dynshmem, pg_notify, pg_serial, pg_snapshots, pg_subtrans Also fix a bug that a pg_repl_slot or pg_stat_tmp being a symlink would cause a corrupt tar header to be created. Now such symlinks are included in the backup as empty directories. Bug found by Ashutosh Sharma <ashu.coek88@gmail.com>. From: David Steele <david@pgmasters.net> Reviewed-by: Michael Paquier <michael.paquier@gmail.com>
1 parent b82d5a2 commit 6ad8ac6

File tree

5 files changed

+243
-100
lines changed

5 files changed

+243
-100
lines changed

doc/src/sgml/backup.sgml

+16
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,22 @@ SELECT pg_stop_backup();
10891089
the new master comes on line.
10901090
</para>
10911091

1092+
<para>
1093+
The contents of the directories <filename>pg_dynshmem/</>,
1094+
<filename>pg_notify/</>, <filename>pg_serial/</>,
1095+
<filename>pg_snapshots/</>, <filename>pg_stat_tmp/</>,
1096+
and <filename>pg_subtrans/</> (but not the directories themselves) can be
1097+
omitted from the backup as they will be initialized on postmaster startup.
1098+
If <xref linkend="guc-stats-temp-directory"> is set and is under the data
1099+
directory then the contents of that directory can also be omitted.
1100+
</para>
1101+
1102+
<para>
1103+
Any file or directory beginning with <filename>pgsql_tmp</filename> can be
1104+
omitted from the backup. These files are removed on postmaster start and
1105+
the directories will be recreated as needed.
1106+
</para>
1107+
10921108
<para>
10931109
The backup label
10941110
file includes the label string you gave to <function>pg_start_backup</>,

doc/src/sgml/protocol.sgml

+10-3
Original file line numberDiff line numberDiff line change
@@ -2069,7 +2069,9 @@ The commands accepted in walsender mode are:
20692069
</listitem>
20702070
<listitem>
20712071
<para>
2072-
various temporary files created during the operation of the PostgreSQL server
2072+
Various temporary files and directories created during the operation
2073+
of the PostgreSQL server, such as any file or directory beginning
2074+
with <filename>pgsql_tmp</>.
20732075
</para>
20742076
</listitem>
20752077
<listitem>
@@ -2082,13 +2084,18 @@ The commands accepted in walsender mode are:
20822084
</listitem>
20832085
<listitem>
20842086
<para>
2085-
<filename>pg_replslot</> is copied as an empty directory.
2087+
<filename>pg_dynshmem</>, <filename>pg_notify</>,
2088+
<filename>pg_replslot</>, <filename>pg_serial</>,
2089+
<filename>pg_snapshots</>, <filename>pg_stat_tmp</>, and
2090+
<filename>pg_subtrans</> are copied as empty directories (even if
2091+
they are symbolic links).
20862092
</para>
20872093
</listitem>
20882094
<listitem>
20892095
<para>
20902096
Files other than regular files and directories, such as symbolic
2091-
links and special device files, are skipped. (Symbolic links
2097+
links (other than for the directories listed above) and special
2098+
device files, are skipped. (Symbolic links
20922099
in <filename>pg_tblspc</filename> are maintained.)
20932100
</para>
20942101
</listitem>

doc/src/sgml/ref/pg_basebackup.sgml

+6-4
Original file line numberDiff line numberDiff line change
@@ -610,10 +610,12 @@ PostgreSQL documentation
610610
<para>
611611
The backup will include all files in the data directory and tablespaces,
612612
including the configuration files and any additional files placed in the
613-
directory by third parties. But only regular files and directories are
614-
copied. Symbolic links (other than those used for tablespaces) and special
615-
device files are skipped. (See <xref linkend="protocol-replication"> for
616-
the precise details.)
613+
directory by third parties, except certain temporary files managed by
614+
PostgreSQL. But only regular files and directories are copied, except that
615+
symbolic links used for tablespaces are preserved. Symbolic links pointing
616+
to certain directories known to PostgreSQL are copied as empty directories.
617+
Other symbolic links and special device files are skipped.
618+
See <xref linkend="protocol-replication"> for the precise details.
617619
</para>
618620

619621
<para>

0 commit comments

Comments
 (0)