Created
October 29, 2015 15:45
-
-
Save mlebkowski/7ac8ab17587e02f0d5c6 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
#!/usr/bin/env bash | |
set -ueo pipefail | |
MYSQL_USER=${MYSQL_USER:-root} | |
main() { | |
local project=${1:-} | |
local suffix=${2:-"prod"} | |
if [ -z "$project" ]; then | |
echo "Usage: $0 <project-name> [<database-suffix>]" >&2 | |
return 1 | |
fi | |
local dbname="${project}_${suffix}" | |
echo "Importing $dbname" | |
( | |
echo "DROP DATABASE IF EXISTS $dbname;" | |
echo "CREATE DATABASE $dbname;" | |
echo "USE $dbname;" | |
ssh voyager.arsthanea.com cat /home/git/$project/dump.sql.gz | gunzip | |
) | mysql -u $MYSQL_USER -p | |
} | |
main "$@" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment