1 <REFENTRY ID="APP-PG-DUMP">
4 <application>pg_dump</application>
6 <REFMISCINFO>Application</REFMISCINFO>
10 <application>pg_dump</application>
13 Extract a <productname>Postgres</productname> database into a script file
17 <DATE>1998-10-04</DATE>
20 pg_dump [ <replaceable class="parameter">dbname</replaceable> ]
21 pg_dump [ -h <replaceable class="parameter">host</replaceable> ] [ -p <replaceable class="parameter">port</replaceable> ]
22 [ -t <replaceable class="parameter">table</replaceable> ]
23 [ -f <replaceable class="parameter">outputfile</replaceable> ]
24 [ -a ] [ -d ] [ -D ] [ -o ] [ -s ] [ -u ] [ -v ] [ -z ]
25 [ <replaceable class="parameter">dbname</replaceable> ]
28 <REFSECT2 ID="R2-APP-PG-DUMP-1">
30 <DATE>1998-10-04</DATE>
36 <application>pg_dump</application> accepts the following command line arguments:
41 <replaceable class="parameter">dbname</replaceable>
45 Specifies the name of the database to be extracted.
46 <replaceable class="parameter">dbname</replaceable>
47 defaults to the value of the
57 Dump out only the data, no schema (definitions).
65 Dump data as proper insert strings.
73 Dump data as inserts with attribute names
77 -f <replaceable class="parameter">filename</replaceable>
81 Specifies the output file. Defaults to <filename>stdout</filename>.
89 Suppress double quotes around identifiers unless absolutely necessary.
90 This may cause trouble loading this dumped data if there are reserved words
99 Dump object identifiers (<acronym>OID</acronym>s) for every table.
107 Dump out only the schema (definitions), no data.
111 -t <replaceable class="parameter">table</replaceable>
115 Dump data for <replaceable class="parameter">table</replaceable> only.
123 Use password authentication. Prompts for username and password.
131 Specifies verbose mode
139 Include ACLs (grant/revoke commands) and table ownership information.
144 <application>pg_dump</application> also accepts
145 the following command line arguments for connection parameters:
150 -h <replaceable class="parameter">host</replaceable>
154 Specifies the hostname of the machine on which the
155 <application>postmaster</application>
156 is running. Defaults to using a local Unix domain socket
157 rather than an IP connection..
161 -p <replaceable class="parameter">port</replaceable>
165 Specifies the Internet TCP/IP port or local Unix domain socket file
166 extension on which the <application>postmaster</application>
167 is listening for connections. The port number defaults to 5432,
168 or the value of the <envar>PGPORT</envar>
169 environment variable (if set).
177 Use password authentication.
179 <replaceable class="parameter">username</replaceable>
180 and <replaceable class="parameter">password</replaceable>.
184 <REFSECT2 ID="R2-APP-PG-DUMP-2">
186 <DATE>1998-10-04</DATE>
192 <application>pg_dump</application> will create a file or
193 write to <filename>stdout</filename>.
198 Connection to database 'template1' failed.
199 connectDB() failed: Is the postmaster running and accepting connections
200 at 'UNIX Socket' on port '<replaceable class="parameter">port</replaceable>'?
203 <application>pg_dump</application> could not attach to the
204 <application>postmaster</application>
205 process on the specified host and port. If you see this message,
206 ensure that the <application>postmaster</application>
207 is running on the proper host and that you have specified the proper
208 port. If your site uses an authentication system, ensure that you
209 have obtained the required authentication credentials.
213 Connection to database '<replaceable class="parameter">dbname</replaceable>' failed.
214 FATAL 1: SetUserId: user '<replaceable class="parameter">username</replaceable>' is not in 'pg_shadow'
217 You do not have a valid entry in the relation <literal>pg_shadow</literal>
218 and and will not be allowed to access <productname>Postgres</productname>.
219 Contact your <productname>Postgres</productname> administrator.
223 dumpSequence(<replaceable class="parameter">table</replaceable>): SELECT failed
226 You do not have permission to read the database.
227 Contact your <productname>Postgres</productname> site administrator.
233 <application>pg_dump</application> internally executes
234 <command>SELECT</command> statements. If you have problems running
235 <application>pg_dump</application>,
236 make sure you are able to select information from the database using, for
237 example, <application>psql</application>.
240 <REFSECT1 ID="R1-APP-PG-DUMP-1">
242 <DATE>1998-10-04</DATE>
248 <application>pg_dump</application> is a utility for dumping out a
249 <productname>Postgres</productname> database into a script file
250 containing query commands. The script
251 files are in text format and can be used to reconstruct the database,
252 even on other machines and other architectures.
253 <application>pg_dump</application>
254 will produce the queries necessary to re-generate all
255 user-defined types, functions, tables, indices, aggregates, and
256 operators. In addition, all the data is copied out in text format so
257 that it can be readily copied in again, as well as imported into tools
261 <application>pg_dump</application>
262 is useful for dumping out the contents of a database to move from one
263 <productname>Postgres</productname> installation to another. After running
264 <application>pg_dump</application>,
265 one should examine the output script file for any warnings, especially
266 in light of the limitations listed below.
268 <REFSECT1 ID="R1-APP-PG-DUMP-2">
270 <DATE>1998-10-04</DATE>
276 <application>pg_dump</application> has a few limitations.
277 The limitations mostly stem from
278 difficulty in extracting certain meta-information from the system
287 <application>pg_dump</application>
288 does not understand user-defined rules and views and
289 will fail to dump them properly. (This is due to the fact that
290 rules are stored as plans in the catalogs and not textually).
297 <application>pg_dump</application>
298 does not understand partial indices. The reason is
299 the same as above; partial index predicates are stored as plans.
306 <application>pg_dump</application> does not handle large objects.
307 Large objects are ignored and must be dealt with manually.
311 <REFSECT1 ID="R1-APP-PG-DUMP-3">
313 <DATE>1998-10-04</DATE>
319 To dump a database of the same name as the user:
326 To reload this database:
329 psql -e database < db.out