In postgres console, run
=# CREATE DATABASE new_database_name WITH TEMPLATE original_database_name;
Boom!, you got a cloned database named new_database_name.
Credit: Creating a copy of a database in Postgres
PS: I've seen a convenient way to make a clone across remote server too. (Haven't try) How to copy postgres database to another server
Update Aug 27, 2015:
Instead of running command in psql, we can use createdb with -T flag like so
$ createdb -T original_database_name new_database_nameCredit: http://stackoverflow.com/a/6739995
5 comments:
Nice!. Do you know if this is going to copy data as well? or just the schema.
Thanks. It does copy the data. You'll get the exact same database with the original one.
Hi
clone database is it slower or faster than "pg_restore" utility?
Thanks
Bader
Hi
clone database is it slower or faster than "pg_restore" utility?
Thanks
Bader
I don't know actually, but cloning seems pretty fast to me
Post a Comment