Cassandra Snapshot running on kubernetes

3/9/2018

I'm using Kubernetes (via minikube) to deploy my Lagom services and my Cassandra DB.

After a lot of work, I succeed to deploy my service and my DB on Kubernetes.

Now, I'm about to manage my data and I need to generate a backup for each day.

Is there any solution to generate and restore a snapshot (Backup) for Cassandra running on Kubernetes:

cassandra statefulset image:

gcr.io/google-samples/cassandra:v12

Cassandra node:

svc/cassandra                     ClusterIP      10.97.86.33      <none>        9042/TCP                     1d

Any help? please.

-- Imen
cassandra
kubernetes
minikube

1 Answer

3/9/2018

https://docs.datastax.com/en/cassandra/3.0/cassandra/operations/opsBackupRestore.html

That link contains all the information you need. Basically you use nodetool snapshot command to create hard links of your SSTables. Then it's up to you to decide what to do with the snapshots.

I would define a new disk in the statefulset and mount it to a folder, e.g. /var/backup/cassandra. The backup disk is a network storage. Then I would create a simple script that:

  1. Run 'nodetool snapshot'
  2. Get the snapshot id from the output of the command.
  3. Copy all files in the snapshot folder to /var/backup/cassandra
  4. Delete snapshot folder

Now all I have to do is make sure I store the backups on my network drive somewhere else for long term.

Disclaimer. I haven't actually done this so there might be a step missing but this would be the first thing I would try based on the Datastax documentation.

-- Simon Fontana Oscarsson
Source: StackOverflow