nodetool snapshot
Creates a backup by taking a snapshot of table data. A snapshot is a hardlink to the SSTable files in the data directory for a schema table at the moment the snapshot is executed. For more, see Taking a snapshot.
The snapshot directory path is: data/<keyspace_name>/<table-UUID>/snapshots/<snapshot_name>.
Data is backed up into multiple .db files and table schema is saved to schema.cql.
The schema.cql file captures the structure of the table at the time of snapshot.
Restoring the snapshot requires the table to have the same structure.
See Manual Backup and Restore with Point-in-time and table-level restore.
|
Always run Before upgrading DataStax Enterprise (DSE), create a backup of all keyspaces. |
Synopsis
nodetool [<connection_options>] snapshot
[--table <table_name> | -kt keyspace_name.table_name,...]
[-sf] [-t <snapshotname>] [--]
[<keyspace_name> [<keyspace_name>...]]
| Syntax conventions | Description |
|---|---|
Italic, bold, or |
Syntax diagrams and code samples use one or more of these styles to mark placeholders for variable values. Replace placeholders with a valid option or your own user-defined value. In CQL statements, angle brackets are required to enclose data types in a set, list, map, or tuple.
Separate the data types with a comma.
For example: In Search CQL statements, angle brackets are used to identify the entity and literal value to overwrite the XML element in the schema and |
|
Square brackets surround optional command arguments. Do not type the square brackets. |
|
Parentheses identify a group to choose from. Do not type the parentheses. |
|
A pipe separates alternative elements. Type any one of the elements. Do not type the pipe. |
|
Indicates that you can repeat the syntax element as often as required. |
|
Single quotation marks must surround literal strings in CQL statements. Use single quotation marks to preserve upper case. For Search CQL only: Single quotation marks surround an entire XML schema declaration, such as |
|
Map collection.
Curly braces enclose maps ( |
|
Ends a CQL statement. |
|
Separate command line options from command arguments with two hyphens. This syntax is useful when arguments might be mistaken for command line options. |
Options
If an option has a short and long form, both forms are given, separated by a comma.
- -h, --host hostname
-
The hostname or IP address of a remote node or nodes. When omitted, the default is the local machine.
- -p, --port jmx_port
-
The JMX port number.
- -pw, --password jmxpassword
-
The JMX password for authenticating with secure JMX. If a password is not provided, you are prompted to enter one.
- -pwf, --password-file jmx_password_filepath
-
The file path to the file that stores JMX authentication credentials.
- -u, --username jmx_username
-
The username for authenticating with secure JMX.
- --table, -cf, --column-family table_name
-
Table name in the specified keyspace.
- -kt, --kt-list, -kc, --kc.list keyspace_name.table_name,…
-
Comma-separated list of keyspace_name.table_name with no spaces after the comma.
Example:
cycling.cyclist,basketball.players - -sf, --skip_flush
-
Do not flush tables before creating the snapshot.
Snapshot will not contain unflushed data.
- -t snapshotname, --tag snapshotname
-
The path to the directory where you want to create the snapshot.
When not specified, the current time is used for the directory name. For example,
1489076973698.
Examples
- Take snapshot of all keyspaces on the node
-
Run
nodetool cleanupbefore taking the snapshot:nodetool cleanupTake a snapshot of all keyspaces:
nodetool snapshotResults include the name of the snapshot directory:
Requested creating snapshot(s) for [all keyspaces] with snapshot name [1489076973698] and options {skipFlush=false} Snapshot directory: 1489076973698 - Create tagged snapshot of keyspace
-
Take tagged snapshot of
cyclingkeyspace in thecycling_2017-3-9directory:nodetool snapshot -t cycling_2017-3-9 cyclingRequested creating snapshot(s) for [cycling] with snapshot name [2015.07.17] and options {skipFlush=false} Snapshot directory: cycling_2017-3-9The
cyclingkeyspace contains two tables,cyclist_nameandupcoming_calendar. The snapshot creates multiple snapshot directories namedcycling_2017-3-9. A number of.dbfiles containing the data are located in these directories, along with table schema.For example, from the DSE installation directory:
ls -1 data/cycling/cyclist_name-9e516080f30811e689e40725f37c761d/snapshots/cycling_2017-3-9manifest.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 - Take snapshot of multiple keyspaces
-
Take snapshot of the
mykeyspaceandcyclingkeyspaces:nodetool snapshot mykeyspace cyclingRequested creating snapshot(s) for [mykeyspace, cycling] with snapshot name [1391460334889] and options {skipFlush=false} Snapshot directory: 1391460334889 - Take snapshot of single table
-
Take a snapshot of the
cyclist_nametable in thecyclingkeyspace:nodetool snapshot --table cyclist_name cyclingThe resulting snapshot directory
1391461910600contains data files and the schema ofcyclist_nametable indata/cycling/cyclist_name-a882dca02aaf11e58c7b8b496c707234/snapshots.Requested creating snapshot(s) for [cycling] with snapshot name [1391461910600] and options {skipFlush=false} Snapshot directory: 1391461910600 - Take snapshot of multiple tables in different keyspaces
-
Take a snapshot the
cyclist_nametable in thecyclingkeyspace and thesample_timestable in thetestkeyspace:nodetool snapshot -kt cycling.cyclist_name,test.sample_timesRequested creating snapshot(s) for [cycling.cyclist_name,test.sample_times] with snapshot name [1431045288401] and options {skipFlush=false} Snapshot directory: 1431045288401 - Create snapshot of keyspace without flushing tables
-
Take snapshot of
cyclingkeyspace with-sfoption:nodetool snapshot cycling -sfRequested creating snapshot(s) for [cycling.cyclist_name,test.sample_times] with snapshot name [1431045288401] and options {skipFlush=false} Snapshot directory: 1431045288401