3
votes

I need to export my keyspace to a .cql file. I have tried the cqlsh -e "DESC keyspace demo" > dump.cql command but that doesnt work and i need the Insert scripts also.

I also tried the COPY command but it doesnt serve my purpose. I also want to be able to import from the cql file.

2

2 Answers

3
votes

The following works for me on a 3.0 install:

cqlsh -e 'DESCRIBE keyspace demo' > dump.cql    - gets the create syntax
cqlsh < dump.cql    - creates the keyspace on a new cluster
0
votes

You can use sstable2json and json2sstable cassandra tools

Check out Datastax documentation on the same and this too

Usage: sstable2json [-f outfile] <sstable> [-k key [-k key [...]]]
Usage: json2sstable -K keyspace -c column_family <json> <sstable>

Desc Keyspace will export only keyspace schema. If you want to export data also you have to use following utility.