Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When executing a pg_dump which should I use and why?

pg_dump -U <user> <database> | gzip -c > backup.gz


pg_dump -F c -f backup.tar.gz -U <user> <database>

share|improve this question
In any case, don't use the -d option because it's deprecated since 8.4 and it has never meant to select the database to dump, it meant this instead (from PG-8.3 doc): > -d > --inserts Dump data as INSERT commands (rather than COPY). This will make restoration very slow; it is mainly useful for making dumps that > can be loaded into non-PostgreSQL databases. Also, it's not a good idea to suffix the filename of a dump in custom format (-Fc) with .tar.gz because it's not a gzipped tarfile. The custom dumps can only be processed – Daniel Vérité Oct 22 '12 at 14:57
up vote 2 down vote accepted

According to the pg_dump documentation the custom format is:

the most flexible output format in that it allows manual selection and reordering of archived items during restore. This format is also compressed by default

You can also select the compression level with the -Z option.

For simplicity I would definitely go for pg_dump -F c over piping to gzip.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.