Skip to content

Instantly share code, notes, and snippets.

@guysherman
Last active February 28, 2019 02:56
Show Gist options
  • Save guysherman/d825b541402198929a8fa47e20357694 to your computer and use it in GitHub Desktop.
Save guysherman/d825b541402198929a8fa47e20357694 to your computer and use it in GitHub Desktop.
Script to clone an AWS postgres db to local
#! /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
@guysherman
Copy link
Author

Use the following arguments, in this order:
AWS postgres hostname AWS postgres port AWS postgres username local postgres username database name (same for both)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment