<prompt>$</prompt> <userinput>pg_dump -Fd mydb -f dumpdir</userinput>
</screen>
</para>
<para>
To dump a database into a directory-format archive in parallel with
5 worker jobs:
<screen>
<prompt>$</prompt> <userinput>pg_dump -Fd mydb -j 5 -f dumpdir</userinput>
</screen>
</para>
<para>
To reload an archive file into a (freshly created) database named
<literal>newdb</literal>:
<screen>
<prompt>$</prompt> <userinput>pg_restore -d newdb db.dump</userinput>
</screen>
</para>
<para>
To reload an archive file into the same database it was dumped from,
discarding the current contents of that database:
<screen>
<prompt>$</prompt> <userinput>pg_restore -d postgres --clean --create db.dump</userinput>
</screen>
</para>
<para>
To dump a single table named <literal>mytab</literal>:
<screen>
<prompt>$</prompt> <userinput>pg_dump -t mytab mydb > db.sql</userinput>
</screen>
</para>
<para>
To dump all tables whose names start with <literal>emp</literal> in the
<literal>detroit</literal> schema, except for the table named
<literal>employee_log</literal>:
<screen>
<prompt>$</prompt> <userinput>pg_dump -t 'detroit.emp*' -T detroit.employee_log mydb > db.sql</userinput>
</screen>
</para>
<para>
To dump all schemas whose names start with <literal>east</literal> or
<literal>west</literal> and end in <literal>gsm</literal>, excluding any schemas whose
names contain the word <literal>test</literal>:
<screen>
<prompt>$</prompt> <userinput>pg_dump -n 'east*gsm' -n 'west*gsm' -N '*test*' mydb > db.sql</userinput>
</screen>
</para>
<para>
The same, using regular expression notation to consolidate the switches:
<screen>
<prompt>$</prompt> <userinput>pg_dump -n '(east|west)*gsm' -N '*test*' mydb > db.sql</userinput>
</screen>
</para>
<para>
To dump all database objects except for tables whose names begin with
<literal>ts_</literal>:
<screen>
<prompt>$</prompt> <userinput>pg_dump -T 'ts_*' mydb > db.sql</userinput>
</screen>
</para>
<para>
To specify an upper-case or mixed-case name in <option>-t</option> and related
switches, you need to double-quote the name; else it will be folded to
lower case (see <xref linkend="app-psql-patterns"/>). But
double quotes are special to the shell, so in turn they must be quoted.
Thus, to dump a single table with a mixed-case name, you need something
like
<screen>
<prompt>$</prompt> <userinput>pg_dump -t "\"MixedCaseName\"" mydb > mytab.sql</userinput>
</screen></para>
<para>
To dump all tables whose names start with <literal>mytable</literal>, except
for table <literal>mytable2</literal>, specify a filter file
<filename>filter.txt</filename> like:
<programlisting>
include table mytable*
exclude table mytable2
</programlisting>
<screen>
<prompt>$</prompt> <userinput>pg_dump --filter=filter.txt mydb > db.sql</userinput>
</screen></para>
</refsect1>
<refsect1>
<title>See Also</title>
<simplelist type="inline">
<member><xref linkend="app-pg-dumpall"/></member>
<member><xref linkend="app-pgrestore"/></member>
<member><xref linkend="app-psql"/></member>
</simplelist>
</refsect1>
</refentry>