Take a snapshot
Snapshots are taken per node using the nodetool snapshot command.
To take a global snapshot, run the command with a parallel SSH utility, such as pssh.
A snapshot first flushes all in-memory writes to disk, then makes a hard link of the SSTable files for each keyspace. You must have enough free disk space on the node to accommodate making snapshots of your data files. A single snapshot requires little disk space. However, snapshots can cause your disk usage to grow more quickly over time because a snapshot prevents old obsolete data files from being deleted. After the snapshot is complete, you can move the backup files to another location, or you can leave them in place.
-
Run
nodetool cleanupto ensure that invalid replicas are removed:nodetool cleanup cycling -
Run the
nodetool snapshotcommand, specifying the keyspace to snapshot and any necessary connection options, such as the hostname or JMX port.For example:
nodetool snapshot -t cycling_2017-3-9 cyclingFor tarball installations, you must run this command from the
INSTALL_DIRECTORY/resources/cassandra/bindirectory. -
Get the
Snapshot directoryfrom the output:Requested creating snapshot(s) for [cycling] with snapshot name [2015.07.17] and options {skipFlush=false} Snapshot directory: cycling_2017-3-9The
Snapshot directoryis the name of a subdirectory containing the snapshot files. The complete path to the snapshot directory is/data/KEYSPACE_NAME/TABLE_NAME-UUID/snapshots/SNAPSHOT_NAME.If the keyspace contains multiple tables, the snapshot process creates multiple snapshot directories with the given
Snapshot directoryname. For example, the following path is for a table namedcyclist_namein thecyclingkeyspace:data/cycling/cyclist_name-9e516080f30811e689e40725f37c761d/snapshots/cycling_2017-3-9 -
To restore from a snapshot, get the table schema file from the snapshot directory.
Within each snapshot directory, there are multiple data files with the extension
.dband aschema.cqlfile that contains the full CQL statement to create the table. For example:manifest.json mc-1-big-CompressionInfo.db mc-1-big-Data.db mc-1-big-Digest.crc32 mc-1-big-Filter.db mc-1-big-Index.db mc-1-big-Statistics.db mc-1-big-Summary.db mc-1-big-TOC.txt schema.cql