nodetool snapshot
Backs up data and table schemas.
Always run |
Synopsis
nodetool options snapshot
( -cf table_name | --column-family table_name )
(-kc ktlist | --kc.list ktlist | -kt ktlist | --kt-list ktlist)
(-sf | --skip-flush)
(-t tag | --tag tag )
-- ( keyspace_name | keyspace_name ... )
Tarball and Installer No-Services path:
<installation_location>/resources/cassandra/bin
Short | Long | Description | ||
---|---|---|---|---|
|
|
Hostname or IP address. |
||
|
|
Port number. |
||
|
|
Password file path. |
||
|
|
Password. |
||
|
|
Remote JMX agent username. |
||
|
|
Name of the table to snapshot. You must specify one and only one keyspace. |
||
|
Name of the table to snapshot. You must specify one and only one keyspace. |
|||
|
|
Comma separated list of keyspace_name.table_name with NO spaces.
For example, |
||
|
|
Comma separated list of keyspace_name.table_name with NO spaces.
For example, |
||
|
|
Executes the snapshot without flushing the tables first. |
||
|
|
Name for the snapshot directory
|
||
keyspace |
One or more optional keyspace names, separated by a space. Default: all keyspaces |
|||
|
Separates an option from an argument that could be mistaken for an option. |
Description
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 if needed, or you can leave them in place.
Restoring from a snapshot requires the table schema. |
The snapshot directory path is data/keyspace_name/table-UID/snapshots/snapshot_name
.
Data is backed up into multiple .db
files and table schema is saved to schema.cql
.
Before upgrading, DataStax Enterprise (DSE) backs up all keyspaces. See taking a snapshot. |
Example: All keyspaces
Take a snapshot of all keyspaces on the node:
nodetool snapshot
A message displays with the name of the snapshot directory:
Requested creating snapshot(s) for [all keyspaces] with snapshot name [1489076973698] and options {skipFlush=false}
Snapshot directory: 1489076973698
Example: Single keyspace snapshot
Assuming you created the keyspace cycling, took a snapshot of the keyspace and named the snapshot cycling_2017-3-9.
:
nodetool snapshot -t cycling_2017-3-9 cycling
The following output appears:
Requested creating snapshot(s) for [cycling] with snapshot name [2015.07.17]
Snapshot directory: cycling_2017-3-9
Assuming the cycling keyspace contains two tables, cyclist_name
and upcoming_calendar
, taking a snapshot of the keyspace creates multiple snapshot directories named cycling_2017-3-9
.
A number of .db
files containing the data are located in these directories as well table schema.
For example, from the installation directory:
ls -1 data/cycling/cyclist_name-9e516080f30811e689e40725f37c761d/snapshots/cycling_2017-3-9
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
Example: Multiple keyspaces snapshot
Assuming you created a keyspace named mykeyspace in addition to the cycling keyspace, take a snapshot of both keyspaces.
nodetool snapshot mykeyspace cycling
The following message appears:
Requested creating snapshot(s) for [mykeyspace, cycling] with snapshot name [1391460334889]
Snapshot directory: 1391460334889
Example: Single table snapshot
Take a snapshot of only the cyclist_name
table in the cycling keyspace.
nodetool snapshot --table cyclist_name cycling
Requested creating snapshot(s) for [cycling] with snapshot name [1391461910600]
Snapshot directory: 1391461910600
DSE creates the snapshot directory named 1391461910600
that contains data files and the schema of cyclist_name
table in data/cycling/cyclist_name-a882dca02aaf11e58c7b8b496c707234/snapshots
.
Example: Multiple tables in different keyspaces
Take a snapshot of several tables in different keyspaces, such as the cyclist_name
table in the cycling keyspace and the sample_times
table in the test keyspace.
List tables in a comma separate list with no spaces.
nodetool snapshot -kt cycling.cyclist_name,test.sample_times
Requested creating snapshot(s) for [cycling.cyclist_name,test.sample_times] with snapshot name [1431045288401]
Snapshot directory: 1431045288401