mirror of
https://github.com/postgres/postgres.git
synced 2025-05-09 18:21:05 +03:00
Don't use "cp -i" in the example WAL archive_command.
This is a dangerous example to provide because on machines with GNU cp, it will silently do the wrong thing and risk archive corruption. Worse, during the 9.0 cycle somebody "improved" the discussion by removing the warning that used to be there about that, and instead leaving the impression that the command would work as desired on most Unixen. It doesn't. Try to rectify the damage by providing an example that is safe most everywhere, and then noting that you can try cp -i if you want but you'd better test that. In back-patching this to all supported branches, I also added an example command for Windows, which wasn't provided before 9.0.
This commit is contained in:
parent
ddef31c15c
commit
a2624c687d
@ -579,7 +579,7 @@ tar -cf backup.tar /usr/local/pgsql/data
|
|||||||
character in the command. The simplest useful command is something
|
character in the command. The simplest useful command is something
|
||||||
like:
|
like:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null' # Unix
|
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' # Unix
|
||||||
archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows
|
archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows
|
||||||
</programlisting>
|
</programlisting>
|
||||||
which will copy archivable WAL segments to the directory
|
which will copy archivable WAL segments to the directory
|
||||||
@ -588,7 +588,7 @@ archive_command = 'copy "%p" "C:\\server\\archivedir\\%f"' # Windows
|
|||||||
<literal>%p</> and <literal>%f</> parameters have been replaced,
|
<literal>%p</> and <literal>%f</> parameters have been replaced,
|
||||||
the actual command executed might look like this:
|
the actual command executed might look like this:
|
||||||
<programlisting>
|
<programlisting>
|
||||||
cp -i pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900000065 </dev/null
|
test ! -f /mnt/server/archivedir/00000001000000A900000065 && cp pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900000065
|
||||||
</programlisting>
|
</programlisting>
|
||||||
A similar command will be generated for each new file to be archived.
|
A similar command will be generated for each new file to be archived.
|
||||||
</para>
|
</para>
|
||||||
@ -617,18 +617,19 @@ cp -i pg_xlog/00000001000000A900000065 /mnt/server/archivedir/00000001000000A900
|
|||||||
preserve the integrity of your archive in case of administrator error
|
preserve the integrity of your archive in case of administrator error
|
||||||
(such as sending the output of two different servers to the same archive
|
(such as sending the output of two different servers to the same archive
|
||||||
directory).
|
directory).
|
||||||
|
</para>
|
||||||
|
|
||||||
|
<para>
|
||||||
It is advisable to test your proposed archive command to ensure that it
|
It is advisable to test your proposed archive command to ensure that it
|
||||||
indeed does not overwrite an existing file, <emphasis>and that it returns
|
indeed does not overwrite an existing file, <emphasis>and that it returns
|
||||||
nonzero status in this case</>. On many Unix platforms, <command>cp
|
nonzero status in this case</>.
|
||||||
-i</> causes copy to prompt before overwriting a file, and
|
The example command above for Unix ensures this by including a separate
|
||||||
<literal>< /dev/null</> causes the prompt (and overwriting) to
|
<command>test</> step. On some Unix platforms, <command>cp</> has
|
||||||
fail. If your platform does not support this behavior, you should
|
switches such as <option>-i</> that can be used to do the same thing
|
||||||
add a command to test for the existence of the archive file. For
|
less verbosely, but you should not rely on these without verifying that
|
||||||
example, something like:
|
the right exit status is returned. (In particular, GNU <command>cp</>
|
||||||
<programlisting>
|
will return status zero when <option>-i</> is used and the target file
|
||||||
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f'
|
already exists, which is <emphasis>not</> the desired behavior.)
|
||||||
</programlisting>
|
|
||||||
works correctly on most Unix variants.
|
|
||||||
</para>
|
</para>
|
||||||
|
|
||||||
<para>
|
<para>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user