Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

When executing a pg_dump which should I use and why?

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

or

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
add comment

1 Answer

up vote 1 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
add comment

Your Answer

 
discard

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.