Friday, February 24, 2012

PostgreSQL - Compressing text dumps on the fly

This one was missing in my recipes ...


pg_dump -U myUser myDB | gzip > myDB.sql.gz

Then, to restore:

gzip -cd myDB.sql.gz | pg_restore ...

or

or zcat myDB.sql.gz |pg_restore


The "tar" utility is for bundling up a bunch of files and directories into a single file (the name is a contraction of "tape archive"). In that respect, a "tar" file is kind-of like a "zip" file, except that "zip" always implies compression while "tar" does not.

Note finally that "gzip" is not "zip." The "gzip" utility just compresses; it doesn't make archives.


Reference:

http://stackoverflow.com/questions/2379482/shell-scripting-use-a-pipe-as-an-input-for-tar

No comments:

Post a Comment