Reputation: 100010
We want to replicate our local test DB automatically, given the structure of the production DB, on the fly / on demand.
What would be nice, would be to query the prod DB and retrieve the SQL that generates the tables/views and then run that SQL against a cleaned out local DB.
Or perhaps there is a better way to replicate a production DB on a local machine?
What is the best way to do this?
Upvotes: 0
Views: 103
Reputation: 3189
If I understood your question correct, you need to copy DB schema. You can use pg_dump
with --schema-only
parameter to do this. It'll only dump schema of the database, and you can import it locally.
$ pg_dump mydb --schema-only > mydb-schema.sql
Upvotes: 2