×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: SQL
Posted by: Paul Allies Allies
Added: Dec 24, 2013 3:17 PM
Views: 22
Tags: sql postgres db
Backup and Restore PostgreSQL Database
  1. -- Backup Database
  2. $ pg_dump -Fc -U <username> -d <database> -p 5432 > db.dump
  3.  
  4. --Example
  5. $ pg_dump -Fc -U admin1 -d db1 -p 5432 > db1.dump
  6.  
  7. -- Restore Database
  8. $ pg_restore -Fc -U <username> -d <database> -p 5432 <filename>.dump
  9.  
  10. -- Example
  11. $ pg_restore -Fc -U admin1 -d db1 -p 5432 db1.dump