Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env bash
- remote_host=remote-host
- remote_port=5432
- remote_db=remote-db
- remote_user=remote-user
- remote_password=remote-password
- # create .pgpass
- echo "${remote_host}:${remote_port}:${remote_db}:${remote_user}:${remote_password}" > ~/.pgpass
- chmod 600 ~/.pgpass
- # initialize DB
- psql -U postgres -d postgres -c 'drop schema public cascade;'
- psql -U postgres -d postgres -c 'create schema public;'
- # dump and restore
- pg_dump -h $remote_host -U $remote_user | psql -h localhost -U postgres postgres
- # remove .pgpass
- rm ~/.pgpass
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement