Difference between revisions of "PostgreSQL"

From FusionPBX
Jump to: navigation, search
(Additional Info)
(Additional Info)
 
(7 intermediate revisions by the same user not shown)
Line 5: Line 5:
 
==Backup==
 
==Backup==
 
The following assumes the database username is fusionpbx and the database to backup is fusionpbx. Make sure you have the database password ready.
 
The following assumes the database username is fusionpbx and the database to backup is fusionpbx. Make sure you have the database password ready.
  pg_dump -U fusionpbx fusionpbx -f /tmp/fusionpbx.sql
+
su postgres
 +
  pg_dump -U fusionpbx fusionpbx -b -v -f /tmp/fusionpbx.sql
  
 
==Restore==
 
==Restore==
 +
Assuming username fusionpbx and database fusionpbx
 +
psql -U fusionpbx -d fusionpbx -f fusionpbx.sql
  
==Additional Info==
+
==Console==
 +
su postgres
 +
psql
 +
 
 +
list the databases
 +
\l
 +
 
 +
connect to the database
 +
\connect fusionpbx
 +
 
 +
or
 +
 
 +
\c fusionpbx
 +
 
 +
list tables
 +
\d
 +
 
 +
drop the database
 +
DROP DATABASE fusionpbx;
 +
 
 +
create the database
 +
CREATE DATABASE fusionpbx;
 +
 
 +
 
 +
==Links==
 
http://www.mkyong.com/database/backup-restore-database-in-postgresql-pg_dumppg_restore/
 
http://www.mkyong.com/database/backup-restore-database-in-postgresql-pg_dumppg_restore/
 +
 +
http://www.postgresql.org/docs/9.1/static/backup.html

Latest revision as of 06:05, 28 October 2012

PostgreSQL is a enterprise grade open source database. http://www.postgresql.org/


Backup

The following assumes the database username is fusionpbx and the database to backup is fusionpbx. Make sure you have the database password ready.

su postgres
pg_dump -U fusionpbx fusionpbx -b -v -f /tmp/fusionpbx.sql

Restore

Assuming username fusionpbx and database fusionpbx

psql -U fusionpbx -d fusionpbx -f fusionpbx.sql

Console

su postgres
psql

list the databases

\l

connect to the database

\connect fusionpbx

or

\c fusionpbx

list tables

\d

drop the database

DROP DATABASE fusionpbx;

create the database

CREATE DATABASE fusionpbx;


Links

http://www.mkyong.com/database/backup-restore-database-in-postgresql-pg_dumppg_restore/

http://www.postgresql.org/docs/9.1/static/backup.html