@ -560,7 +560,8 @@ 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'
archive_command = 'test ! -f /mnt/server/archivedir/%f && cp %p /mnt/server/archivedir/%f' # Unix
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
<filename>/mnt/server/archivedir</>. (This is an example, not a
<filename>/mnt/server/archivedir</>. (This is an example, not a
@ -568,7 +569,7 @@ archive_command = 'cp -i %p /mnt/server/archivedir/%f </dev/null'
<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>
@ -597,17 +598,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</>. We have found that <literal>cp -i</> does
nonzero status in this case</>.
this correctly on some platforms but not others. If the chosen command
The example command above for Unix ensures this by including a separate
does not itself handle this case correctly, you should add a command
<command>test</> step. On some Unix platforms, <command>cp</> has
to test for pre-existence of the archive file. For example, something
switches such as <option>-i</> that can be used to do the same thing
like:
less verbosely, but you should not rely on these without verifying that
<programlisting>
the right exit status is returned. (In particular, GNU <command>cp</>
archive_command = 'test ! -f .../%f && cp %p .../%f'
will return status zero when <option>-i</> is used and the target file
</programlisting>
already exists, which is <emphasis>not</> the desired behavior.)
works correctly on most Unix variants.
</para>
</para>
<para>
<para>