postgresql pg_dumpall restore one database

Posted on

Question :

My environment:

# cat /etc/redhat-release 
Red Hat Enterprise Linux Server release 7.3 (Maipo)
# rpm -q postgresql

I used following PostgreSQL: Documentation: 9.6: pg_dumpall to take dump all databases

$ pg_dumpall > db.out

from what I understand, following will restore all databases:

$ psql -f db.out postgres

my goal is, I need to restore just a one (single) database from that entire dump, how does one accomplish this task?

Answer :

Your dump is in SQL format. Just open your db.out file remove what’s for other databases.

Leave a Reply

Your email address will not be published.