- Make a copy of the database using pg_dump
$ pg_dump -h <public dns> -U <my username> -f <name of dump file .sql> <name of my database>
- you will be asked for postgressql password.
- a dump file(.sql) will be created
- Clean the existing database by recreating it.
psql -U "<my username>" -d <some local database name> -c "DROP DATABASE <database name>;"
psql -U "<my username>" -d <some local database name> -c "CREATE DATABASE <database name>;"
- The dump file might contain references to the original user priveleges. In this case you will have to do one of the two things:
- Create the same user locally:
psql -U "<my username>" -d <database name> -c "CREATE USER <original postgresql username> SUPERUSER;"
- Replace all mentions of the old username with a new one in your
<name of dump file .sql>
- Create the same user locally: