Looking for a JavaEE Architect or Potential Tech Co-Founder?
Please don't hesitate to contact me.

How to setup postgresql in ubuntu 11.10 and perform dump/restore

This write up will try to explain how to install postgresql and attempt to perform database dump and restore. Which should be a basic functionality but is not present in pgadmin.

 1.) Install postgresql (execute in terminal):
sudo apt-get install postgresql postgresql-contrib

2.) Setup postgres user:
sudo -u postgres psql
alter user postgres password 'postgres'
//close the terminal after.

3.) To check install pgadmin via "Ubuntu Update Center", and try to login using postgres/postgres account.
4.) Perform dump/restore. But before performing the ff commands, you should login as postgres first:
sudo su postgres

+Create the dumps:
//dump the roles
pg_dumpall -g -U postgres > roles.sql

+Dump the schema
pg_dump -Fp -s -v -f schema.sql -U postgres databaseName

+Dump the data
pg_dump -Fc -v -f data.dump -U postgres databaseName

+How to restore
psql -f roles.sql
psql -f schema.sql databaseName
pg_restore -a -d databaseName -Fc data.dump

Note: Got this somewhere else, just added some more statements.
How to setup postgresql in ubuntu 11.10 and perform dump/restore How to setup postgresql in ubuntu 11.10 and perform dump/restore Reviewed by Edward Legaspi on Friday, June 01, 2012 Rating: 5

No comments:

Powered by Blogger.