<p>What is the most efficient, secure way to pipe the contents of a postgresSQL database into a compressed tarfile, then copy to another machine?</p>

<p>This would be used for localhosting development, or backing up to a remote server, using *nix based machines at both ends.</p>

[{'answer_id': 81679, 'author': 'Espo', 'author_id': 2257, 'author_profile': 'https://Stackoverflow.com/users/2257', 'pm_score': 1, 'selected': False, 'text': '<p><a href="http://www.cyberciti.biz/faq/how-to-back-up-a-web-server/" rel="nofollow noreferrer">This page</a> has a complete backup script for a webserver, including the pg_dump output.</p>\n\n<p>Here is the syntax it uses:</p>\n\n<pre><code>BACKUP="/backup/$NOW"\nPFILE="$(hostname).$(date +\'%T\').pg.sql.gz"\nPGSQLUSER="vivek"\nPGDUMP="/usr/bin/pg_dump"\n\n$PGDUMP -x -D -U${PGSQLUSER} | $GZIP -c &gt; ${BACKUP}/${PFILE}\n</code></pre>\n\n<p>After you have gzipped it, you can transfer it to the other server with <a href="http://en.wikipedia.org/wiki/Secure_copy" rel="nofollow noreferrer">scp</a>, <a href="http://en.wikipedia.org/wiki/Rsync" rel="nofollow noreferrer">rsync</a> or <a href="http://en.wikipedia.org/wiki/Network_file_system" rel="nofollow noreferrer">nfs</a> depending on your network and services.</p>\n'}, {'answer_id': 82210, 'author': 'bortzmeyer', 'author_id': 15625, 'author_profile': 'https://Stackoverflow.com/users/15625', 'pm_score': 1, 'selected': True, 'text': "<p>pg_dump is indeed the proper solution. Be sure to read the man page. In Espo's example, some options are questionable (-x and -D) and may not suit you.</p>\n\n<p>As with every other database manipulation, test a lot!</p>\n"}]
['https://Stackoverflow.com/questions/81657', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/15479/']