1PG_DUMPALL(1)           PostgreSQL Client Applications           PG_DUMPALL(1)
2
3
4

NAME

6       pg_dumpall - extract a PostgreSQL database cluster into a script file
7
8

SYNOPSIS

10       pg_dumpall [ option... ]
11

DESCRIPTION

13       pg_dumpall  is  a  utility for writing out (``dumping'') all PostgreSQL
14       databases of a cluster into one script file. The script  file  contains
15       SQL  commands that can be used as input to psql(1) to restore the data‐
16       bases. It does this by calling pg_dump(1) for each database in a  clus‐
17       ter.  pg_dumpall also dumps global objects that are common to all data‐
18       bases.  (pg_dump does not save these objects.)  This currently includes
19       information  about  database users and groups, tablespaces, and proper‐
20       ties such as access permissions that apply to databases as a whole.
21
22       Since pg_dumpall reads tables from all databases you will  most  likely
23       have  to connect as a database superuser in order to produce a complete
24       dump. Also you will need superuser  privileges  to  execute  the  saved
25       script  in  order  to be allowed to add users and groups, and to create
26       databases.
27
28       The SQL script will be written to the standard output. Shell  operators
29       should be used to redirect it into a file.
30
31       pg_dumpall  needs  to  connect  several  times to the PostgreSQL server
32       (once per database). If you use password authentication it will ask for
33       a password each time. It is convenient to have a ~/.pgpass file in such
34       cases. See in the documentation for more information.
35

OPTIONS

37       The following command-line options control the content  and  format  of
38       the output.
39
40       -a
41
42       --data-only
43              Dump only the data, not the schema (data definitions).
44
45       -c
46
47       --clean
48              Include SQL commands to clean (drop) databases before recreating
49              them. DROP commands for roles and tablespaces are added as well.
50
51       -f filename
52
53       --file=filename
54              Send output to the specified file. If this is omitted, the stan‐
55              dard output is used.
56
57       -g
58
59       --globals-only
60              Dump only global objects (roles and tablespaces), no databases.
61
62       -i
63
64       --ignore-version
65              A deprecated option that is now ignored.
66
67       -o
68
69       --oids Dump object identifiers (OIDs) as part of the data for every ta‐
70              ble. Use this option if your application references the OID col‐
71              umns  in  some  way (e.g., in a foreign key constraint).  Other‐
72              wise, this option should not be used.
73
74       -O
75
76       --no-owner
77              Do not output commands to set ownership of objects to match  the
78              original database.  By default, pg_dumpall issues ALTER OWNER or
79              SET SESSION AUTHORIZATION statements to set ownership of created
80              schema  elements.  These statements will fail when the script is
81              run unless it is started by a superuser (or the same  user  that
82              owns  all  of the objects in the script).  To make a script that
83              can be restored by any user, but will give that  user  ownership
84              of all the objects, specify -O.
85
86       --lock-wait-timeout=timeout
87              Do  not wait forever to acquire shared table locks at the begin‐
88              ning of the dump. Instead fail if unable to lock a table  within
89              the  specified  timeout.  The timeout may be specified in any of
90              the formats accepted by SET statement_timeout.  (Allowed  values
91              vary  depending  on the server version you are dumping from, but
92              an integer number of milliseconds is accepted  by  all  versions
93              since  7.3.  This  option is ignored when dumping from a pre-7.3
94              server.)
95
96       --no-tablespaces
97              Do  not  output  commands  to  create  tablespaces  nor   select
98              tablespaces  for objects.  With this option, all objects will be
99              created in whichever tablespace is the default during restore.
100
101       -r
102
103       --roles-only
104              Dump only roles, no databases or tablespaces.
105
106       -s
107
108       --schema-only
109              Dump only the object definitions (schema), not data.
110
111       -S username
112
113       --superuser=username
114              Specify the superuser user name to use when disabling  triggers.
115              This  is only relevant if --disable-triggers is used.  (Usually,
116              it's better to leave this out, and instead start  the  resulting
117              script as superuser.)
118
119       -t
120
121       --tablespaces-only
122              Dump only tablespaces, no databases or roles.
123
124       -v
125
126       --verbose
127              Specifies  verbose  mode.  This  will cause pg_dumpall to output
128              start/stop times to the dump  file,  and  progress  messages  to
129              standard error.  It will also enable verbose output in pg_dump.
130
131       -x
132
133       --no-privileges
134
135       --no-acl
136              Prevent dumping of access privileges (grant/revoke commands).
137
138       --binary-upgrade
139              This  option  is  for use by in-place upgrade utilities. Its use
140              for other purposes is not recommended or supported. The behavior
141              of the option may change in future releases without notice.
142
143       --inserts
144              Dump  data as INSERT commands (rather than COPY). This will make
145              restoration very slow; it is mainly useful for making dumps that
146              can  be  loaded  into  non-PostgreSQL  databases.  Note that the
147              restore might fail altogether  if  you  have  rearranged  column
148              order.   The  --column-inserts  option  is  safer,  though  even
149              slower.
150
151       --column-inserts
152
153       --attribute-inserts
154              Dump data as INSERT commands with explicit column names  (INSERT
155              INTO table (column, ...) VALUES ...). This will make restoration
156              very slow; it is mainly useful for  making  dumps  that  can  be
157              loaded into non-PostgreSQL databases.
158
159       --disable-dollar-quoting
160              This option disables the use of dollar quoting for function bod‐
161              ies, and forces them to be quoted using SQL standard string syn‐
162              tax.
163
164       --disable-triggers
165              This option is only relevant when creating a data-only dump.  It
166              instructs pg_dumpall to include commands to temporarily  disable
167              triggers  on  the  target tables while the data is reloaded. Use
168              this if you have referential integrity checks or other  triggers
169              on the tables that you do not want to invoke during data reload.
170
171              Presently,  the  commands emitted for --disable-triggers must be
172              done as superuser. So, you should also specify a superuser  name
173              with  -S, or preferably be careful to start the resulting script
174              as a superuser.
175
176       --use-set-session-authorization
177              Output SQL-standard SET SESSION AUTHORIZATION  commands  instead
178              of  ALTER  OWNER  commands  to  determine object ownership. This
179              makes the dump more standards compatible, but depending  on  the
180              history of the objects in the dump, might not restore properly.
181
182       The  following  command-line  options  control  the database connection
183       parameters.
184
185       -h host
186
187       --host=host
188              Specifies the host name of the machine  on  which  the  database
189              server  is running. If the value begins with a slash, it is used
190              as the directory for the Unix  domain  socket.  The  default  is
191              taken  from the PGHOST environment variable, if set, else a Unix
192              domain socket connection is attempted.
193
194       -l dbname
195
196       --database=dbname
197              Specifies the name of the database to connect to to dump  global
198              objects  and  discover what other databases should be dumped. If
199              not specified, the ``postgres'' database will be  used,  and  if
200              that does not exist, ``template1'' will be used.
201
202       -p port
203
204       --port=port
205              Specifies  the  TCP port or local Unix domain socket file exten‐
206              sion on which the server is listening for connections.  Defaults
207              to  the  PGPORT  environment  variable, if set, or a compiled-in
208              default.
209
210       -U username
211
212       --username=username
213              User name to connect as.
214
215       -w
216
217       --no-password
218              Never issue a password prompt. If the server  requires  password
219              authentication  and  a  password is not available by other means
220              such as a .pgpass file, the connection attempt will  fail.  This
221              option  can be useful in batch jobs and scripts where no user is
222              present to enter a password.
223
224       -W
225
226       --password
227              Force pg_dumpall to prompt for a password before connecting to a
228              database.
229
230              This  option is never essential, since pg_dumpall will automati‐
231              cally prompt for a  password  if  the  server  demands  password
232              authentication.   However,  pg_dumpall  will  waste a connection
233              attempt finding out that the server wants a password.   In  some
234              cases  it  is  worth  typing  -W  to  avoid the extra connection
235              attempt.
236
237              Note that the password prompt will occur again for each database
238              to  be  dumped.  Usually, it's better to set up a ~/.pgpass file
239              than to rely on manual password entry.
240
241       --role=rolename
242              Specifies a role name to be  used  to  create  the  dump.   This
243              option  causes  pg_dumpall  to issue a SET ROLE rolename command
244              after connecting to the database. It is useful when the  authen‐
245              ticated  user  (specified  by  -U)  lacks  privileges  needed by
246              pg_dumpall, but can switch to a role with the  required  rights.
247              Some  installations have a policy against logging in directly as
248              a superuser, and use of this option  allows  dumps  to  be  made
249              without violating the policy.
250

ENVIRONMENT

252       PGHOST
253
254       PGOPTIONS
255
256       PGPORT
257
258       PGUSER Default connection parameters
259
260       This utility, like most other PostgreSQL utilities, also uses the envi‐
261       ronment variables supported by libpq (see in the documentation).
262

NOTES

264       Since pg_dumpall calls pg_dump  internally,  some  diagnostic  messages
265       will refer to pg_dump.
266
267       Once  restored, it is wise to run ANALYZE on each database so the opti‐
268       mizer has useful statistics. You can also run vacuumdb -a -z to analyze
269       all databases.
270
271       pg_dumpall  requires  all needed tablespace directories to exist before
272       the restore, else database creation will fail  for  databases  in  non-
273       default locations.
274

EXAMPLES

276       To dump all databases:
277
278       $ pg_dumpall > db.out
279
280
281       To reload this database use, for example:
282
283       $ psql -f db.out postgres
284
285       (It  is  not  important  to  which  database you connect here since the
286       script file created by pg_dumpall will contain the appropriate commands
287       to create and connect to the saved databases.)
288

SEE ALSO

290       Check pg_dump(1) for details on possible error conditions.
291
292
293
294Application                       2011-09-22                     PG_DUMPALL(1)
Impressum