nodetool snapshot

Take a snapshot of one or more keyspaces, or of a table, to backup data.

Take a snapshot of one or more keyspaces, or of a table, to backup data.

Synopsis

nodetool <options> snapshot
     ( -cf <table> | --column-family <table> )
     (-kc <ktlist> | --kc.list <ktlist> | -kt <ktlist> | --kt-list <ktlist>)
     ( -t <tag> | --tag <tag> )
   -- ( <keyspace> ) | ( <keyspace> ... )
  • Options are:
    • ( -h | --host ) <host name> | <ip address>
    • ( -p | --port ) <port number>
    • ( -pw | --password ) <password >
    • ( -u | --username ) <user name>
    • ( -pwf <passwordFilePath | --password-file <passwordFilePath> )
  • -cf, or --column-family, followed by the name of the table to be backed up.
  • -kc, --kc.list, -kt, or --kt-list, followed by a list of keyspace.table names to be back up, ktlist.
  • -t or --tag, followed by the snapshot name.
  • -- separates an option and argument that could be mistaken for a option.
  • keyspace is a single keyspace name that is required when using the -cf option
  • keyspace_list is one or more optional keyspace names, separated by a space.

Description

Use this command to back up data using a snapshot. See the examples below for various options.

Cassandra flushes the node before taking a snapshot, takes the snapshot, and stores the data in the snapshots directoryof each keyspace in the data directory. If you do not specify the name of a snapshot directory using the -t option, Cassandra names the directory using the timestamp of the snapshot, for example 1391460334889. Follow the procedure for taking a snapshot before upgrading Cassandra. When upgrading, backup all keyspaces. For more information about snapshots, see Apache documentation.

Example: All keyspaces

Take a snapshot of all keyspaces on the node. On Linux, in the Cassandra bin directory, for example:

nodetool snapshot

The following message appears:

Requested creating snapshot(s) for [all keyspaces] with snapshot name [1391464041163]
Snapshot directory: 1391464041163

Because you did not specify a snapshot name, Cassandra names snapshot directories using the timestamp of the snapshot. If the keyspace contains no data, empty directories are not created.

Example: Single keyspace snapshot

Assuming you created the keyspace cycling, take a snapshot of the keyspace and name the snapshot 2015.07.17.

nodetool snapshot -t 2015.07.17 cycling

The following message appears:

Requested creating snapshot(s) for [cycling] with snapshot name [2015.07.17]
Snapshot directory: 2015.07.17
Assuming the cycling keyspace contains two tables, cyclist_name and upcoming_calendar, taking a snapshot of the keyspace creates multiple snapshot directories named 2015.07.17. A number of .db files containing the data are located in these directories. For example, from the installation directory:
cd data/data/cycling/cyclist_name-a882dca02aaf11e58c7b8b496c707234/snapshots/2015.07.17
$ ls
la-1-big-CompressionInfo.db  la-1-big-Index.db       la-1-big-TOC.txt
la-1-big-Data.db             la-1-big-Statistics.db  la-1-big-Digest.adler32
la-1-big-Filter.db           la-1-big-Summary.db  manifest.json
 cd data/data/cycling/cyclist_name-a882dca02aaf11e58c7b8b496c707234/snapshots/2015.07.17
la-1-big-CompressionInfo.db  la-1-big-Index.db       la-1-big-TOC.txt
la-1-big-Data.db             la-1-big-Statistics.db  la-1-big-Digest.adler32
la-1-big-Filter.db           la-1-big-Summary.db  manifest.json

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
Cassandra creates the snapshot directory named 1391461910600 that contains the backup data of cyclist_name table in data/data/cycling/cyclist_name-a882dca02aaf11e58c7b8b496c707234/snapshots, for example.

Example: List of different keyspace.tables snapshot

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. The keyspace.table list should be comma-delimited 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