Skip to content

Instantly share code, notes, and snippets.

@phact
Created May 24, 2019 19:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save phact/90717babb76a5f2d52b4d72c17b56ae5 to your computer and use it in GitHub Desktop.
Save phact/90717babb76a5f2d52b4d72c17b56ae5 to your computer and use it in GitHub Desktop.
#!/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