0% found this document useful (0 votes)
44 views

Cassandra Backup&restore

The document outlines the steps to backup and restore Cassandra data. It involves: 1. Creating a keyspace and table, and inserting sample data. 2. Backing up the schema and taking a snapshot to backup the data. 3. Dropping the keyspace to simulate data loss. 4. Restoring the schema from backup, copying the backed up data files, and refreshing the node to see the restored data.

Uploaded by

saran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
44 views

Cassandra Backup&restore

The document outlines the steps to backup and restore Cassandra data. It involves: 1. Creating a keyspace and table, and inserting sample data. 2. Backing up the schema and taking a snapshot to backup the data. 3. Dropping the keyspace to simulate data loss. 4. Restoring the schema from backup, copying the backed up data files, and refreshing the node to see the restored data.

Uploaded by

saran
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

CASSANDRA BACKUP AND RESTORE

STEP 1: Launch the Cassandra shell, create a keyspace, table, and insert the
data.

CREATE KEYSPACE insta WITH replication = {'class':'SimpleStrategy', 'replication_factor' : 3};


use insta;
CREATE TABLE stock( symbol varchar PRIMARY KEY, description varchar, exchange varchar);
insert into stock(symbol, description, exchange) values ('AAA', 'XXXXX', 'AP');
insert into stock(symbol, description, exchange) values ('BBB', 'YYYYY', 'TN');
insert into stock(symbol, description, exchange) values ('CCC', 'ZZZZZ', 'KA');
insert into stock(symbol, description, exchange) values ('DDD', 'YYYYY', 'BR');

Step 2: Create a backup schema backup using this command.


cqlsh -e 'desc keyspace insta' > schema_insta.cql
Step 3: View the schema using cat command
cat schema_insta.cql

Step 4: check this directory , By default this directory is empty.


cd /var/lib/Cassandra/data/insta

Step 5: Create a Data backup using snapshot command and check this directory;
now backup files are available.
nodetool snapshot insta
Step 6: Check the snapshots, using this command.
nodetool listsnapshots

Step 7: Now go to cqlsh shell, drop the insta keyspace.


cqlsh
drop keyspace insta;

Step 8: Check the keyspaces;


describe keyspaces;

Step 9: Change schema directory, else you will get permission error.
cp schema_insta.cql /tmp/
Step 10: Get backup form the source file, using command.
source ‘/tmp/schema_insta.cql’;
describe keyspace;
use insta:
describe table;

Step 11: Now check this directory, two folders are available, one folder is
previous backup folder, another one is new keyspace folder this folder is empty
folder.

Step 12: Copy the data backup file in to new directory

cp /var/lib/cassandra/data/insta/stock-
6b8ec1b0070911eba29abf08e5a68515/snapshots/1601902597924/*.*
/var/lib/cassandra/data/insta/stock-79df8ae0070b11eba29abf08e5a68515/
Step 13: Check the directory, files will available there.

Step: 14: Now launch the cqlsh shell, then check the data., still data not updated
cqlsh
use insta;
select * from stock;

Step 15: Refresh the node using this command.


nodetool refresh insta stock
Step 16: Now check the data using select command.
select * from stock;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy