segments
are sent to archive storage by setting
<xref linkend="guc-archive-command"/> or
<xref linkend="guc-archive-library"/>. In addition to <literal>off</literal>,
to disable, there are two modes: <literal>on</literal>, and
<literal>always</literal>. During normal operation, there is no
difference between the two modes, but when set to <literal>always</literal>
the WAL archiver is enabled also during archive recovery or standby
mode. In <literal>always</literal> mode, all files restored from the archive
or streamed with streaming replication will be archived (again). See
<xref linkend="continuous-archiving-in-standby"/> for details.
</para>
<para>
<varname>archive_mode</varname> is a separate setting from
<varname>archive_command</varname> and
<varname>archive_library</varname> so that
<varname>archive_command</varname> and
<varname>archive_library</varname> can be changed without leaving
archiving mode.
This parameter can only be set at server start.
<varname>archive_mode</varname> cannot be enabled when
<varname>wal_level</varname> is set to <literal>minimal</literal>.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-archive-command" xreflabel="archive_command">
<term><varname>archive_command</varname> (<type>string</type>)
<indexterm>
<primary><varname>archive_command</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
The local shell command to execute to archive a completed WAL file
segment. Any <literal>%p</literal> in the string is
replaced by the path name of the file to archive, and any
<literal>%f</literal> is replaced by only the file name.
(The path name is relative to the working directory of the server,
i.e., the cluster's data directory.)
Use <literal>%%</literal> to embed an actual <literal>%</literal> character in the
command. It is important for the command to return a zero
exit status only if it succeeds. For more information see
<xref linkend="backup-archiving-wal"/>.
</para>
<para>
This parameter can only be set in the <filename>postgresql.conf</filename>
file or on the server command line. It is only used if
<varname>archive_mode</varname> was enabled at server start and
<varname>archive_library</varname> is set to an empty string. If both
<varname>archive_command</varname> and <varname>archive_library</varname>
are set, an error will be raised.
If <varname>archive_command</varname> is an empty string (the default) while
<varname>archive_mode</varname> is enabled (and <varname>archive_library</varname>
is set to an empty string), WAL archiving is temporarily
disabled, but the server continues to accumulate WAL segment files in
the expectation that a command will soon be provided. Setting
<varname>archive_command</varname> to a command that does nothing but
return true, e.g., <literal>/bin/true</literal> (<literal>REM</literal> on
Windows), effectively disables
archiving, but also breaks the chain of WAL files needed for
archive recovery, so it should only be used in unusual circumstances.
</para>
</listitem>
</varlistentry>
<varlistentry id="guc-archive-library" xreflabel="archive_library">
<term><varname>archive_library</varname> (<type>string</type>)
<indexterm>
<primary><varname>archive_library</varname> configuration parameter</primary>
</indexterm>
</term>
<listitem>
<para>
The library to use for archiving completed WAL file segments. If set to
an empty string (the default), archiving via shell is enabled, and
<xref