- pgx_list_dbs: Lists the names of databases in an .sql file dumped using pg_dumpall.
- pgx_extract_db: Extracts a single database from a sql file dumped with pg_dumpall and outputs its content to stdout.
Download the (re)installer by doing:
sudo wget -O /usr/local/bin/pgx_installer \ https://gist.github.com/runekaagaard/7924963/raw/pgx_installer \ && sudo chmod +x /usr/local/bin/pgx_installer
Then run it with:
pgx_installer
Based on:
http://madssj.com/blog/2010/04/09/extracting-a-single-database-from-a-pg_dumpall-postgresql-dump/
I had problems running the following command:
I got the following error message: "error: start or end not found". Notice the database name my-database. It includes a dash character.
Iff a database name includes dash characters,
pg_dumpall
will generate a\connect
statement with its database name parameter in double quotes, e.g. the full dump won't include the statement\connect my-database
, but\connect "my-database"
.The solution / workaround then is to run
pg_extract_db
with the database name in (shell-escaped) double quotes: