gooderp18绿色标准版
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

350 lines
30KB

  1. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
  2. <!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 V1.79.1" /><link rel="prev" href="app-pgdump.html" title="pg_dump" /><link rel="next" href="app-pg-isready.html" title="pg_isready" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center"><span xmlns="http://www.w3.org/1999/xhtml" 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 12.4 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></hr></div><div class="refentry" id="APP-PG-DUMPALL"><div class="titlepage"></div><a id="id-1.9.4.13.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.13.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>
  3. <span class="application">pg_dumpall</span> is a utility for writing out
  4. (<span class="quote">“<span class="quote">dumping</span>”</span>) all <span class="productname">PostgreSQL</span> databases
  5. of a cluster into one script file. The script file contains
  6. <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
  7. calling <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle">pg_dump</span></a> for each database in the cluster.
  8. <span class="application">pg_dumpall</span> also dumps global objects
  9. that are common to all databases, that is, database roles and tablespaces.
  10. (<span class="application">pg_dump</span> does not save these objects.)
  11. </p><p>
  12. Since <span class="application">pg_dumpall</span> reads tables from all
  13. databases you will most likely have to connect as a database
  14. superuser in order to produce a complete dump. Also you will need
  15. superuser privileges to execute the saved script in order to be
  16. allowed to add roles and create databases.
  17. </p><p>
  18. The SQL script will be written to the standard output. Use the
  19. <code class="option">-f</code>/<code class="option">--file</code> option or shell operators to
  20. redirect it into a file.
  21. </p><p>
  22. <span class="application">pg_dumpall</span> needs to connect several
  23. times to the <span class="productname">PostgreSQL</span> server (once per
  24. database). If you use password authentication it will ask for
  25. a password each time. It is convenient to have a
  26. <code class="filename">~/.pgpass</code> file in such cases. See <a class="xref" href="libpq-pgpass.html" title="33.15. The Password File">Section 33.15</a> for more information.
  27. </p></div><div class="refsect1" id="id-1.9.4.13.6"><h2>Options</h2><p>
  28. The following command-line options control the content and
  29. format of the output.
  30. </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>
  31. Dump only the data, not the schema (data definitions).
  32. </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>
  33. Include SQL commands to clean (drop) databases before
  34. recreating them. <code class="command">DROP</code> commands for roles and
  35. tablespaces are added as well.
  36. </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>
  37. Create the dump in the specified character set encoding. By default,
  38. the dump is created in the database encoding. (Another way to get the
  39. same result is to set the <code class="envar">PGCLIENTENCODING</code> environment
  40. variable to the desired dump encoding.)
  41. </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>
  42. Send output to the specified file. If this is omitted, the
  43. standard output is used.
  44. </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>
  45. Dump only global objects (roles and tablespaces), no databases.
  46. </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>
  47. Do not output commands to set
  48. ownership of objects to match the original database.
  49. By default, <span class="application">pg_dumpall</span> issues
  50. <code class="command">ALTER OWNER</code> or
  51. <code class="command">SET SESSION AUTHORIZATION</code>
  52. statements to set ownership of created schema elements.
  53. These statements
  54. will fail when the script is run unless it is started by a superuser
  55. (or the same user that owns all of the objects in the script).
  56. To make a script that can be restored by any user, but will give
  57. that user ownership of all the objects, specify <code class="option">-O</code>.
  58. </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>
  59. Dump only roles, no databases or tablespaces.
  60. </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>
  61. Dump only the object definitions (schema), not data.
  62. </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>
  63. Specify the superuser user name to use when disabling triggers.
  64. This is relevant only if <code class="option">--disable-triggers</code> is used.
  65. (Usually, it's better to leave this out, and instead start the
  66. resulting script as superuser.)
  67. </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>
  68. Dump only tablespaces, no databases or roles.
  69. </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>
  70. Specifies verbose mode. This will cause
  71. <span class="application">pg_dumpall</span> to output start/stop
  72. times to the dump file, and progress messages to standard error.
  73. It will also enable verbose output in <span class="application">pg_dump</span>.
  74. </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>
  75. Print the <span class="application">pg_dumpall</span> version and exit.
  76. </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>
  77. Prevent dumping of access privileges (grant/revoke commands).
  78. </p></dd><dt><span class="term"><code class="option">--binary-upgrade</code></span></dt><dd><p>
  79. This option is for use by in-place upgrade utilities. Its use
  80. for other purposes is not recommended or supported. The
  81. behavior of the option may change in future releases without
  82. notice.
  83. </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>
  84. Dump data as <code class="command">INSERT</code> commands with explicit
  85. column names (<code class="literal">INSERT INTO
  86. <em class="replaceable"><code>table</code></em>
  87. (<em class="replaceable"><code>column</code></em>, ...) VALUES
  88. ...</code>). This will make restoration very slow; it is mainly
  89. useful for making dumps that can be loaded into
  90. non-<span class="productname">PostgreSQL</span> databases.
  91. </p></dd><dt><span class="term"><code class="option">--disable-dollar-quoting</code></span></dt><dd><p>
  92. This option disables the use of dollar quoting for function bodies,
  93. and forces them to be quoted using SQL standard string syntax.
  94. </p></dd><dt><span class="term"><code class="option">--disable-triggers</code></span></dt><dd><p>
  95. This option is relevant only when creating a data-only dump.
  96. It instructs <span class="application">pg_dumpall</span> to include commands
  97. to temporarily disable triggers on the target tables while
  98. the data is reloaded. Use this if you have referential
  99. integrity checks or other triggers on the tables that you
  100. do not want to invoke during data reload.
  101. </p><p>
  102. Presently, the commands emitted for <code class="option">--disable-triggers</code>
  103. must be done as superuser. So, you should also specify
  104. a superuser name with <code class="option">-S</code>, or preferably be careful to
  105. start the resulting script as a superuser.
  106. </p></dd><dt><span class="term"><code class="option">--extra-float-digits=<em class="replaceable"><code>ndigits</code></em></code></span></dt><dd><p>
  107. Use the specified value of extra_float_digits when dumping
  108. floating-point data, instead of the maximum available precision.
  109. Routine dumps made for backup purposes should not use this option.
  110. </p></dd><dt><span class="term"><code class="option">--exclude-database=<em class="replaceable"><code>pattern</code></em></code></span></dt><dd><p>
  111. Do not dump databases whose name matches
  112. <em class="replaceable"><code>pattern</code></em>.
  113. Multiple patterns can be excluded by writing multiple
  114. <code class="option">--exclude-database</code> switches. The
  115. <em class="replaceable"><code>pattern</code></em> parameter is
  116. interpreted as a pattern according to the same rules used by
  117. <span class="application">psql</span>'s <code class="literal">\d</code>
  118. commands (see <a class="xref" href="app-psql.html#APP-PSQL-PATTERNS" title="Patterns">Patterns</a>),
  119. so multiple databases can also be excluded by writing wildcard
  120. characters in the pattern. When using wildcards, be careful to
  121. quote the pattern if needed to prevent shell wildcard expansion.
  122. </p></dd><dt><span class="term"><code class="option">--if-exists</code></span></dt><dd><p>
  123. Use conditional commands (i.e. add an <code class="literal">IF EXISTS</code>
  124. clause) to drop databases and other objects. This option is not valid
  125. unless <code class="option">--clean</code> is also specified.
  126. </p></dd><dt><span class="term"><code class="option">--inserts</code></span></dt><dd><p>
  127. Dump data as <code class="command">INSERT</code> commands (rather
  128. than <code class="command">COPY</code>). This will make restoration very slow;
  129. it is mainly useful for making dumps that can be loaded into
  130. non-<span class="productname">PostgreSQL</span> databases. Note that
  131. the restore might fail altogether if you have rearranged column order.
  132. The <code class="option">--column-inserts</code> option is safer, though even
  133. slower.
  134. </p></dd><dt><span class="term"><code class="option">--load-via-partition-root</code></span></dt><dd><p>
  135. When dumping data for a table partition, make
  136. the <code class="command">COPY</code> or <code class="command">INSERT</code> statements
  137. target the root of the partitioning hierarchy that contains it, rather
  138. than the partition itself. This causes the appropriate partition to
  139. be re-determined for each row when the data is loaded. This may be
  140. useful when reloading data on a server where rows do not always fall
  141. into the same partitions as they did on the original server. That
  142. could happen, for example, if the partitioning column is of type text
  143. and the two systems have different definitions of the collation used
  144. to sort the partitioning column.
  145. </p></dd><dt><span class="term"><code class="option">--lock-wait-timeout=<em class="replaceable"><code>timeout</code></em></code></span></dt><dd><p>
  146. Do not wait forever to acquire shared table locks at the beginning of
  147. the dump. Instead, fail if unable to lock a table within the specified
  148. <em class="replaceable"><code>timeout</code></em>. The timeout may be
  149. specified in any of the formats accepted by <code class="command">SET
  150. statement_timeout</code>. Allowed values vary depending on the server
  151. version you are dumping from, but an integer number of milliseconds
  152. is accepted by all versions since 7.3. This option is ignored when
  153. dumping from a pre-7.3 server.
  154. </p></dd><dt><span class="term"><code class="option">--no-comments</code></span></dt><dd><p>
  155. Do not dump comments.
  156. </p></dd><dt><span class="term"><code class="option">--no-publications</code></span></dt><dd><p>
  157. Do not dump publications.
  158. </p></dd><dt><span class="term"><code class="option">--no-role-passwords</code></span></dt><dd><p>
  159. Do not dump passwords for roles. When restored, roles will have a
  160. null password, and password authentication will always fail until the
  161. password is set. Since password values aren't needed when this option
  162. is specified, the role information is read from the catalog
  163. view <code class="structname">pg_roles</code> instead
  164. of <code class="structname">pg_authid</code>. Therefore, this option also
  165. helps if access to <code class="structname">pg_authid</code> is restricted by
  166. some security policy.
  167. </p></dd><dt><span class="term"><code class="option">--no-security-labels</code></span></dt><dd><p>
  168. Do not dump security labels.
  169. </p></dd><dt><span class="term"><code class="option">--no-subscriptions</code></span></dt><dd><p>
  170. Do not dump subscriptions.
  171. </p></dd><dt><span class="term"><code class="option">--no-sync</code></span></dt><dd><p>
  172. By default, <code class="command">pg_dumpall</code> will wait for all files
  173. to be written safely to disk. This option causes
  174. <code class="command">pg_dumpall</code> to return without waiting, which is
  175. faster, but means that a subsequent operating system crash can leave
  176. the dump corrupt. Generally, this option is useful for testing
  177. but should not be used when dumping data from production installation.
  178. </p></dd><dt><span class="term"><code class="option">--no-tablespaces</code></span></dt><dd><p>
  179. Do not output commands to create tablespaces nor select tablespaces
  180. for objects.
  181. With this option, all objects will be created in whichever
  182. tablespace is the default during restore.
  183. </p></dd><dt><span class="term"><code class="option">--no-unlogged-table-data</code></span></dt><dd><p>
  184. Do not dump the contents of unlogged tables. This option has no
  185. effect on whether or not the table definitions (schema) are dumped;
  186. it only suppresses dumping the table data.
  187. </p></dd><dt><span class="term"><code class="option">--on-conflict-do-nothing</code></span></dt><dd><p>
  188. Add <code class="literal">ON CONFLICT DO NOTHING</code> to
  189. <code class="command">INSERT</code> commands.
  190. This option is not valid unless <code class="option">--inserts</code> or
  191. <code class="option">--column-inserts</code> is also specified.
  192. </p></dd><dt><span class="term"><code class="option">--quote-all-identifiers</code></span></dt><dd><p>
  193. Force quoting of all identifiers. This option is recommended when
  194. dumping a database from a server whose <span class="productname">PostgreSQL</span>
  195. major version is different from <span class="application">pg_dumpall</span>'s, or when
  196. the output is intended to be loaded into a server of a different
  197. major version. By default, <span class="application">pg_dumpall</span> quotes only
  198. identifiers that are reserved words in its own major version.
  199. This sometimes results in compatibility issues when dealing with
  200. servers of other versions that may have slightly different sets
  201. of reserved words. Using <code class="option">--quote-all-identifiers</code> prevents
  202. such issues, at the price of a harder-to-read dump script.
  203. </p></dd><dt><span class="term"><code class="option">--rows-per-insert=<em class="replaceable"><code>nrows</code></em></code></span></dt><dd><p>
  204. Dump data as <code class="command">INSERT</code> commands (rather than
  205. <code class="command">COPY</code>). Controls the maximum number of rows per
  206. <code class="command">INSERT</code> command. The value specified must be a
  207. number greater than zero. Any error during reloading will cause only
  208. rows that are part of the problematic <code class="command">INSERT</code> to be
  209. lost, rather than the entire table contents.
  210. </p></dd><dt><span class="term"><code class="option">--use-set-session-authorization</code></span></dt><dd><p>
  211. Output SQL-standard <code class="command">SET SESSION AUTHORIZATION</code> commands
  212. instead of <code class="command">ALTER OWNER</code> commands to determine object
  213. ownership. This makes the dump more standards compatible, but
  214. depending on the history of the objects in the dump, might not restore
  215. properly.
  216. </p></dd><dt><span class="term"><code class="option">-?</code><br /></span><span class="term"><code class="option">--help</code></span></dt><dd><p>
  217. Show help about <span class="application">pg_dumpall</span> command line
  218. arguments, and exit.
  219. </p></dd></dl></div><p>
  220. </p><p>
  221. The following command-line options control the database connection parameters.
  222. </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>
  223. Specifies parameters used to connect to the server, as a connection
  224. string. See <a class="xref" href="libpq-connect.html#LIBPQ-CONNSTRING" title="33.1.1. Connection Strings">Section 33.1.1</a> for more information.
  225. </p><p>
  226. The option is called <code class="literal">--dbname</code> for consistency with other
  227. client applications, but because <span class="application">pg_dumpall</span>
  228. needs to connect to many databases, the database name in the
  229. connection string will be ignored. Use the <code class="literal">-l</code>
  230. option to specify the name of the database used for the initial
  231. connection, which will dump global objects and discover what other
  232. databases should be dumped.
  233. </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>
  234. Specifies the host name of the machine on which the database
  235. server is running. If the value begins with a slash, it is
  236. used as the directory for the Unix domain socket. The default
  237. is taken from the <code class="envar">PGHOST</code> environment variable,
  238. if set, else a Unix domain socket connection is attempted.
  239. </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>
  240. Specifies the name of the database to connect to for dumping global
  241. objects and discovering what other databases should be dumped. If
  242. not specified, the <code class="literal">postgres</code> database will be used,
  243. and if that does not exist, <code class="literal">template1</code> will be used.
  244. </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>
  245. Specifies the TCP port or local Unix domain socket file
  246. extension on which the server is listening for connections.
  247. Defaults to the <code class="envar">PGPORT</code> environment variable, if
  248. set, or a compiled-in default.
  249. </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>
  250. User name to connect as.
  251. </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>
  252. Never issue a password prompt. If the server requires
  253. password authentication and a password is not available by
  254. other means such as a <code class="filename">.pgpass</code> file, the
  255. connection attempt will fail. This option can be useful in
  256. batch jobs and scripts where no user is present to enter a
  257. password.
  258. </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>
  259. Force <span class="application">pg_dumpall</span> to prompt for a
  260. password before connecting to a database.
  261. </p><p>
  262. This option is never essential, since
  263. <span class="application">pg_dumpall</span> will automatically prompt
  264. for a password if the server demands password authentication.
  265. However, <span class="application">pg_dumpall</span> will waste a
  266. connection attempt finding out that the server wants a password.
  267. In some cases it is worth typing <code class="option">-W</code> to avoid the extra
  268. connection attempt.
  269. </p><p>
  270. Note that the password prompt will occur again for each database
  271. to be dumped. Usually, it's better to set up a
  272. <code class="filename">~/.pgpass</code> file than to rely on manual password entry.
  273. </p></dd><dt><span class="term"><code class="option">--role=<em class="replaceable"><code>rolename</code></em></code></span></dt><dd><p>
  274. Specifies a role name to be used to create the dump.
  275. This option causes <span class="application">pg_dumpall</span> to issue a
  276. <code class="command">SET ROLE</code> <em class="replaceable"><code>rolename</code></em>
  277. command after connecting to the database. It is useful when the
  278. authenticated user (specified by <code class="option">-U</code>) lacks privileges
  279. needed by <span class="application">pg_dumpall</span>, but can switch to a role with
  280. the required rights. Some installations have a policy against
  281. logging in directly as a superuser, and use of this option allows
  282. dumps to be made without violating the policy.
  283. </p></dd></dl></div><p>
  284. </p></div><div class="refsect1" id="id-1.9.4.13.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>
  285. Default connection parameters
  286. </p></dd><dt><span class="term"><code class="envar">PG_COLOR</code></span></dt><dd><p>
  287. Specifies whether to use color in diagnostic messages. Possible values
  288. are <code class="literal">always</code>, <code class="literal">auto</code> and
  289. <code class="literal">never</code>.
  290. </p></dd></dl></div><p>
  291. This utility, like most other <span class="productname">PostgreSQL</span> utilities,
  292. also uses the environment variables supported by <span class="application">libpq</span>
  293. (see <a class="xref" href="libpq-envars.html" title="33.14. Environment Variables">Section 33.14</a>).
  294. </p></div><div class="refsect1" id="id-1.9.4.13.8"><h2>Notes</h2><p>
  295. Since <span class="application">pg_dumpall</span> calls
  296. <span class="application">pg_dump</span> internally, some diagnostic
  297. messages will refer to <span class="application">pg_dump</span>.
  298. </p><p>
  299. The <code class="option">--clean</code> option can be useful even when your
  300. intention is to restore the dump script into a fresh cluster. Use of
  301. <code class="option">--clean</code> authorizes the script to drop and re-create the
  302. built-in <code class="literal">postgres</code> and <code class="literal">template1</code>
  303. databases, ensuring that those databases will retain the same properties
  304. (for instance, locale and encoding) that they had in the source cluster.
  305. Without the option, those databases will retain their existing
  306. database-level properties, as well as any pre-existing contents.
  307. </p><p>
  308. Once restored, it is wise to run <code class="command">ANALYZE</code> on each
  309. database so the optimizer has useful statistics. You
  310. can also run <code class="command">vacuumdb -a -z</code> to analyze all
  311. databases.
  312. </p><p>
  313. The dump script should not be expected to run completely without errors.
  314. In particular, because the script will issue <code class="command">CREATE ROLE</code>
  315. for every role existing in the source cluster, it is certain to get a
  316. <span class="quote">“<span class="quote">role already exists</span>”</span> error for the bootstrap superuser,
  317. unless the destination cluster was initialized with a different bootstrap
  318. superuser name. This error is harmless and should be ignored. Use of
  319. the <code class="option">--clean</code> option is likely to produce additional
  320. harmless error messages about non-existent objects, although you can
  321. minimize those by adding <code class="option">--if-exists</code>.
  322. </p><p>
  323. <span class="application">pg_dumpall</span> requires all needed
  324. tablespace directories to exist before the restore; otherwise,
  325. database creation will fail for databases in non-default
  326. locations.
  327. </p></div><div class="refsect1" id="APP-PG-DUMPALL-EX"><h2>Examples</h2><p>
  328. To dump all databases:
  329. </p><pre class="screen">
  330. <code class="prompt">$</code> <strong class="userinput"><code>pg_dumpall &gt; db.out</code></strong>
  331. </pre><p>
  332. </p><p>
  333. To reload database(s) from this file, you can use:
  334. </p><pre class="screen">
  335. <code class="prompt">$</code> <strong class="userinput"><code>psql -f db.out postgres</code></strong>
  336. </pre><p>
  337. It is not important to which database you connect here since the
  338. script file created by <span class="application">pg_dumpall</span> will
  339. contain the appropriate commands to create and connect to the saved
  340. databases. An exception is that if you specified <code class="option">--clean</code>,
  341. you must connect to the <code class="literal">postgres</code> database initially;
  342. the script will attempt to drop other databases immediately, and that
  343. will fail for the database you are connected to.
  344. </p></div><div class="refsect1" id="id-1.9.4.13.10"><h2>See Also</h2><p>
  345. Check <a class="xref" href="app-pgdump.html" title="pg_dump"><span class="refentrytitle">pg_dump</span></a> for details on possible
  346. error conditions.
  347. </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">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="reference-client.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="app-pg-isready.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">pg_dump </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> <span class="application">pg_isready</span></td></tr></table></div></body></html>
上海开阖软件有限公司 沪ICP备12045867号-1