My environment:
# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
# rpm -q postgresql
postgresql-9.2.18-1.el7.x86_64
#
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?
asked Jun 6, 2017 at 15:37
1 Answer 1
Your dump is in SQL format. Just open your db.out file remove what's for other databases.
answered Jun 7, 2017 at 9:37
-
that would be too much, i want better solution then editing dump file, what's other way of accomplishing same thing? perhaps changing
pg_dumpall
topg_dump
? but then I need to keep track of each database name, which also not ideal...alexus– alexus2017年06月15日 21:14:01 +00:00Commented Jun 15, 2017 at 21:14 -
Then you have to use
pg_dump
for each and every database you want to dump to a file. You can list all you databases withpsql
. Don't forget to usepg_dumpall
with-g
option to save roles and tablespaces.Arkhena– Arkhena2017年06月19日 06:18:15 +00:00Commented Jun 19, 2017 at 6:18
lang-sql
pg_dumpall
, apart from the DB in question? Isn't it easier just to dump a single DB usingpg_dump
?