I need to duplicate the existing database including its schema and structure to another new database. I need this in shell command environment and not in pgadmin. Please kindly help me.
nohup pg_dump exampledb > example-01.sql
createdb -O postgres exampledbclone_01
my user is "postgres"
nohup psql exampledbclone_01 < example-01.sql
$ pg_dump mydb > db.sql
$ psql -d newdb -f db.sql
CREATE DATABASE my_new_database TEMPLATE my_old_database;– anjaneyulubatta505 Apr 11 '19 at 05:40pg_dumpandpg_restoreif you want to be more selective and dump (say) just the structure. – Craig Ringer Jan 13 '20 at 02:23dropdb xxx_test; createdb -T xxx_development xxx_test– Dogweather Jun 01 '21 at 04:01