Is a there a command line tool or a simple script that can export/copy entire Cassandra database (tables and data) and then import somewhere else
To get the schema, you can use this:
cqlsh -e "DESCRIBE SCHEMA" > schema.cql
Regarding the data export, if you are just playing around, you might test the GitHub project that Mandraenke posted. But if you are doing this in a non-safe environment (production), I recommend AGAINST using that project. It's not safe, and they even wrote that on the project's page:
Disclaimer: most of the times, you really shouldn't be using this. It's fragile, non-scalable, inefficient and verbose.
The safest way is to write a script to output the data using the COPY
command, and iterating over the tables. Check this article which might be of help: https://www.datastax.com/dev/blog/simple-data-importing-and-exporting-with-cassandra
This article also explains how to import the data using the same command.
Alternatively, you can just copy the SSTable files to the new place where you want to set up the database and then use sstableloader: http://docs.datastax.com/en/cassandra/2.1/cassandra/tools/toolsBulkloader_t.html
Don't forget you will still need the schema, even if you go for the SSTable files solution.
Cassandra offers COPY
and DESCRIBE KEYSPACES
build in you can use for this. Also there are several projects on GitHub who are more user friendly, for example https://github.com/gianlucaborello/cassandradump - which is inspired by mysqldump.
But if you have a huge dataset this will take a really long time.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With