Removing comments from pg_dump output
I've just submitted this patch for Postgres 11+ (still under consideration) that should allow one to dump without COMMENTS (until an ideal solution is in place) which should be a slightly better kludge than the ones we resort to using.
If there are enough voices, it may even get back-patched to Postgres 10!
[UPDATE]
This is now a feature in Postgres v11+
On a UNIX type operating system, I would do it like this:
pg_dump [options] mydatabase | sed -e '/^--/d' >mydatabase.dmp
This could accidentally swallow data lines that start with --
. To work around that problem, use the --inserts
option of pg_dump
.