· 9 years ago · Jan 18, 2017, 11:54 PM
1#!/bin/bash
2while ! nc -z localhost 7199; do
3 echo "Waiting for Cassandra to start..."
4 sleep 1
5done
6echo "Cassandra is ready."
7sleep 60 && cqlsh -e "CREATE KEYSPACE IF NOT EXISTS platform WITH REPLICATION = {'class': 'SimpleStrategy', 'replication_factor': 3};"
8cqlsh -e "CREATE TABLE IF NOT EXISTS platform.users (
9 userid uuid PRIMARY KEY,
10 first_name text,
11 last_name text
12)"
13cqlsh -e "INSERT INTO platform.users (userid, first_name, last_name) VALUES (uuid(), 'Walter', 'Sobchack')"
14if $BACKUP -eq true; then
15 echo 'start tablesnap'
16 sleep 60 && tablesnap -k aws_cred -s aws_key -r -a --listen-events IN_CLOSE_WRITE weedmaps-cassandra-backups-dev /var/lib/cassandra/data/platform/
17 echo 'tablesnap running...'
18else
19 echo 'backups not enabled...'
20fi