Last active
August 3, 2016 18:10
-
-
Save ibspoof/0c04c4849219572f8efa701f0214ceaa to your computer and use it in GitHub Desktop.
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
SNAPS=$(ls -R /app/cassandra/datastax/dse-data* | grep 1469291 | grep app) | |
while read -r line; do | |
MOVE_FROM=$(echo $line | awk -F":" '{print $1}') | |
#echo "MOVE_FROM = $MOVE_FROM" | |
TABLE_NAME=$(echo $line | awk -F"/" '{print $7}' | awk -F"-" '{print $1}') | |
#echo "TABLENAME = $TABLE_NAME" | |
KEYSPACE_DIR=$(echo $line | awk -F/ '{print "/"$2"/"$3"/"$4"/"$5"/"$6}') | |
#echo "KEYSPACE_DIR = $KEYSPACE_DIR" | |
TABLE_UUID=$(ls -la $KEYSPACE_DIR | grep $TABLE_NAME- | grep "Jul 23" | grep -v "09:2" | awk '{print $9}') | |
TABLE_UUID_CNT=$(echo "$TABLE_UUID" | wc -l) | |
if [ "$TABLE_UUID_CNT" != 1 ]; then | |
echo "ERROR: $KEYSPACE_DIR - $TABLE_UUID has to many results..., skipping" | |
continue | |
fi | |
echo "NEW_TABLE_DIR = $KEYSPACE_DIR/$TABLE_UUID/" | |
TABLE_CNT=$(ls $MOVE_FROM | grep -v .json | wc -l) | |
if [ "$TABLE_CNT" == "0" ]; then | |
echo "TBL_CNT of $MOVE_FROM == 0. Skipping." | |
continue | |
fi | |
echo "move command = mv $MOVE_FROM/* $KEYSPACE_DIR/$TABLE_UUID/" | |
mv $MOVE_FROM/* $KEYSPACE_DIR/$TABLE_UUID/ | |
done <<< "$SNAPS" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment