Created
May 24, 2019 19:56
-
-
Save phact/90717babb76a5f2d52b4d72c17b56ae5 to your computer and use it in GitHub Desktop.
This file contains 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/bash | |
#this gnarly one liner will download dsbulk and download an entire keyspace worth of data into your local machine (assuming it fits!) | |
if [ -z "$CAS_HOST" ]; then | |
echo "Comma separated contact points (or set CAS_HOST environment variable):" | |
read CAS_HOST | |
fi | |
if [ -z "$KEYSPACE" ]; then | |
echo "Keyspace (or set KEYSPACE environment variable):" | |
read KEYSPACE | |
fi | |
if ! [ -f "./dsbulk-1.3.3/bin/dsbulk" ]; then | |
curl -OL https://downloads.datastax.com/dsbulk/dsbulk-1.3.3.tar.gz … && tar -xvf dsbulk-1.3.3.tar.gz && cqlsh $HOST -e "use $KEYSPACE; describe tables" | |
fi | |
cqlsh $DSE_HOST -e "use $KEYSPACE; describe tables" | xargs | sed 's/ /\n/g' | awk -F' ' '{print "./dsbulk unload --driver.hosts=$DSE_HOST -k=$KEYSPACE -t=" $1 " > " $1 ".csv" }' | bash |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment