Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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
You can’t perform that action at this time.