Teamwork Cloud 18.5 SP3 Documentation

Skip to end of metadata
Go to start of metadata

This page provides the instructions and the scripts required to back up and restore Cassandra database. These backup and restore scripts are same for both Windows and Linux Operating Systems. But on Windows, you should use the Cygwin tool to run the scripts (https://cygwin.com/install.html).

For Windows, to make a backup data or to restore Cassandra database, you must add the Cassnadra bin folder to PATH variable, so that you can access the nodetool without having to change directory to the folder that contains it. You can do this by adding the folder, C:\Program Files\DataStax Community\apache-cassandra\bin to Path variable. Please note that if you install Cassandra on different location, you need to change this value accordingly.

For detailed information about backup and restore operation, click the following link http://docs.datastax.com/en/cassandra/2.0/cassandra/operations/ops_backup_restore_c.html.
You need to change the Cassandra username and password values in the scripts otherwise the default values will be used for authentication.

Backup and restore scripts

To backup and restore Cassandra database, you need the following files. Click the file to download it.

backup.sh 

restore-single_node.sh

 

 

backup.sh

This script creates snapshots of Cassandra database. The script must run on the host running Cassandra and Cassandra must be running. The Cassandra bin directory or nodetool must be added to $PATH (not required if DataStax Cassandra is installed). The backup script preserves the database file permissions and owner.

$ ./backup.sh

Asks for Cassandra database and where to store the backup file, flushes data to disk, makes snapshots of Cassandra, then archives and puts them to a specified directory. After that it will clear the snapshots from the database. 

$ ./backup.sh -dir CASSANDRA_DB_PATH

Asks Cassandra where to store the backup file, flushes data to disk, makes snapshots of Cassandra, then archives the snapshots from CASSANDRA_DB_PATH and puts them to a specified directory. After that it will clear the snapshots from the database.

$ ./backup.sh -dir CASSANDRA_DB_PATH -rf PUT_ARCHIVE_DIR

Flushes data to disk, makes snapshot of Cassandra, then archives snapshots from CASSANDRA_DB_PATH and puts them to PUT_ARCHIVE_DIR. After that it will clear the snapshots from the database.

restore-single_node.sh

This script should be run with 'su' on Linux and Cygwin console must be launched with the administrator privileges. This script restores data from the backup file. While restoring Cassandra, TWCloud server must be turned off. The script stops and starts Cassandra if needed. The backup script preserves the database file permissions and owner, and then restores backup on another machine with another user. Therefore, the file permissions must be changed manually otherwise Cassandra may not start. The following variables may be passed onto the script:

 
VariableDescription
commitlog_pathThe path of commitlog files. They are removed when restoring database to prevent recovery of commits made earlier. DataStax recommends to store the commitlog files in a separate hard-disk for performance sake.
cassandra_databaseThe Cassandra database path. It is used to clean existing database and restoring database from the recovery file.
cassandraThe Cassandra installation path. It is the required parameter when Cassandra is launched not as service.
serviceThe Boolean parameter indicating that Cassandra is started as a service. The default value is true so you need to set this variable to false when Cassandra is launched by the other script or manually.
rfThe recovery file with the full path to it.


On Linux

Type:

$ su ./restore-single_node.sh


On Windows

Use the Cygwin tool and type:

$ ./restore-single_node.sh

 

The following are some other examples for Linux (just remove 'su' parameter on Cygwin).

$ cassandra_database=<cassandra_database_path> commitlog_path=<cassandra_commitlog_path> rf=<backup_file_to_restore> su ./restore-single_node.sh
$ cassandra_database=/var/lib/cassandra commitlog_path=/var/lib/cassandra/commitlog rf=/home/<user>/backups/cassandra_backup_2016.07.29.12.23.24.tar su ./restore-single_node.sh
or parameters can be set(please note that order maters). i.e. :
$ su  ./restore-single_node.sh -dir <cassandra_database_path> -commitlog <cassandra_commitlog_path> -rf <backup_file_to_restore>
$ su  ./restore-single_node.sh -dir /var/lib/cassandra -commitlog /var/lib/cassandra/commitlog -rf /home/<user>/backups/cassandra_backup_2016.07.29.12.23.24.tar

 

If Cassandra is not running as service, set the variable service to false. See the following example.

$ service=false su ./restore-single_node.sh

 

You will be then asked to enter the following information.

Please enter Cassandra database directory. i.e. /var/lib/cassandra:
Please enter Cassandra commitlog directory. i.e. /var/lib/cassandra/commitlog:
Please enter Cassandra home directory. i.e. /opt/cassandra-2.2.5:
Please enter backup file location. i.e. /home/<user>/backups/:
or parameters can be set(please note that order maters). i.e. :
$ su service=false ./restore-single_node.sh -dir <cassandra_database_path> -commitlog <cassandra_commitlog_path> -rf <backup_file_to_restore> -cassandra=<cassandra_home>
$ su service=false ./restore-single_node.sh -dir /var/lib/cassandra -commitlog /var/lib/cassandra/commitlog -rf /home/<user>/backups/cassandra_backup_2016.07.29.12.23.24.tar -cassandra=/opt/apache-cassandra-2.2.5
 

 

  • No labels