class="parameter">method</replaceable></option></term>
<listitem>
<para>
When set to <literal>fsync</literal>, which is the default,
<command>pg_rewind</command> will recursively open and synchronize all
files in the data directory. The search for files will follow symbolic
links for the WAL directory and each configured tablespace.
</para>
<para>
On Linux, <literal>syncfs</literal> may be used instead to ask the
operating system to synchronize the whole file systems that contain the
data directory, the WAL files, and each tablespace. See
<xref linkend="guc-recovery-init-sync-method"/> for information about
the caveats to be aware of when using <literal>syncfs</literal>.
</para>
<para>
This option has no effect when <option>--no-sync</option> is used.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-V</option></term>
<term><option>--version</option></term>
<listitem><para>Display version information, then exit.</para></listitem>
</varlistentry>
<varlistentry>
<term><option>-?</option></term>
<term><option>--help</option></term>
<listitem><para>Show help, then exit.</para></listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1>
<title>Environment</title>
<para>
When <option>--source-server</option> option is used,
<application>pg_rewind</application> also uses the environment variables
supported by <application>libpq</application> (see <xref linkend="libpq-envars"/>).
</para>
<para>
The environment variable <envar>PG_COLOR</envar> specifies whether to use
color in diagnostic messages. Possible values are
<literal>always</literal>, <literal>auto</literal> and
<literal>never</literal>.
</para>
</refsect1>
<refsect1>
<title>Notes</title>
<para>
When executing <application>pg_rewind</application> using an online
cluster as source, a role having sufficient permissions to execute the
functions used by <application>pg_rewind</application> on the source
cluster can be used instead of a superuser. Here is how to create such
a role, named <literal>rewind_user</literal> here:
<programlisting>
CREATE USER rewind_user LOGIN;
GRANT EXECUTE ON function pg_catalog.pg_ls_dir(text, boolean, boolean) TO rewind_user;
GRANT EXECUTE ON function pg_catalog.pg_stat_file(text, boolean) TO rewind_user;
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text) TO rewind_user;
GRANT EXECUTE ON function pg_catalog.pg_read_binary_file(text, bigint, bigint, boolean) TO rewind_user;
</programlisting>
</para>
<refsect2>
<title>How It Works</title>
<para>
The basic idea is to copy all file system-level changes from the source
cluster to the target cluster:
</para>
<procedure>