Add cleanup_snaphots parameter
We need to have an option to enable cleanup of outdated snaphots
in cassandra data dir as it's meaningless to keep them on db node as
we're storing backups in specific BACKUPDIR and copy backups on
remote backup server.
Change-Id: I24e83ce5f10751a3e54192d5aa0fd864628f6270
Related-PROD: PROD-27054
diff --git a/README.rst b/README.rst
index f23e2b9..5bf4621 100644
--- a/README.rst
+++ b/README.rst
@@ -25,6 +25,7 @@
backup:
client:
enabled: true
+ cleanup_snaphots: true
full_backups_to_keep: 3
hours_before_full: 24
target:
@@ -43,6 +44,7 @@
backup:
client:
enabled: true
+ cleanup_snaphots: true
full_backups_to_keep: 3
hours_before_full: 24
containers:
@@ -59,6 +61,7 @@
backup:
client:
enabled: true
+ cleanup_snaphots: true
full_backups_to_keep: 3
hours_before_full: 24
@@ -73,6 +76,7 @@
backup:
client:
enabled: true
+ cleanup_snaphots: true
full_backups_to_keep: 3
incr_before_full: 3
backup_times:
diff --git a/cassandra/files/backup/cassandra-backup-client-runner-call.sh b/cassandra/files/backup/cassandra-backup-client-runner-call.sh
index 06ae68f..e507f56 100644
--- a/cassandra/files/backup/cassandra-backup-client-runner-call.sh
+++ b/cassandra/files/backup/cassandra-backup-client-runner-call.sh
@@ -138,6 +138,24 @@
# Cleanup
# ---------
+
+ {%- if backup.client.get('cleanup_snaphots', True) %}
+ echo "Cleanup old snapshots from cassandra data dir"
+
+ {%- if backup.client.containers is defined %}
+
+ {%- for container_name in backup.client.containers %}
+ docker exec {{ container_name }} nodetool -h $JMXIP clearsnapshot 2>&1
+ {%- endfor %}
+
+ {%- else %}
+
+ nodetool -h $JMXIP clearsnapshot 2>&1
+
+ {%- endif %}
+
+ {%- endif %}
+
if [ $SKIPCLEANUP = false ] ; then
{%- if backup.client.backup_times is not defined %}
echo "----------------------------"