Last active
September 14, 2016 09:22
-
-
Save ivanovaleksey/4f73d2e7ee8a56a6121134557e50e0e2 to your computer and use it in GitHub Desktop.
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
# make_dump(){ | |
# now=$(date +"%Y%m%d") | |
# pg_dump -Fc -U deployer -w mercury_production -f ~/manual_dumps/mercury_sa_$now.dump | |
# } | |
_pg_restore(){ | |
if [[ -z $1 ]]; then | |
echo Database is not specified | |
return 0 | |
fi | |
if [[ -z $2 ]]; then | |
echo File is not specified | |
return 0 | |
fi | |
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U $(whoami) -d $1 $2 | |
} | |
_pg_mercury_restore(){ | |
if [[ -z $1 ]]; then | |
echo Database is not specified | |
return 0 | |
fi | |
local db_name=mercury_$1 | |
_pg_restore $db_name $2 | |
} | |
_pg_mercury_restore_completion(){ | |
_arguments "1: :(indonesia malaysia philippines south_africa taiwan vietnam)"\ | |
"2: :_files -g \*.backup" | |
} | |
compdef _pg_mercury_restore_completion _pg_mercury_restore | |
alias pg.restore=_pg_restore | |
alias pg.m.restore=_pg_mercury_restore |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment