@@ -948,13 +948,26 @@ SELECT * FROM pg_stop_backup(false, true);
948
948
</sect3>
949
949
<sect3 id="backup-lowlevel-base-backup-exclusive">
950
950
<title>Making an exclusive low level backup</title>
951
+
952
+ <note>
953
+ <para>
954
+ The exclusive backup method is deprecated and should be avoided.
955
+ Prior to <productname>PostgreSQL</productname> 9.6, this was the only
956
+ low-level method available, but it is now recommended that all users
957
+ upgrade their scripts to use non-exclusive backups.
958
+ </para>
959
+ </note>
960
+
951
961
<para>
952
962
The process for an exclusive backup is mostly the same as for a
953
- non-exclusive one, but it differs in a few key steps. This type of backup
954
- can only be taken on a primary and does not allow concurrent backups.
955
- Prior to <productname>PostgreSQL</productname> 9.6, this
956
- was the only low-level method available, but it is now recommended that
957
- all users upgrade their scripts to use non-exclusive backups if possible.
963
+ non-exclusive one, but it differs in a few key steps. This type of
964
+ backup can only be taken on a primary and does not allow concurrent
965
+ backups. Moreover, because it writes a backup_label file on the
966
+ master, it can cause the master to fail to restart automatically after
967
+ a crash. On the other hand, the erroneous removal of a backup_label
968
+ file from a backup or standby is a common mistake which can can result
969
+ in serious data corruption. If it is necessary to use this method,
970
+ the following steps may be used.
958
971
</para>
959
972
<para>
960
973
<orderedlist>
@@ -1011,9 +1024,17 @@ SELECT pg_start_backup('label', true);
1011
1024
consider during this backup.
1012
1025
</para>
1013
1026
<para>
1014
- Note that if the server crashes during the backup it may not be
1015
- possible to restart until the <literal>backup_label</literal> file has been
1016
- manually deleted from the <envar>PGDATA</envar> directory.
1027
+ As noted above, if the server crashes during the backup it may not be
1028
+ possible to restart until the <literal>backup_label</literal> file has
1029
+ been manually deleted from the <envar>PGDATA</envar> directory. Note
1030
+ that it is very important to never remove the
1031
+ <literal>backup_label</literal> file when restoring a backup, because
1032
+ this will result in corruption. Confusion about when it is appropriate
1033
+ to remove this file is a common cause of data corruption when using this
1034
+ method; be very certain that you remove the file only on an existing
1035
+ master and never when building a standby or restoring a backup, even if
1036
+ you are building a standby that will subsequently be promoted to a new
1037
+ master.
1017
1038
</para>
1018
1039
</listitem>
1019
1040
<listitem>
@@ -1045,11 +1066,16 @@ SELECT pg_stop_backup();
1045
1066
If the archive process has fallen behind
1046
1067
because of failures of the archive command, it will keep retrying
1047
1068
until the archive succeeds and the backup is complete.
1048
- If you wish to place a time limit on the execution of
1049
- <function>pg_stop_backup</function>, set an appropriate
1050
- <varname>statement_timeout</varname> value, but make note that if
1051
- <function>pg_stop_backup</function> terminates because of this your backup
1052
- may not be valid.
1069
+ </para>
1070
+
1071
+ <para>
1072
+ When using exclusive backup mode, it is absolutely imperative to ensure
1073
+ that <function>pg_stop_backup</function> completes successfully at the
1074
+ end of the backup. Even if the backup itself fails, for example due to
1075
+ lack of disk space, failure to call <function>pg_stop_backup</function>
1076
+ will leave the server in backup mode indefinitely, causing future backups
1077
+ to fail and increasing the risk of a restart failure during the time that
1078
+ <literal>backup_label</literal> exists.
1053
1079
</para>
1054
1080
</listitem>
1055
1081
</orderedlist>
0 commit comments