Home Explore Blog CI



postgresql

5th chunk of `doc/src/sgml/ref/pg_basebackup.sgml`
3b1473736ca7bf61b45fb2b6f5386b71c54507c6cf05a67b0000000100000fa2
 <term><option>-T <replaceable class="parameter">olddir</replaceable>=<replaceable class="parameter">newdir</replaceable></option></term>
      <term><option>--tablespace-mapping=<replaceable class="parameter">olddir</replaceable>=<replaceable class="parameter">newdir</replaceable></option></term>
      <listitem>
       <para>
        Relocates the tablespace in directory <replaceable>olddir</replaceable>
        to <replaceable>newdir</replaceable> during the backup.  To be
        effective, <replaceable>olddir</replaceable> must exactly match the
        path specification of the tablespace as it is defined on the source
        server.  (But it is not an error if there is no tablespace
        in <replaceable>olddir</replaceable> on the source server.)
        Meanwhile <replaceable>newdir</replaceable> is a directory in the
        receiving host's filesystem.  As with the main target directory,
        <replaceable>newdir</replaceable> need not exist already, but if
        it does exist it must be empty.
        Both <replaceable>olddir</replaceable>
        and <replaceable>newdir</replaceable> must be absolute paths.  If
        either path needs to contain an equal sign (<literal>=</literal>),
        precede that with a backslash.  This option can be specified multiple
        times for multiple tablespaces.
       </para>

       <para>
        If a tablespace is relocated in this way, the symbolic links inside
        the main data directory are updated to point to the new location.  So
        the new data directory is ready to be used for a new server instance
        with all tablespaces in the updated locations.
       </para>

       <para>
        Currently, this option only works with plain output format; it is
        ignored if tar format is selected.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--waldir=<replaceable class="parameter">waldir</replaceable></option></term>
      <listitem>
       <para>
        Sets the directory to write WAL (write-ahead log) files to.
        By default WAL files will be placed in
        the <filename>pg_wal</filename> subdirectory of the target
        directory, but this option can be used to place them elsewhere.
        <replaceable>waldir</replaceable> must be an absolute path.
        As with the main target directory,
        <replaceable>waldir</replaceable> need not exist already, but if
        it does exist it must be empty.
        This option can only be specified when
        the backup is in plain format.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>-X <replaceable class="parameter">method</replaceable></option></term>
      <term><option>--wal-method=<replaceable class="parameter">method</replaceable></option></term>
      <listitem>
       <para>
        Includes the required WAL (write-ahead log) files in the
        backup. This will include all write-ahead logs generated during
        the backup. Unless the method <literal>none</literal> is specified,
        it is possible to start a postmaster in the target
        directory without the need to consult the WAL archive, thus
        making the output a completely standalone backup.
       </para>
       <para>
        The following <replaceable>method</replaceable>s for collecting the
        write-ahead logs are supported:

        <variablelist>
         <varlistentry>
          <term><literal>n</literal></term>
          <term><literal>none</literal></term>
          <listitem>
           <para>
            Don't include write-ahead logs in the backup.
           </para>
          </listitem>
         </varlistentry>

         <varlistentry>
          <term><literal>f</literal></term>
          <term><literal>fetch</literal></term>
          <listitem>
           <para>
            The write-ahead log files are collected at the end of the backup.
            Therefore, it is necessary for the source

Title: pg_basebackup: Tablespace Mapping, WAL Directory, and WAL Method
Summary
The `pg_basebackup` tool offers options for tablespace mapping, allowing relocation of tablespaces to new directories during backup (plain output format only). It also provides a `--waldir` option for specifying a separate directory for WAL files (plain output format only). The `-X` or `--wal-method` option controls the inclusion of WAL files in the backup, with methods like 'none' (no WAL), 'fetch' (collect WAL at the end), and 'stream' (stream WAL during the backup).