Last active
May 9, 2016 19:05
-
-
Save nathcampreguer/4d1871bad3ac86d15961 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
DBNAME=<database_name> | |
DBUSER=<database_user> | |
DBHOST=<host> | |
DUMP_FILE=$1 | |
if [[ $DUMP_FILE == "" ]]; then | |
echo "[ERROR] Arquivo de dump não especificado" | |
echo " usage: restore.sh DUMP_FILE" | |
exit 0 | |
fi | |
dropdb --username=$DBUSER --host=$DBHOST $DBNAME | |
createdb --username=$DBUSER --host=$DBHOST $DBNAME | |
pg_restore -v --exit-on-error --single-transaction --no-owner --no-privileges --host=$DBHOST --dbname=$DBNAME --username=$DBUSER $DUMP_FILE | |
reindexdb --username=$DBUSER --host=$DBHOST --system | |
reindexdb --username=$DBUSER --host=$DBHOST $DBNAME | |
vacuumdb --full --analyze --username=$DBUSER --host=$DBHOST $DBNAME | |
exit $? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment