📄 pg_dumpall.1
字号:
.\\" auto-generated by docbook2man-spec $Revision: 1.1.1.1 $.TH "PG_DUMPALL" "1" "2008-01-03" "Application" "PostgreSQL Client Applications".SH NAMEpg_dumpall \- extract a PostgreSQL database cluster into a script file.SH SYNOPSIS.sp\fBpg_dumpall\fR [ \fB\fIoption\fB\fR\fI...\fR ] .SH "DESCRIPTION".PP\fBpg_dumpall\fR is a utility for writing out(``dumping'') all PostgreSQL databasesof a cluster into one script file. The script file containsSQL commands that can be used as input to \fBpsql\fR(1) to restore the databases. It does this bycalling \fBpg_dump\fR(1) for each database in a cluster.\fBpg_dumpall\fR also dumps global objectsthat are common to all databases.(\fBpg_dump\fR does not save these objects.)This currently includes information about database users andgroups, and access permissions that apply to databases as a whole..PPSince \fBpg_dumpall\fR reads tables from alldatabases you will most likely have to connect as a databasesuperuser in order to produce a complete dump. Also you will needsuperuser privileges to execute the saved script in order to beallowed to add users and groups, and to create databases..PPThe SQL script will be written to the standard output. Shelloperators should be used to redirect it into a file..PP\fBpg_dumpall\fR needs to connect severaltimes to the PostgreSQL server (once perdatabase). If you use password authentication it is likely to ask fora password each time. It is convenient to have a\fI~/.pgpass\fR file in such cases. See in the documentation for more information..SH "OPTIONS".PPThe following command-line options control the content andformat of the output..TP\fB-a\fR.TP\fB--data-only\fRDump only the data, not the schema (data definitions)..TP\fB-c\fR.TP\fB--clean\fRInclude SQL commands to clean (drop) databases beforerecreating them. \fBDROP\fR commands for roles andtablespaces are added as well..TP\fB-d\fR.TP\fB--inserts\fRDump data as \fBINSERT\fR commands (ratherthan \fBCOPY\fR). This will make restoration very slow;it is mainly useful for making dumps that can be loaded intonon-PostgreSQL databases. Note thatthe restore may fail altogether if you have rearranged column order.The \fB-D\fR option is safer, though even slower..TP\fB-D\fR.TP\fB--column-inserts\fR.TP\fB--attribute-inserts\fRDump data as \fBINSERT\fR commands with explicitcolumn names (INSERT INTO\fItable\fR(\fIcolumn\fR, ...) VALUES\&...). This will make restoration very slow; it is mainlyuseful for making dumps that can be loaded intonon-PostgreSQL databases..TP\fB-g\fR.TP\fB--globals-only\fRDump only global objects (roles and tablespaces), no databases..TP\fB-i\fR.TP\fB--ignore-version\fRIgnore version mismatch between\fBpg_dumpall\fR and the database server.\fBpg_dumpall\fR can handle databasesfrom previous releases of PostgreSQL, but veryold versions are not supported anymore (currently prior to7.0). Use this option if you need to override the versioncheck (and if \fBpg_dumpall\fR thenfails, don't say you weren't warned)..TP\fB-o\fR.TP\fB--oids\fRDump object identifiers (OIDs) as part of thedata for every table. Use this option if your application referencesthe OIDcolumns in some way (e.g., in a foreign key constraint).Otherwise, this option should not be used..TP\fB-O\fR.TP\fB--no-owner\fRDo not output commands to setownership of objects to match the original database.By default, \fBpg_dumpall\fR issues\fBALTER OWNER\fR or \fBSET SESSION AUTHORIZATION\fRstatements to set ownership of created schema elements.These statementswill 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 givethat user ownership of all the objects, specify \fB-O\fR..TP\fB-s\fR.TP\fB--schema-only\fRDump only the object definitions (schema), not data..TP\fB-S \fIusername\fB\fR.TP\fB--superuser=\fIusername\fB\fRSpecify the superuser user name to use when disabling triggers.This is only relevant if \fB--disable-triggers\fR is used.(Usually, it's better to leave this out, and instead start theresulting script as superuser.).TP\fB-v\fR.TP\fB--verbose\fRSpecifies verbose mode. This will cause\fBpg_dumpall\fR to output start/stoptimes to the dump file, and progress messages to standard error.It will also enable verbose output in \fBpg_dump\fR..TP\fB-x\fR.TP\fB--no-privileges\fR.TP\fB--no-acl\fRPrevent dumping of access privileges (grant/revoke commands)..TP\fB--disable-dollar-quoting\fRThis option disables the use of dollar quoting for function bodies,and forces them to be quoted using SQL standard string syntax..TP\fB--disable-triggers\fRThis option is only relevant when creating a data-only dump.It instructs \fBpg_dumpall\fR to include commandsto temporarily disable triggers on the target tables whilethe data is reloaded. Use this if you have referentialintegrity checks or other triggers on the tables that youdo not want to invoke during data reload.Presently, the commands emitted for \fB--disable-triggers\fRmust be done as superuser. So, you should also specifya superuser name with \fB-S\fR, or preferably be careful tostart the resulting script as a superuser..TP\fB--use-set-session-authorization\fROutput SQL-standard \fBSET SESSION AUTHORIZATION\fR commandsinstead of \fBALTER OWNER\fR commands to determine objectownership. This makes the dump more standards compatible, butdepending on the history of the objects in the dump, may not restoreproperly..PP.PPThe following command-line options control the database connection parameters..TP\fB-h \fIhost\fB\fRSpecifies the host name of the machine on which the databaseserver is running. If the value begins with a slash, it isused as the directory for the Unix domain socket. The defaultis taken from the \fBPGHOST\fR environment variable,if set, else a Unix domain socket connection is attempted..TP\fB-p \fIport\fB\fRSpecifies the TCP port or local Unix domain socket fileextension on which the server is listening for connections.Defaults to the \fBPGPORT\fR environment variable, ifset, or a compiled-in default..TP\fB-U \fIusername\fB\fRConnect as the given user..TP\fB-W\fRForce a password prompt. This should happen automatically ifthe server requires password authentication..PP.SH "ENVIRONMENT".TP\fBPGHOST\fR.TP\fBPGPORT\fR.TP\fBPGUSER\fRDefault connection parameters.PPThis utility, like most other PostgreSQL utilities,also uses the environment variables supported by \fBlibpq\fR(see in the documentation)..PP.SH "NOTES".PPSince \fBpg_dumpall\fR calls\fBpg_dump\fR internally, some diagnosticmessages will refer to \fBpg_dump\fR..PPOnce restored, it is wise to run \fBANALYZE\fR on eachdatabase so the optimizer has useful statistics. Youcan also run \fBvacuumdb -a -z\fR to analyze alldatabases..PP\fBpg_dumpall\fR requires all neededtablespace directories to exist before the restore ordatabase creation will fail for databases in non-defaultlocations..SH "EXAMPLES".PPTo dump all databases:.sp.nf$ \fBpg_dumpall > db.out\fR.sp.fi.PPTo reload this database use, for example:.sp.nf$ \fBpsql -f db.out postgres\fR.sp.fi(It is not important to which database you connect here since thescript file created by \fBpg_dumpall\fR willcontain the appropriate commands to create and connect to the saveddatabases.).SH "SEE ALSO".PPCheck \fBpg_dump\fR(1) for details on possibleerror conditions.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -