At some point in development, you may want to make a copy of your existing development database to play with an unstable new feature. Postgres makes it super trivial to do that by allow us to create a new database by using existing database as a template.
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
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
Instead of running command in psql, we can use createdb with -T flag like so
$ createdb -T original_database_name new_database_name