postgresql-dump - a utility to dump and destroy a PostgreSQL database when the database format becomes incompatible with a previous version.


/usr/lib/postgresql/bin/postgresql-dump [-b blocksize? [-c? [-d? [-e encoding? [-f? [-i? [-l? [-p directory? -t target_file [-v? [-x?


postgreql-dump is used to dump and reload the whole PostgreSQL database when the database format has changed between releases and become incompatible. It tests for this situation by reading the version file in the top-level directory of the PostgreSQL database.

The trace of the program output is sent to standard output or standard error.

If there is an incompatibility between the database version of the current PostgreSQL programs and that of the database itself, this program must be used to dump the database to an ASCII file. (This may be a tape device.)

If the -d option is used, the entire contents of the database directory are then deleted. They may be preserved in another location, with the -p option, should you have both the desire and the spare disk capacity.

Postgresql-dump may only be run by the user postgres (the postgresql superuser).


-b blocksize

Specify the blocksize for writing the dump to target. This is only useful for output to a tape drive; it makes the script use dd to write to the target, instead of redirecting standard output.


After the dump has been written, copy it to screen through the filter named in PAGER (or more, by default) and ask the user to give confirmation before deleting the database files.


Destroy the database files after dumping the database. This option must be used when a new, incompatible release of PostgreSQL is loaded.

-e encoding

Force the default encoding to be encoding instead of its current value. This will not affect the encoding of existing databases, but will be used whenever a new database is created without a specific encoding's being specified.


Fix rules from earlier versions to the 6.5 (and later) standard. This filters the dump file through


Force an upgrade, even though the database version number is apparently up to date. This may be needed between beta releases that require an initdb even though the version number does not change.


Create a new database with initdb. This requires the option -d.


Load the dump into a new database. This option requires the -i option.

-p directory

This option can only be used with -d. Instead of destroying the database files, the program moves them under directory, creating it, if necessary. Directory must not be the same directory as, or underneath the directory named in the environment variable, PGDATA.

-t target

This option is always required. Target is the file or tape to which the ASCII dump should be written. It is incorrect to name any physical device other than a tape. It is not possible (or, at least, meaningful) to use a tape with the -c option and also to start the dump in the middle of the tape. Target must not be the same directory as, or underneath the directory named in the environment variable, PGDATA.


Print more information about what the script is doing.


Prevents dumping the old database; use of this option overrides -x and -c. It is intended for use by the Debian post-installation script.


Prevents dumping the old database; use of this option forces

  • c.


initdb, pg_dump, pg_dumpall, pg_upgrade


The program does not check that a device is really a tape. If you send the dump to the screen, for instance, and also use -d, without -c, you will destroy your database irrecoverably.


postgresql-dump was written for Debian GNU/Linux by Oliver Elphick

This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.