Untitled UI logotext
Solutions
WebsitesEcommerceMobile AppsWeb AppsProduction Support & Maintenance
Our work
Company
About usBlogPodcastContact us
Book a free consultation

How To Duplicate a PGSQL database

Olivia Rhye

Recently I needed to create a duplicate of PGSQL database. Being a MySQL guy, I didn't know off hand how to do it, but here is an easy way:

pg_dump original_db > original_db.sql
createdb new_db
psql -d new_db < original_db.sql

From a bird's eye view, you are creating a dump of the original database and outputting it to a file. From there, make sure the new database is created and use your dump file as input for that database. It wouldn't be too hard to make this into a one-liner, but I like to see intermediate steps to make sure things are going well.

Ready to start a project?

Book a free consultation
Untitled UI logotext
Our work
About us
Blog
Careers
Submit a ticket
Agency Partnerships
Contact
© 2024 fjorge. All rights reserved.
Privacy