raghu kalachar wrote:Thank you Tim for giving breif information on commands and your examples.
Mainly I would like to zip the dump which i get from custom format pg_dump command. I would like to know what will be best utility to use ? let me know
It all depends on your needs. A straight -Fc dump is already "zipped" in an optimal format for a pg_restore operation. As I said earlier, compressing a compressed file can actually result in a larger file than if you didn't do the second compression at all.
pg_dump does have other options. One of them is to dump as a set of text files in a directory that can then be run into the zip or tar (with optional compression) utilities. That would be more for the benefit of being able to selectively work with selected backed-up SQL than for a quick pg_restore, where '-Fc' was specifically designed for that option.
If you're not familiar with how ZIP actually works, here's some information. Ever notice that when you're zipping a whole directory of files, sometimes it says "deflate", sometimes it says "store", sometimes it says something else and that not all files in the ZIP archive are always saying the same thing? That's because ZIP's default behavior is to try different methods of compression to see which one is most effective. Then it reports the method used. The "store" method means it isn't compressed at all. "deflate" is the most common algorithm, but "bzip" is also an option. You can manually override the storage technique used, but generally it's not worth the trouble. The exception being where you're often doing the same kind of thing and you know the best compression and want to skip all the extra tests.
The pg_dump utility has ability to fine-tune backup formats and their compression schemes as well. Unless you have a very compelling reason to do otherwise (as in you have measured how things work in your shop or you have an idiot supervisor who claims that "X" is better and that you "Absolutely Must" do it that way), then "-Fc" is good enough. It's what I use. It keeps life simple and I don't have to remember all the weird options I set when the backup was made if there's an emergency restore required. Because I didn't have any weird options