Migrate Metastore from one cluster to another
source cluster
mv alltables.sql alltables.sql.backup ; for d in hive -e "show databases"
; do echo "create database $d; use $d;" >> alltables.sql ; for t in hive --database $d -e "show tables"
; do ddl=hive --database $d -e "show create table $t"
; echo "$ddl ;" >> alltables.sql ; echo "$ddl" | grep -q "PARTITIONED\s*BY" && echo "MSCK REPAIR TABLE $t ;" >> alltables.sql ; done; done
destination cluster
hive -f alltables.sql