Skip to content

Instantly share code, notes, and snippets.

@ivanovaleksey
Last active September 14, 2016 09:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanovaleksey/4f73d2e7ee8a56a6121134557e50e0e2 to your computer and use it in GitHub Desktop.
Save ivanovaleksey/4f73d2e7ee8a56a6121134557e50e0e2 to your computer and use it in GitHub Desktop.
# 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