Last active
February 28, 2019 02:56
-
-
Save guysherman/d825b541402198929a8fa47e20357694 to your computer and use it in GitHub Desktop.
Script to clone an AWS postgres db to local
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env bash | |
set -euxo pipefail | |
PGSSLMODE=require pg_dump -h $1 -p $2 -U $3 -f dump.sql $5 | |
psql -U $4 -c "DROP DATABASE IF EXISTS $5" | |
psql -U $4 -c "CREATE DATABASE $5" | |
psql -U $4 -d $5 -f dump.sql |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use the following arguments, in this order:
AWS postgres hostname
AWS postgres port
AWS postgres username
local postgres username
database name (same for both)