Copy Postgres database into another database on same server

Hey friends. I need to copy a Postgres database on the same server.

So if I have a source database, I want to make a source_copy database with all of the same data and tables.

CREATE DATABASE source_copy WITH TEMPLATE source does not work because it will lock the table and does not allow additional connections. This makes things excessively complicated, and I’ve not figured out how to make this work with Ecto.

Also it is a managed database so pg_dump isn’t great either since the DB is HUGE and I don’t want to pay the networking transfer penalty. ( Plus reloading the dump has a penalty as well )

These are for dev environments so they do not have to be perfect.

Any recommendations for doing this?