Created
September 18, 2019 15:11
-
-
Save sankars/ca8239912cad91044bf1f46619f6a068 to your computer and use it in GitHub Desktop.
Script to replicate Hive DB in the same cluster
This file contains hidden or 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
#!/bin/sh | |
SRC_DB_NAME="src" | |
TGT_DB_NAME="tgt" | |
EXPORT_DIR="/tmp" | |
HiveTables=$(hive -e "use $SRC_DB_NAME;show tables;" 2>/dev/null | egrep -v "WARN|^$|^Logging|^OK|^Time\ taken") | |
for Table in $HiveTables | |
do | |
hive -e "EXPORT TABLE $SRC_DB_NAME.$Table TO '$EXPORT_DIR/$SRC_DB_NAME.$Table';" | |
hive -e "IMPORT TABLE $TGT_DB_NAME.$Table FROM '$EXPORT_DIR/$SRC_DB_NAME.$Table';" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment