Skip to content

Instantly share code, notes, and snippets.

@Condla
Created March 8, 2018 09:06
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 Condla/ec4aa2aa9bc0c3562250a9aea2d5604a to your computer and use it in GitHub Desktop.
Save Condla/ec4aa2aa9bc0c3562250a9aea2d5604a to your computer and use it in GitHub Desktop.
#!/usr/bin/bash
export DUMP_PATH=/tmp
mysqldump -u$HIVE_USER -p$HIVE_PASSWORD -h $MYSQL_HOST hive > $DUMP_PATH/hive.dump
sed -i s/$CLUSTERNAME/$CLUSTERNAME2/g $DUMP_PATH/hive.dump
echo 'DROP DATABASE hive; CREATE DATABASE hive; USE hive;' | cat - $DUMP_PATH/hive.dump > $DUMP_PATH/temp && mv $DUMP_PATH/temp $DUMP_PATH/hive.dump
mysql -u$HIVE_USER2 -p$HIVE_PASSWORD2 -h $MYSQL_HOST2 hive < $DUMP_PATH/hive.dump
rm $DUMP_PATH/hive.dump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment