How to Restore a Postgresql Database.doc - FTP Directory Listing

needmoreneedmoreData Management

Nov 28, 2012 (4 years and 10 months ago)

379 views


How to
Restore a Postgresql

Database


To restore database



rcapache stop


r
csolcl stop


rcpostgresql restart


If the database is compressed to a .gz file:


C
opy zip
ped file (.gz)

to a dir
ectory

and unzip (assuming the zipped file is in
/root/ direc
tory
)



md db


cd db


cp /root/

db_backup_filename
.sql.gz /root/db


gunzip *


Next, copy the unzipped .sql file to /work/pgsql



cd /work/pgsql


cp /root/db/ db_backup_filename.sql /work/pgsql/


Now to do the restore:



su
-

postgres
-
c 'drop
db ipbilling'


su
-

postgres
-
c 'createdb ipbilling'


psql
-
U postgres ipbilling < db_backup_filename.sql


rcapache start


rcsolcl start