Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/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