How to dump and restore a postgresql database

To create a postgresql dump in linux, execute the following commands:

  1. Login as root user
  2. >su - postgres
  3. >pg_dump -U username -W -Z 9 -f /tmp/dump_username.dump.zip -h 127.0.0.1 username
  4. >password
To restore, execute:
  1. >psql -U username -f dump_username.dump database
Other ways:
>pg_dump -U <username> -W -Z 9 -f /outfile.dump.zip -h 127.0.0.1 <dbname>
><password>

//to restore
>psql -U <username> -f <infile> <dbname>
How to dump and restore a postgresql database How to dump and restore a postgresql database Reviewed by Edward Legaspi on Monday, December 08, 2014 Rating: 5

No comments:

Powered by Blogger.