Home Explore Blog CI



postgresql

9th chunk of `doc/src/sgml/ref/pg_restore.sgml`
ffacc3c564c033dac1963b2c04094d699bdc1431a8daf3f30000000100000fbf
 linkend="app-psql-patterns"/>),
        so multiple databases can also be excluded by writing wildcard
        characters in the pattern.  When using wildcards, be careful to
        quote the pattern if needed to prevent shell wildcard expansion.
       </para>
       <para>
        This option is only relevant when restoring from an archive made using <application>pg_dumpall</application>.
       </para>
      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--filter=<replaceable class="parameter">filename</replaceable></option></term>
      <listitem>
       <para>
        Specify a filename from which to read patterns for objects excluded
        or included from restore. The patterns are interpreted according to the
        same rules as
        <option>-n</option>/<option>--schema</option> for including objects in schemas,
        <option>-N</option>/<option>--exclude-schema</option> for excluding objects in schemas,
        <option>-P</option>/<option>--function</option> for restoring named functions,
        <option>-I</option>/<option>--index</option> for restoring named indexes,
        <option>-t</option>/<option>--table</option> for restoring named tables
        or <option>-T</option>/<option>--trigger</option> for restoring triggers.
        To read from <literal>STDIN</literal>, use <filename>-</filename> as the
        filename.  The <option>--filter</option> option can be specified in
        conjunction with the above listed options for including or excluding
        objects, and can also be specified more than once for multiple filter
        files.
       </para>

       <para>
        The file lists one database pattern per row, with the following format:
<synopsis>
{ include | exclude } { function | index | schema | table | trigger } <replaceable class="parameter">PATTERN</replaceable>
</synopsis>
       </para>

       <para>
        The first keyword specifies whether the objects matched by the pattern
        are to be included or excluded. The second keyword specifies the type
        of object to be filtered using the pattern:
        <itemizedlist>
         <listitem>
          <para>
           <literal>function</literal>: functions, works like the
           <option>-P</option>/<option>--function</option> option. This keyword
           can only be used with the <literal>include</literal> keyword.
          </para>
         </listitem>
         <listitem>
          <para>
           <literal>index</literal>: indexes, works like the
           <option>-I</option>/<option>--indexes</option> option. This keyword
           can only be used with the <literal>include</literal> keyword.
          </para>
         </listitem>
         <listitem>
          <para>
           <literal>schema</literal>: schemas, works like the
           <option>-n</option>/<option>--schema</option> and
           <option>-N</option>/<option>--exclude-schema</option> options.
          </para>
         </listitem>
         <listitem>
          <para>
           <literal>table</literal>: tables, works like the
           <option>-t</option>/<option>--table</option> option. This keyword
           can only be used with the <literal>include</literal> keyword.
          </para>
         </listitem>
         <listitem>
          <para>
           <literal>trigger</literal>: triggers, works like the
           <option>-T</option>/<option>--trigger</option> option. This keyword
           can only be used with the <literal>include</literal> keyword.
          </para>
         </listitem>
        </itemizedlist>
       </para>

       <para>
        Lines starting with <literal>#</literal> are considered comments and
        ignored. Comments can be placed after an object pattern row as well.
        Blank lines are also ignored. See <xref linkend="app-psql-patterns"/>
        for how to perform quoting in patterns.
       </para>

      </listitem>
     </varlistentry>

     <varlistentry>
      <term><option>--if-exists</option></term>

Title: pg_restore Options: Filters (cont.)
Summary
The --filter option in pg_restore allows specifying a file containing patterns for including or excluding database objects. The file lists database patterns, specifying whether to include or exclude objects of types like function, index, schema, table, or trigger, based on a pattern. Comments start with #, and blank lines are ignored. The patterns are interpreted using the same rules as psql's pattern matching.