diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 13:44:03 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-13 13:44:03 +0000 |
commit | 293913568e6a7a86fd1479e1cff8e2ecb58d6568 (patch) | |
tree | fc3b469a3ec5ab71b36ea97cc7aaddb838423a0c /doc/src/sgml/html/app-pg-dumpall.html | |
parent | Initial commit. (diff) | |
download | postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.tar.xz postgresql-16-293913568e6a7a86fd1479e1cff8e2ecb58d6568.zip |
Adding upstream version 16.2.upstream/16.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | doc/src/sgml/html/app-pg-dumpall.html | 364 |
1 files changed, 364 insertions, 0 deletions
diff --git a/doc/src/sgml/html/app-pg-dumpall.html b/doc/src/sgml/html/app-pg-dumpall.html new file mode 100644 index 0000000..62ed40c --- /dev/null +++ b/doc/src/sgml/html/app-pg-dumpall.html @@ -0,0 +1,364 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>pg_dumpall</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="app-pgdump.html" title="pg_dump" /><link rel="next" href="app-pg-isready.html" title="pg_isready" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span class="application">pg_dumpall</span></th></tr><tr><td width="10%" align="left"><a accesskey="p" href="app-pgdump.html" title="pg_dump">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><th width="60%" align="center">PostgreSQL Client Applications</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="app-pg-isready.html" title="pg_isready">Next</a></td></tr></table><hr /></div><div class="refentry" id="APP-PG-DUMPALL"><div class="titlepage"></div><a id="id-1.9.4.14.1" class="indexterm"></a><div class="refnamediv"><h2><span class="refentrytitle"><span class="application">pg_dumpall</span></span></h2><p>pg_dumpall — extract a <span class="productname">PostgreSQL</span> database cluster into a script file</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="cmdsynopsis"><p id="id-1.9.4.14.4.1"><code class="command">pg_dumpall</code> [<em class="replaceable"><code>connection-option</code></em>...] [<em class="replaceable"><code>option</code></em>...]</p></div></div><div class="refsect1" id="APP-PG-DUMPALL-DESCRIPTION"><h2>Description</h2><p> + <span class="application">pg_dumpall</span> is a utility for writing out + (<span class="quote">“<span class="quote">dumping</span>”</span>) all <span class="productname">PostgreSQL</span> databases + of a cluster into one script file. The script file contains + <acronym class="acronym">SQL</acronym> commands that can be used as input to <a class="xref" href="app-psql.html" title="psql"><span class="refentrytitle"><span class="application">psql</span></span></a> to restore the databases. It does this by + calling <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> for each database in the cluster. + <span class="application">pg_dumpall</span> also dumps global objects + that are common to all databases, namely database roles, tablespaces, + and privilege grants for configuration parameters. + (<span class="application">pg_dump</span> does not save these objects.) + </p><p> + Since <span class="application">pg_dumpall</span> reads tables from all + databases you will most likely have to connect as a database + superuser in order to produce a complete dump. Also you will need + superuser privileges to execute the saved script in order to be + allowed to add roles and create databases. + </p><p> + The SQL script will be written to the standard output. Use the + <code class="option">-f</code>/<code class="option">--file</code> option or shell operators to + redirect it into a file. + </p><p> + <span class="application">pg_dumpall</span> needs to connect several + times to the <span class="productname">PostgreSQL</span> server (once per + database). If you use password authentication it will ask for + a password each time. It is convenient to have a + <code class="filename">~/.pgpass</code> file in such cases. See <a class="xref" href="libpq-pgpass.html" title="34.16. The Password File">Section 34.16</a> for more information. + </p></div><div class="refsect1" id="id-1.9.4.14.6"><h2>Options</h2><p> + The following command-line options control the content and + format of the output. + + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-a</code><br /></span><span class="term"><code class="option">--data-only</code></span></dt><dd><p> + Dump only the data, not the schema (data definitions). + </p></dd><dt><span class="term"><code class="option">-c</code><br /></span><span class="term"><code class="option">--clean</code></span></dt><dd><p> + Emit SQL commands to <code class="command">DROP</code> all the dumped + databases, roles, and tablespaces before recreating them. + This option is useful when the restore is to overwrite an existing + cluster. If any of the objects do not exist in the destination + cluster, ignorable error messages will be reported during + restore, unless <code class="option">--if-exists</code> is also specified. + </p></dd><dt><span class="term"><code class="option">-E <em class="replaceable"><code>encoding</code></em></code><br /></span><span class="term"><code class="option">--encoding=<em class="replaceable"><code>encoding</code></em></code></span></dt><dd><p> + Create the dump in the specified character set encoding. By default, + the dump is created in the database encoding. (Another way to get the + same result is to set the <code class="envar">PGCLIENTENCODING</code> environment + variable to the desired dump encoding.) + </p></dd><dt><span class="term"><code class="option">-f <em class="replaceable"><code>filename</code></em></code><br /></span><span class="term"><code class="option">--file=<em class="replaceable"><code>filename</code></em></code></span></dt><dd><p> + Send output to the specified file. If this is omitted, the + standard output is used. + </p></dd><dt><span class="term"><code class="option">-g</code><br /></span><span class="term"><code class="option">--globals-only</code></span></dt><dd><p> + Dump only global objects (roles and tablespaces), no databases. + </p></dd><dt><span class="term"><code class="option">-O</code><br /></span><span class="term"><code class="option">--no-owner</code></span></dt><dd><p> + Do not output commands to set + ownership of objects to match the original database. + By default, <span class="application">pg_dumpall</span> issues + <code class="command">ALTER OWNER</code> or + <code class="command">SET SESSION AUTHORIZATION</code> + statements to set ownership of created schema elements. + These statements + will fail when the script is run unless it is started by a superuser + (or the same user that owns all of the objects in the script). + To make a script that can be restored by any user, but will give + that user ownership of all the objects, specify <code class="option">-O</code>. + </p></dd><dt><span class="term"><code class="option">-r</code><br /></span><span class="term"><code class="option">--roles-only</code></span></dt><dd><p> + Dump only roles, no databases or tablespaces. + </p></dd><dt><span class="term"><code class="option">-s</code><br /></span><span class="term"><code class="option">--schema-only</code></span></dt><dd><p> + Dump only the object definitions (schema), not data. + </p></dd><dt><span class="term"><code class="option">-S <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--superuser=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p> + Specify the superuser user name to use when disabling triggers. + This is relevant only if <code class="option">--disable-triggers</code> is used. + (Usually, it's better to leave this out, and instead start the + resulting script as superuser.) + </p></dd><dt><span class="term"><code class="option">-t</code><br /></span><span class="term"><code class="option">--tablespaces-only</code></span></dt><dd><p> + Dump only tablespaces, no databases or roles. + </p></dd><dt><span class="term"><code class="option">-v</code><br /></span><span class="term"><code class="option">--verbose</code></span></dt><dd><p> + Specifies verbose mode. This will cause + <span class="application">pg_dumpall</span> to output start/stop + times to the dump file, and progress messages to standard error. + Repeating the option causes additional debug-level messages + to appear on standard error. + The option is also passed down to <span class="application">pg_dump</span>. + </p></dd><dt><span class="term"><code class="option">-V</code><br /></span><span class="term"><code class="option">--version</code></span></dt><dd><p> + Print the <span class="application">pg_dumpall</span> version and exit. + </p></dd><dt><span class="term"><code class="option">-x</code><br /></span><span class="term"><code class="option">--no-privileges</code><br /></span><span class="term"><code class="option">--no-acl</code></span></dt><dd><p> + Prevent dumping of access privileges (grant/revoke commands). + </p></dd><dt><span class="term"><code class="option">--binary-upgrade</code></span></dt><dd><p> + This option is for use by in-place upgrade utilities. Its use + for other purposes is not recommended or supported. The + behavior of the option may change in future releases without + notice. + </p></dd><dt><span class="term"><code class="option">--column-inserts</code><br /></span><span class="term"><code class="option">--attribute-inserts</code></span></dt><dd><p> + Dump data as <code class="command">INSERT</code> commands with explicit + column names (<code class="literal">INSERT INTO + <em class="replaceable"><code>table</code></em> + (<em class="replaceable"><code>column</code></em>, ...) VALUES + ...</code>). This will make restoration very slow; it is mainly + useful for making dumps that can be loaded into + non-<span class="productname">PostgreSQL</span> databases. + </p></dd><dt><span class="term"><code class="option">--disable-dollar-quoting</code></span></dt><dd><p> + This option disables the use of dollar quoting for function bodies, + and forces them to be quoted using SQL standard string syntax. + </p></dd><dt><span class="term"><code class="option">--disable-triggers</code></span></dt><dd><p> + This option is relevant only when creating a data-only dump. + It instructs <span class="application">pg_dumpall</span> to include commands + to temporarily disable triggers on the target tables while + the data is restored. Use this if you have referential + integrity checks or other triggers on the tables that you + do not want to invoke during data restore. + </p><p> + Presently, the commands emitted for <code class="option">--disable-triggers</code> + must be done as superuser. So, you should also specify + a superuser name with <code class="option">-S</code>, or preferably be careful to + start the resulting script as a superuser. + </p></dd><dt><span class="term"><code class="option">--exclude-database=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p> + Do not dump databases whose name matches + <em class="replaceable"><code>pattern</code></em>. + Multiple patterns can be excluded by writing multiple + <code class="option">--exclude-database</code> switches. The + <em class="replaceable"><code>pattern</code></em> parameter is + interpreted as a pattern according to the same rules used by + <span class="application">psql</span>'s <code class="literal">\d</code> + commands (see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>), + 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. + </p></dd><dt><span class="term"><code class="option">--extra-float-digits=<em class="replaceable"><code>ndigits</code></em></code></span></dt><dd><p> + Use the specified value of extra_float_digits when dumping + floating-point data, instead of the maximum available precision. + Routine dumps made for backup purposes should not use this option. + </p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p> + Use <code class="literal">DROP ... IF EXISTS</code> commands to drop objects + in <code class="option">--clean</code> mode. This suppresses <span class="quote">“<span class="quote">does not + exist</span>”</span> errors that might otherwise be reported. This + option is not valid unless <code class="option">--clean</code> is also + specified. + </p></dd><dt><span class="term"><code class="option">--inserts</code></span></dt><dd><p> + Dump data as <code class="command">INSERT</code> commands (rather + than <code class="command">COPY</code>). This will make restoration very slow; + it is mainly useful for making dumps that can be loaded into + non-<span class="productname">PostgreSQL</span> databases. Note that + the restore might fail altogether if you have rearranged column order. + The <code class="option">--column-inserts</code> option is safer, though even + slower. + </p></dd><dt><span class="term"><code class="option">--load-via-partition-root</code></span></dt><dd><p> + When dumping data for a table partition, make + the <code class="command">COPY</code> or <code class="command">INSERT</code> statements + target the root of the partitioning hierarchy that contains it, rather + than the partition itself. This causes the appropriate partition to + be re-determined for each row when the data is loaded. This may be + useful when restoring data on a server where rows do not always fall + into the same partitions as they did on the original server. That + could happen, for example, if the partitioning column is of type text + and the two systems have different definitions of the collation used + to sort the partitioning column. + </p></dd><dt><span class="term"><code class="option">--lock-wait-timeout=<em class="replaceable"><code>timeout</code></em></code></span></dt><dd><p> + Do not wait forever to acquire shared table locks at the beginning of + the dump. Instead, fail if unable to lock a table within the specified + <em class="replaceable"><code>timeout</code></em>. The timeout may be + specified in any of the formats accepted by <code class="command">SET + statement_timeout</code>. + </p></dd><dt><span class="term"><code class="option">--no-comments</code></span></dt><dd><p> + Do not dump comments. + </p></dd><dt><span class="term"><code class="option">--no-publications</code></span></dt><dd><p> + Do not dump publications. + </p></dd><dt><span class="term"><code class="option">--no-role-passwords</code></span></dt><dd><p> + Do not dump passwords for roles. When restored, roles will have a + null password, and password authentication will always fail until the + password is set. Since password values aren't needed when this option + is specified, the role information is read from the catalog + view <code class="structname">pg_roles</code> instead + of <code class="structname">pg_authid</code>. Therefore, this option also + helps if access to <code class="structname">pg_authid</code> is restricted by + some security policy. + </p></dd><dt><span class="term"><code class="option">--no-security-labels</code></span></dt><dd><p> + Do not dump security labels. + </p></dd><dt><span class="term"><code class="option">--no-subscriptions</code></span></dt><dd><p> + Do not dump subscriptions. + </p></dd><dt><span class="term"><code class="option">--no-sync</code></span></dt><dd><p> + By default, <code class="command">pg_dumpall</code> will wait for all files + to be written safely to disk. This option causes + <code class="command">pg_dumpall</code> to return without waiting, which is + faster, but means that a subsequent operating system crash can leave + the dump corrupt. Generally, this option is useful for testing + but should not be used when dumping data from production installation. + </p></dd><dt><span class="term"><code class="option">--no-table-access-method</code></span></dt><dd><p> + Do not output commands to select table access methods. + With this option, all objects will be created with whichever + table access method is the default during restore. + </p></dd><dt><span class="term"><code class="option">--no-tablespaces</code></span></dt><dd><p> + Do not output commands to create tablespaces nor select tablespaces + for objects. + With this option, all objects will be created in whichever + tablespace is the default during restore. + </p></dd><dt><span class="term"><code class="option">--no-toast-compression</code></span></dt><dd><p> + Do not output commands to set <acronym class="acronym">TOAST</acronym> compression + methods. + With this option, all columns will be restored with the default + compression setting. + </p></dd><dt><span class="term"><code class="option">--no-unlogged-table-data</code></span></dt><dd><p> + Do not dump the contents of unlogged tables. This option has no + effect on whether or not the table definitions (schema) are dumped; + it only suppresses dumping the table data. + </p></dd><dt><span class="term"><code class="option">--on-conflict-do-nothing</code></span></dt><dd><p> + Add <code class="literal">ON CONFLICT DO NOTHING</code> to + <code class="command">INSERT</code> commands. + This option is not valid unless <code class="option">--inserts</code> or + <code class="option">--column-inserts</code> is also specified. + </p></dd><dt><span class="term"><code class="option">--quote-all-identifiers</code></span></dt><dd><p> + Force quoting of all identifiers. This option is recommended when + dumping a database from a server whose <span class="productname">PostgreSQL</span> + major version is different from <span class="application">pg_dumpall</span>'s, or when + the output is intended to be loaded into a server of a different + major version. By default, <span class="application">pg_dumpall</span> quotes only + identifiers that are reserved words in its own major version. + This sometimes results in compatibility issues when dealing with + servers of other versions that may have slightly different sets + of reserved words. Using <code class="option">--quote-all-identifiers</code> prevents + such issues, at the price of a harder-to-read dump script. + </p></dd><dt><span class="term"><code class="option">--rows-per-insert=<em class="replaceable"><code>nrows</code></em></code></span></dt><dd><p> + Dump data as <code class="command">INSERT</code> commands (rather than + <code class="command">COPY</code>). Controls the maximum number of rows per + <code class="command">INSERT</code> command. The value specified must be a + number greater than zero. Any error during restoring will cause only + rows that are part of the problematic <code class="command">INSERT</code> to be + lost, rather than the entire table contents. + </p></dd><dt><span class="term"><code class="option">--use-set-session-authorization</code></span></dt><dd><p> + Output SQL-standard <code class="command">SET SESSION AUTHORIZATION</code> commands + instead of <code class="command">ALTER OWNER</code> commands to determine object + ownership. This makes the dump more standards compatible, but + depending on the history of the objects in the dump, might not restore + properly. + </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p> + Show help about <span class="application">pg_dumpall</span> command line + arguments, and exit. + </p></dd></dl></div><p> + </p><p> + The following command-line options control the database connection parameters. + + </p><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="option">-d <em class="replaceable"><code>connstr</code></em></code><br /></span><span class="term"><code class="option">--dbname=<em class="replaceable"><code>connstr</code></em></code></span></dt><dd><p> + Specifies parameters used to connect to the server, as a <a class="link" href="libpq-connect.html#LIBPQ-CONNSTRING" title="34.1.1. Connection Strings">connection string</a>; these + will override any conflicting command line options. + </p><p> + The option is called <code class="literal">--dbname</code> for consistency with other + client applications, but because <span class="application">pg_dumpall</span> + needs to connect to many databases, the database name in the + connection string will be ignored. Use the <code class="literal">-l</code> + option to specify the name of the database used for the initial + connection, which will dump global objects and discover what other + databases should be dumped. + </p></dd><dt><span class="term"><code class="option">-h <em class="replaceable"><code>host</code></em></code><br /></span><span class="term"><code class="option">--host=<em class="replaceable"><code>host</code></em></code></span></dt><dd><p> + Specifies the host name of the machine on which the database + server is running. If the value begins with a slash, it is + used as the directory for the Unix domain socket. The default + is taken from the <code class="envar">PGHOST</code> environment variable, + if set, else a Unix domain socket connection is attempted. + </p></dd><dt><span class="term"><code class="option">-l <em class="replaceable"><code>dbname</code></em></code><br /></span><span class="term"><code class="option">--database=<em class="replaceable"><code>dbname</code></em></code></span></dt><dd><p> + Specifies the name of the database to connect to for dumping global + objects and discovering what other databases should be dumped. If + not specified, the <code class="literal">postgres</code> database will be used, + and if that does not exist, <code class="literal">template1</code> will be used. + </p></dd><dt><span class="term"><code class="option">-p <em class="replaceable"><code>port</code></em></code><br /></span><span class="term"><code class="option">--port=<em class="replaceable"><code>port</code></em></code></span></dt><dd><p> + Specifies the TCP port or local Unix domain socket file + extension on which the server is listening for connections. + Defaults to the <code class="envar">PGPORT</code> environment variable, if + set, or a compiled-in default. + </p></dd><dt><span class="term"><code class="option">-U <em class="replaceable"><code>username</code></em></code><br /></span><span class="term"><code class="option">--username=<em class="replaceable"><code>username</code></em></code></span></dt><dd><p> + User name to connect as. + </p></dd><dt><span class="term"><code class="option">-w</code><br /></span><span class="term"><code class="option">--no-password</code></span></dt><dd><p> + Never issue a password prompt. If the server requires + password authentication and a password is not available by + other means such as a <code class="filename">.pgpass</code> file, the + connection attempt will fail. This option can be useful in + batch jobs and scripts where no user is present to enter a + password. + </p></dd><dt><span class="term"><code class="option">-W</code><br /></span><span class="term"><code class="option">--password</code></span></dt><dd><p> + Force <span class="application">pg_dumpall</span> to prompt for a + password before connecting to a database. + </p><p> + This option is never essential, since + <span class="application">pg_dumpall</span> will automatically prompt + for a password if the server demands password authentication. + However, <span class="application">pg_dumpall</span> will waste a + connection attempt finding out that the server wants a password. + In some cases it is worth typing <code class="option">-W</code> to avoid the extra + connection attempt. + </p><p> + Note that the password prompt will occur again for each database + to be dumped. Usually, it's better to set up a + <code class="filename">~/.pgpass</code> file than to rely on manual password entry. + </p></dd><dt><span class="term"><code class="option">--role=<em class="replaceable"><code>rolename</code></em></code></span></dt><dd><p> + Specifies a role name to be used to create the dump. + This option causes <span class="application">pg_dumpall</span> to issue a + <code class="command">SET ROLE</code> <em class="replaceable"><code>rolename</code></em> + command after connecting to the database. It is useful when the + authenticated user (specified by <code class="option">-U</code>) lacks privileges + needed by <span class="application">pg_dumpall</span>, but can switch to a role with + the required rights. Some installations have a policy against + logging in directly as a superuser, and use of this option allows + dumps to be made without violating the policy. + </p></dd></dl></div><p> + </p></div><div class="refsect1" id="id-1.9.4.14.7"><h2>Environment</h2><div class="variablelist"><dl class="variablelist"><dt><span class="term"><code class="envar">PGHOST</code><br /></span><span class="term"><code class="envar">PGOPTIONS</code><br /></span><span class="term"><code class="envar">PGPORT</code><br /></span><span class="term"><code class="envar">PGUSER</code></span></dt><dd><p> + Default connection parameters + </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p> + Specifies whether to use color in diagnostic messages. Possible values + are <code class="literal">always</code>, <code class="literal">auto</code> and + <code class="literal">never</code>. + </p></dd></dl></div><p> + This utility, like most other <span class="productname">PostgreSQL</span> utilities, + also uses the environment variables supported by <span class="application">libpq</span> + (see <a class="xref" href="libpq-envars.html" title="34.15. Environment Variables">Section 34.15</a>). + </p></div><div class="refsect1" id="id-1.9.4.14.8"><h2>Notes</h2><p> + Since <span class="application">pg_dumpall</span> calls + <span class="application">pg_dump</span> internally, some diagnostic + messages will refer to <span class="application">pg_dump</span>. + </p><p> + The <code class="option">--clean</code> option can be useful even when your + intention is to restore the dump script into a fresh cluster. Use of + <code class="option">--clean</code> authorizes the script to drop and re-create the + built-in <code class="literal">postgres</code> and <code class="literal">template1</code> + databases, ensuring that those databases will retain the same properties + (for instance, locale and encoding) that they had in the source cluster. + Without the option, those databases will retain their existing + database-level properties, as well as any pre-existing contents. + </p><p> + Once restored, it is wise to run <code class="command">ANALYZE</code> on each + database so the optimizer has useful statistics. You + can also run <code class="command">vacuumdb -a -z</code> to analyze all + databases. + </p><p> + The dump script should not be expected to run completely without errors. + In particular, because the script will issue <code class="command">CREATE ROLE</code> + for every role existing in the source cluster, it is certain to get a + <span class="quote">“<span class="quote">role already exists</span>”</span> error for the bootstrap superuser, + unless the destination cluster was initialized with a different bootstrap + superuser name. This error is harmless and should be ignored. Use of + the <code class="option">--clean</code> option is likely to produce additional + harmless error messages about non-existent objects, although you can + minimize those by adding <code class="option">--if-exists</code>. + </p><p> + <span class="application">pg_dumpall</span> requires all needed + tablespace directories to exist before the restore; otherwise, + database creation will fail for databases in non-default + locations. + </p></div><div class="refsect1" id="APP-PG-DUMPALL-EX"><h2>Examples</h2><p> + To dump all databases: + +</p><pre class="screen"> +<code class="prompt">$</code> <strong class="userinput"><code>pg_dumpall > db.out</code></strong> +</pre><p> + </p><p> + To restore database(s) from this file, you can use: +</p><pre class="screen"> +<code class="prompt">$</code> <strong class="userinput"><code>psql -f db.out postgres</code></strong> +</pre><p> + It is not important to which database you connect here since the + script file created by <span class="application">pg_dumpall</span> will + contain the appropriate commands to create and connect to the saved + databases. An exception is that if you specified <code class="option">--clean</code>, + you must connect to the <code class="literal">postgres</code> database initially; + the script will attempt to drop other databases immediately, and that + will fail for the database you are connected to. + </p></div><div class="refsect1" id="id-1.9.4.14.10"><h2>See Also</h2><p> + Check <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle"><span class="application">pg_dump</span></span></a> for details on possible + error conditions. + </p></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="app-pgdump.html" title="pg_dump">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html" title="PostgreSQL Client Applications">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pg-isready.html" title="pg_isready">Next</a></td></tr><tr><td width="40%" align="left" valign="top"><span class="application">pg_dump</span> </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.2 Documentation">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_isready</span></td></tr></table></div></body></html>
\ No newline at end of file |