Skip to content

Instantly share code, notes, and snippets.

@joaomarceloods
Created July 21, 2017 18:38
Show Gist options
  • Save joaomarceloods/02f821027e0007039eda27ced6565919 to your computer and use it in GitHub Desktop.
Save joaomarceloods/02f821027e0007039eda27ced6565919 to your computer and use it in GitHub Desktop.
Postgres - Clone remote database
pg_dump -Fc \
-d REMOTE_DB_NAME \
-h REMOTE_DB_HOST \
-p 5432 \
-U REMOTE_DB_USER \
|\
pg_restore \
-d LOCAL_DB_NAME \
-h localhost \
-p 5432 \
-U LOCAL_DB_USER \
-n public --clean --no-owner \
--role=LOCAL_DB_USER
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment