Last active
January 31, 2023 13:34
-
-
Save syabro/5073c37cc3df1a694705 to your computer and use it in GitHub Desktop.
Load remote db to local one
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
#!/bin/bash | |
echo "Dumping $1 to /tmp/$1.pgdump..." | |
ssh [email protected] "pg_dump -U www-data -Fc -O $1" > /tmp/$1.pgdump | |
echo "Destroying current DB..."; | |
psql template1 -c "drop database if exists localdb;" > /dev/null | |
echo "Creating DB..."; | |
psql template1 -c "create database localdb" > /dev/null | |
echo "Restoring dump from /tmp/$1.pgdump..." | |
pg_restore --dbname=localdb --no-owner --no-acl --jobs=16 /tmp/$1.pgdump | |
rm -rf /tmp/$1.pgdump |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment