GithubHelp home page GithubHelp logo

phantacix / cassandra-snapshot-tools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from appliedinfrastructure/cassandra-snapshot-tools

0.0 1.0 0.0 621 KB

Create, move, and restore keyspace snapshots across Apache/Datastax Cassandra clusters

License: Apache License 2.0

Shell 100.00%

cassandra-snapshot-tools's Introduction

Cassandra Snapshot Tools Build Status

A handy couple of scripts that make creating, moving, and restoring SSTable snapshots between clusters easy. Some common use cases include:

  • Copying keyspaces between clusters (QA environments, for example)
  • Staging an upgrade (application, Cassandra, both) using a copy of live data
  • Seeding data in a test environment
  • Snapshotting a keyspace for offline analytics
  • Backup and restore
  • Generally moving a keyspace from one Cassandra cluster to another

Cassandra Snapshot Tools currently includes two BASH shell scripts, getSnapshot and putSnapshot, which leverage standard Cassandra utilities like nodetool, cqlsh, and sstableloader to simplify the process of creating snapshots and moving them between hosts. A convenient compressed tar archive is generated by getSnapshot, and includes all of the SSTable snapshot files, metadata, and schema information necessary to restore the keyspace into another Cassandra cluster (or the same cluster). The putSnapshot tool is then used to alter various attributes of the original snapshot, and restore into the destination Cassandra cluster.

Features

  • Automatically generates a keyspace snapshot and packages into an easy-to-move archive
  • Copies snapshots out of the Cassandra data directory, allowing space to be reclaimed using nodetool clearsnapshot
  • Archive a previously created snapshot (e.g. created manually using nodetool snapshot)
  • Schedulable using Cron (e.g. for scheduled backups)
  • Change keyspace name, datacenter name and replication factor on restore
  • Restore to local or remote clusters, either privately hosted or through hosted services like Datascale.io
  • Easy to use with sane defaults
  • Most Cassandra versions supported (tested against Cassandra 2.0, 2.1, 2.2, 3.0, and 3.7)

Usage

getSnapshot

Usage: ./getSnapshot -h
       ./getSnapshot -k <keyspace name> [-s <snapshot name>] [-y <cassandra.yaml file>] [--no-timestamp]
    -h,--help                          Print usage and exit
    -v,--version                       Print version information and exit
    -k,--keyspace <keyspace name>      REQUIRED: The name of the keyspace to snapshot
    -s,--snapshot <snapshot name>      The name of an existing snapshot to package
    -y,--yaml <cassandra.yaml file>    Alternate cassandra.yaml file
    --no-timestamp                     Don't include a timestamp in the resulting filename

putSnapshot

Usage: ./putSnapshot -h
       ./putSnapshot -f <snapshot file> [-n <node address>] [-k <new ks name>] [-d <new dc name>] [-r <new rf>] [-y <cassandra.yaml file>]
    -h,--help                          Print usage and exit
    -v,--version                       Print version information and exit
    -f,--file <snapshot file>          REQUIRED: The snapshot file name (created using the
                                       getSnapshot utility
    -n,--node <node address>           Destination Cassandra node IP (defaults to the local
                                       Cassandra IP if run on a Cassandra node, otherwise
                                       required in order to connect to Cassandra.  Will take
                                       precedence if provided and run on a Cassandra node
    -k,--keyspace <new ks name>        Override the destination keyspace name (defaults to
                                       the source keyspace name)
    -d,--datacenter <new dc name>      Override the destination datacenter name (defaults
                                       to the sourcen datacenter name)
    -r,--replication <new rf>          Override the destination replication factor (defaults
                                       to source replication factor)
    -y,--yaml <cassandra.yaml file>    Alternate cassandra.yaml file

Basic Examples

  1. Copy a keyspace to the same Cassandra cluster using a different keyspace name:

    $ getSnapshot -k <keyspace name>
    $ putSnapshot -f <snapshot package file> -k <new keyspace name>
  2. Copy a keyspace to a remote Cassandra cluster using the same keyspace name:

    $ getSnapshot -k <keyspace name>
    $ putSnapshot -f <snapshot package file> -n <destination node IP>
  3. Copy a keyspace from a Cassandra cluster to a remote cluster using a different keyspace name and replication factor:

    $ getSnapshot -k <keyspace name>
    $ putSnapshot -f <snapshot package file> -n <destination node IP> -k <new keyspace name> -r 1
  4. Copy a snapshot previously created using nodetool snapshot to a new keyspace:

    $ nodetool snapshot <keyspace name> -t <custom snapshot name>
    $ getSnapshot -k <keyspace name> -s <custom snapshot name>
    $ putSnapshot -f <snapshot package file> -k <new keyspace name>

Caveats

  • Currently supports snapshots/restores between clusters running similar versions of Cassandra.
  • Partitioner configuration (e.g. RandomPartitioner, Murmur3Partitioner, etc.) must be the same between source and destination Cassandra clusters.
  • Local access to the source Cassandra node is required (to create/collect snapshot files). Fairly open network access is required to the destination Cassandra node (to create the schema and load SSTables).

Contributing

All contributions welcome! Please see How to Contribute.

cassandra-snapshot-tools's People

Contributors

mikelaws avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.