Child pages
  • PostgreSQL Backup and Restore
Skip to end of metadata
Go to start of metadata
This section briefly describes how to backup and restore PostgreSQL database.


PostgreSQL provides the utility program pg_dump for taking the backup of database. Following is the syntax of this command:

pg_dump -h [hostname] -p [port_number] -U [username] -W [databasename] > [backupfile.sql]

[hostname] - this is your database server host
[port_number] - this is your database server port number
[username] - this is your database username
[databasename] - the name of your RMsis database
[backupfile.sql] - the file to which the backup should be written.

You will be prompted to provide the database password.


The idea behind pg_dump is to generate a text file with SQL commands that, when fed back to the server, will recreate the database in the same state as it was at the time of the dump.The text files created by pg_dump are intended to be read in by the psql program. Following is the general command syntax to restore a dump :

psql -h [hostname] -p [port_number] -U [username] -W [database_to_restore] < [backupfile.sql]


A detailed explanation for backup and restore of PostgreSQL database is available here :

  • No labels