I have a snapshot of a Postgres database named srcDB in a file named srcDB-cachedump.gz, obtained using pg_dump. The dump is from a production database, so there are a bunch of different roles. What I would like to do is make a development database called devDB, which has only one role, a user by the name of 'development', but with the same schema as the original database.
The way I initially tried to do this was:
gunzip -c srcDB-cachedump.gz | psql -d devDB -U development -W
When I ran this, however, I got many errors that boiled down to, essentially, "role does not exist." I would like to bypass the recreation of the roles in the production database if at all possible, as I have other programmers on my team and I would like the dev environment to be as portable as possible. I am relatively new at Postgres administration, though, so I am at a loss.
pg_restore
instead ofpsql
to restore your DB. It has a set of options you may need. You may also need to change DB dump format formsql-in-archive
to postgres custom bump format. – Igor Romanchenko Nov 22 '14 at 19:12pg_restore
with plain text dump. I am not shure it will work. – Igor Romanchenko Nov 24 '14 at 20:29