Last active
January 29, 2020 16:48
-
-
Save faisalmahmud/0be5292a6c411a1cfd8184f111e9e6a8 to your computer and use it in GitHub Desktop.
Postgres commands that makes it easy to take a local DB snapshot and restore it
This file contains hidden or 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
DATE_WITH_TIME=`date "+%Y%m%d-%H%M%S"` | |
pg_dump -Fc -U $1 -h localhost -p 5432 $1 --no-owner --no-acl -f "pgdump-$1-$DATE_WITH_TIME.bak" |
This file contains hidden or 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
pg_restore -Fc -c -U $1 -h localhost -d $1 -O --no-acl --no-owner -v $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment