«

»

Aug
17

How to Backup and Restore PostgreSQL Database

pg_dump is an effective tool for PostgreSQL through which we can backup postgres database and to restore PostgreSQL database, command psql is enough.

1) backup postgres database

Ssh to server and execute following command to take backup of database.

#pg_dump -U Db_User Db_name -f database_name.sql

Executing above command will prompt you for database password, once password is authenticated database will be backup into file database_name.sqlNote: replace Db_User and Db_name with your actual database user and database name respectively.


2) Restore postgres database

#psql -U Db_user -d Db_name -f mydb.sql


contact@webhostingsupport.info

Post to Twitter

1 comment

  1. vibhor Kumar says:

    pg_dump command would help you take the backup as snapshot of data in PostgreSQL for one particular moment.

    However, when it comes production system, where user cannot afford to loss data, Hotbackup of PostgreSQL is recommended.
    Following is a link for Hotbackup of Postgresql DB:
    http://www.postgresql.org/docs/8.4/interactive/continuous-archiving.html

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>