Bringing together the Apache Cassandra experts from the community and DataStax.

Want to learn? Have a question? Want to share your expertise? You are in the right place!

Not sure where to begin? Getting Started

 

question

premuditha_185831 avatar image
premuditha_185831 asked ·

How to restore Cassandra snapshot to a different keyspace name

I'm running a multi-cluster Cassandra setup in the Production environment and I want to create a new environment for Staging.


I managed to create a snapshot of the Production Cassandra databases and restore successfully to the Staging environment. But I'm not sure how to change the Keyspace name when restoring a snapshot.


E.g: if the production Cassandra keyspace is "foo_prod", I want to create a snapshot of this and restore to new keyspaces named "foo_staging", "foo_dev", "foo_testing"

cassandrabackuprestoresnapshot
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Erick Ramirez avatar image
Erick Ramirez answered ·

@premuditha_185831 If you previously restored the snapshot using sstableloader , you can effectively do the same thing except you would place the snapshot files in a different directory structure. For example, if you want to restore a table named mytable to a keyspace foo_staging:

  • create the keyspace foo_staging in the destination cluster
  • create the table schema
  • create a new snapshot directory structure with the new keyspace name, for example /path/to/snapshots/foo_staging/mytable
  • copy the snapshots to the new directory foo_staging/mytable/

Load the data as follows:

$ sstableloader -d node_ip1,node_ip2 /path/to/snapshots/foo_staging/mytable

Let us know if you have any follow up questions. Cheers!

Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

sebastien.fouquette_160564 avatar image
sebastien.fouquette_160564 answered ·

Hello,

I v found an interesting link: https://stackoverflow.com/questions/40548750/restore-cassandra-snapshot-to-new-keyspace-in-same-cluster

Just being tested in my lab .

Regards

Sébastien

1 comment Share
10 |1000 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Thanks @sebastien.fouquette_160564. It's effectively a variation of the method I proposed with the exception that the procedure you linked is for restoring snapshots to the same cluster. @premuditha_185831 has a different requirement -- restore snapshots from a production cluster to various non-production clusters. Cheers!

0 Likes 0 · ·