Someone accidentally deleted several records from Cassandra's table in the cluster. I want to restore the last snapshot to another copy table with the same structure within the cluster.
What is the best way to do that?
Cassandra v4.0.4
Someone accidentally deleted several records from Cassandra's table in the cluster. I want to restore the last snapshot to another copy table with the same structure within the cluster.
What is the best way to do that?
Cassandra v4.0.4
You could use SSTABLELOADER or NODETOOL IMPORT. Documentation for those sources are below.
https://cassandra.apache.org/doc/4.1/cassandra/operating/bulk_loading.html#using-sstableloader
https://cassandra.apache.org/doc/4.1/cassandra/operating/bulk_loading.html#using-nodetool-import
I've previously documented steps on how to clone snapshots to another cluster in How do I restore Cassandra snapshots to another cluster with identical configuration?. The procedure for cloning a snapshot to a new table is pretty much identical using the "refresh" method.
The high level steps are:
STEP 1 - Create the table with a new name using the schema file in the snapshot.
STEP 2 - On the first node, copy the contents of the snapshot directory to the corresponding data directory of the destination table.
STEP 3 - Force Cassandra to load the copied SSTables from disk with:
$ nodetool import -- ks_name new_table_name
STEP 4 - Check the Cassandra system.log to verify that the new SSTables were opened.
STEP 5 - Repeat steps 2 to 4 on the next node until all nodes are done.
See the background information and additional details in the post I linked above. Cheers!
Thank you for your reply, @Erick .
I experimented with your recommendation, putting it to the test using two tables I constructed with identical structures edi_test_keyspace.t1 and edi_test_keyspace.t1_copy .
I inserted a few records to t1, and then I truncated the t1 table (in order to create an automated snapshot).
I copied the files from the truncated snapshot t1 directory to the corresponding data directory of t1_copy table
Then I ran the command nodetool import edi_test_keyspace t1_copy but I got the following error nodetool: import requires keyspace, table name and directories See 'nodetool help' or 'nodetool help <command>.'
the command works only after I specify the t1_copy directory path nodetool import edi_test_keyspace t1_copy /data/cassandra/edi_test_keyspace/t1_copy-d0659b50ffd911ee9b3c6bc1eefe57b6