Cassandra CQL exporter with SSL and truststore

Cassandra CQL exporter with SSL and truststore

Cassandra allows you to do backups using nodetool snapshot command.

But, this snapshot is not stored in .CQL format (which lists actual CQL commands just as you'd type them via CQL command line)

I came around this great exporter:

You can use it as specified in README file, but it doesn't mention anything if you're using SSL connection to connect to cassandra.

After studying the source code, it handes special parameter "-secure", which is not specified in README file.

CQL exporter has it's

which contains:

java -jar cql-generator.1.0.jar "$@"

But, to let java recognize the SSL settings, you need to pass the and parameters.

with OpenJDK openjdk version "1.8.0_242" OpenJDK Runtime Environment (AdoptOpenJDK)(build 1.8.0_242-b08) OpenJDK 64-Bit Server VM (AdoptOpenJDK)(build 25.242-b08, mixed mode)

specifying these parameters just via JAVA_OPTS does not work! (see:

so, you need to modify it manually in

export JAVA_OPTS=""
java $JAVA_OPTS -jar cql-generator.1.0.jar "$@"

great. so now, let's run the with the hidden "secure" parameter to make sure the SSL works:

./ -secure -h -k my_keyspace

This approach can be used to do backups which can be easily understood and restored if some part of it is needed.

You can also use it to migrate your data to ScyllaDB, which should understand the universal CQL files.


Trying connect to host ""
Trying connect to port "9042" 
Trying connect to keyspace "my_keyspace"
All good!
Start exporting...
Write DDL to ~/export/my_keyspace.CQL
Extract from my_keyspace.mytable
Total number of record: 34244
Start write "mytable" data DML to ~/export/my_keyspace.CQL
Done 0.00%
Done 20.00%
Done 40.00%
Done 60.00%
Done 79.99%
Done 99.99%
Done exporting "mytable", total number of records exported: 36296
Export completed after 23.97 s!

To run backup of all keyspaces :

for i in `cqlsh --ssl $CASSANDRA_IP --connect-timeout=10000 -e "describe keyspaces;" | tr '\n' ' '`
        ./ -secure -h $CASSANDRA_IP -k $i

That's it! Enjoy !


Related Posts