Database Reference
In-Depth Information
Snapshots
The purpose of a snapshot is to make a copy of some or all of the keyspaces in a node and save
it to what is essentially a separate database file. This means that you can back up the keyspaces
elsewhere or leave them where they are in case you need to restore them later.
Taking a Snapshot
When you take a snapshot of one or more keyspaces, Cassandra delegates the call to the Table
class, which then calls the snapshot method on every column family. This just uses Java's file
facilities to create a copy of the SSTables. Note the implication here: if data exists only in the
commit log, it will notbe part of the snapshot. Only data that has been previously flushed will
be part of the snapshot, because the storage service basically performs a direct file copy.
NOTE
To perform a flush before taking a snapshot, see Flush .
Taking a snapshot is straightforward:
$ bin/nodetool -h 192.168.1.5 snapshot
This will print out in the server logs an indication that a snapshot has been taken:
DEBUG 14:25:15,385 Snapshot for Keyspace1 table data file
/var/lib/cassandra/data/Keyspace1/Standard2-1-Filter.db
created as /var/lib/cassandra/data/Keyspace1/snapshots/1277673915365/
Standard2-1-Filter.db
DEBUG 14:25:15,424 Snapshot for system table data file
/var/lib/cassandra/data/system/LocationInfo-9-Filter.db
created as /var/lib/cassandra/data/system/snapshots/1277673915389/
LocationInfo-9-Filter.d
Notice that the snapshot has been placed in a folder named for the timestamp at which it was
taken, in its own datafile ending with a .dbextension, like Cassandra's regular data tables. Here,
a snapshot has been taken for all of the keyspaces on the server, including Cassandra's internal
keyspace system .
If you want to specify only a single keyspace to take a snapshot of, you can pass it as an addi-
tional argument:
$ bin/nodetool -h 192.168.1.5 snapshot Keyspace1
Search WWH ::




Custom Search