> For the complete documentation index, see [llms.txt](https://rc.sunbird.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://rc.sunbird.org/use/developer-guide/backup-and-restore/cassandra.md).

# Cassandra

SSTables live under the keyspace directory (default `/var/lib/cassandra/data/`), per the path in `cassandra.yaml`.

## Backup

{% tabs %}
{% tab title="Snapshot-based" %}
Via `nodetool snapshot`, which flushes memtables and hard-links SSTables.

```bash
nodetool snapshot                                  # all keyspaces
nodetool snapshot -t 2023.06.27 organization       # one keyspace, named
nodetool snapshot --table employee organization    # one table
```

Transfer snapshots off-box (S3, GCS, Azure) afterward. `nodetool clearsnapshot` removes them locally.

{% hint style="warning" %}
Snapshots don't back up the schema — do that separately.
{% endhint %}

* *Advantages*: simple, easy to manage.
* *Disadvantages*: daily full-keyspace snapshots don't scale well for large datasets; transfer to cold storage can get expensive.
  {% endtab %}

{% tab title="Incremental" %}
Set `incremental_backups: true` in `cassandra.yaml`. Cassandra then hard-links newly-flushed SSTables into a backup directory as they're written, on top of the last full snapshot.

* *Advantages*: lower disk usage, lower transfer cost.
* *Disadvantages*: Cassandra doesn't clean these up automatically (you need your own pruning script); produces many small files; can't selectively back up individual column families.
  {% endtab %}
  {% endtabs %}

## Data Restore

{% tabs %}
{% tab title="nodetool refresh" %}
Loads newly-placed SSTables without a restart.

1. Create the schema if missing
2. Truncate the table if needed
3. Copy the snapshot's SSTable directory into place
4. Run `nodetool refresh`
   {% endtab %}

{% tab title="sstableloader" %}
Loads a set of SSTables into a running cluster — works for external data, existing SSTables, or snapshot restores:

```bash
sstableloader -d <ip> /home/data
```

Create the schema and truncate the table first if needed.
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://rc.sunbird.org/use/developer-guide/backup-and-restore/cassandra.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
