This page provides instructions for cold and hot backups, and the scripts required to perform hot backup and restore of the Cassandra database. These backup and restore scripts are the 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 back up data or to restore Cassandra database, you must add the Cassandra bin folder to the PATH variable, so that you can access the nodetool utility without having to change directory to the folder that contains it. If you installed Cassandra to its default location, this folder will be C:\Program Files\apache-cassandra-3.11.2\bin. Please note that if you install Cassandra in a different location, you need to change this value accordingly.
Cold Backup/Restore
A cold backup is a backup taken via regular system backups, while the database is shut down in a consistent state. Once the database is shut down in a consistent state, we back up the directories pointed to by the data_file_directories and commitlog_directory values in your cassandra.yaml file.
Backup procedure consists of:
- Stop the Teamwork Cloud service
- Stop the Authserver service
- Stop the WebApp service
- Commit all the data to disk by issuing the "nodetool drain" command
- Stop the Cassandra service
- Perform the backup (this can be a VM snapshot, a backup of the specified directories using any backup software, or copying the directories to another location)
- Start the Cassandra service
- Start the Teamwork Cloud service
- Start the Authserver service
- Start the WebApp service
Restore procedure consists of:
- Stop the Teamwork Cloud service
- Stop the Authserver service
- Stop the Cassandra service
- Stop the WebApp service
- Delete the data_file_directories and commitlog_directory
- Restore the data from the backup to the original location
- Start the Cassandra service
- Start the Teamwork Cloud service
- Start the Authserver service
- Start WebApp service
Hot Backups
Backups
Hot backups are backups which are taken while the database is running, therefore eliminating the need for downtime. This is accomplished by using Cassandra's internal ability to perform a snapshot of the database. The backup process consists of flushing data to disk, stopping any compactions which may be taking place, creating a snapshot (the snapshot creates a set of hard links to the current immutable files), archiving the state of the immutable files to a backup location, and clearing the snapshots directories created in the database. For disaster recovery, this directory should be located on a different physical drive than where the data resides. Each snapshot will consume approximately the same amount of space as the data directory. The backup script does not perform any directory maintenance or purging. This can be done either by using a wrapper script which will delete the current backup before creating the new snapshot, or by a scheduled task which is to be executed before the backup. If point in time recovery is desired, the backup directory can be backed up as part of the regular backup procedures for the server.
When backing up a cluster, all nodes must be backed up individually, preferably at the same time. Also, on a cluster, it is imperative that the clocks on all machines be synchronized.
Hot backups should be executed at a time when there is no client activity, in order to ensure model consistency. If you cannot be sure that there is no client traffic at the time of the snapshot, please stop the Teamwork Cloud service momentarily. Once the “nodetool snapshot” command has completed, you can restart the Teamwork Cloud service. |
Restore
The restore procedure will stop the Cassandra database, delete the commit logs and the data files in the repository, restore the snapshot files and relocate them back to their source directories. Once this is done, Cassandra will be started and the nodetool utility will be invoked to repair the keyspaces.
When restoring a cluster, all nodes must be restored from their individual backups (backups taken at the same time). You must first stop the Teamwork Cloud, authserver, and Cassandra service on each of the nodes. Once the Cassandra nodes are off, proceed to restore the seed node. Once you have completed the restoration of the seed node, proceed to restore the second node. Upon completion of the second node, restore the third node. During the restoration process of the first 2 nodes, you may receive an error from the keyspace repair process - this is normal since some of the nodes have not joined the cluster. The last node to be restored will take care of the keyspace repairing process.
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_311.sh