Advertisement
Guest User

Untitled

a guest
Jan 5th, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #!/usr/bin/env bash
  2.  
  3. remote_host=remote-host
  4. remote_port=5432
  5. remote_db=remote-db
  6. remote_user=remote-user
  7. remote_password=remote-password
  8.  
  9. # create .pgpass
  10. echo "${remote_host}:${remote_port}:${remote_db}:${remote_user}:${remote_password}" > ~/.pgpass
  11. chmod 600 ~/.pgpass
  12.  
  13. # initialize DB
  14. psql -U postgres -d postgres -c 'drop schema public cascade;'
  15. psql -U postgres -d postgres -c 'create schema public;'
  16.  
  17. # dump and restore
  18. pg_dump -h $remote_host -U $remote_user | psql -h localhost -U postgres postgres
  19.  
  20. # remove .pgpass
  21. rm ~/.pgpass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement