AFAIK, neither pg_dump nor pg_restore have options for deleting COMMENT s. But if you use a binary dump format, for example:
$ pg_dump -Fc <your connection> -f /path/to/backup.dump
you can extract the entry in the TOC and edit it:
$ pg_restore -l -f /path/to/backup.toc /path/to/backup.dump
The above file will extract the TOC file and save it in /path/to/backup.toc , then you can find each line with the COMMENT entry and delete or comment on it. If you don't use weird names on your objects, a simple sed will solve the problem, to comment out the lines with COMMENT , you could do this (the semicolon started the comment):
$ sed -i 's/^\(.* COMMENT .*\)/;\1/g' bar.toc
With this new TOC file, you can now use pg_restore to restore the dump (with the -L option):
$ pg_restore -L /path/to/backup.toc -d <your database> /path/to/backup.dump
source share