Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CASSANDRA-16451 add ttl for snapshots #69

Open
wants to merge 5 commits into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 40 additions & 1 deletion src/doc/4.1/_sources/operating/backups.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ In this section including sub-sections we shall demonstrate creating snapshots.
-t <tag>, --tag <tag>
The name of the snapshot

--ttl <ttl in TimeUnit>
Set ttl of snapshot

-u <username>, --username <username>
Remote jmx agent username

Expand Down Expand Up @@ -378,7 +381,7 @@ To take snapshots of multiple tables that are in different keyspaces the command
Requested creating snapshot(s) for [catalogkeyspace.journal,cqlkeyspace.t] with snapshot
name [multi-ks] and options {skipFlush=false}
Snapshot directory: multi-ks

Listing Snapshots
***************************
To list snapshots use the ``nodetool listsnapshots`` command. All the snapshots that we created in the preceding examples get listed:
Expand All @@ -400,6 +403,42 @@ To list snapshots use the ``nodetool listsnapshots`` command. All the snapshots

Total TrueDiskSpaceUsed: 44.02 KiB

Expiring snapshots
++++++++++++++++++++++++++++++++++
It's possible to set a time-to-live (TTL) for created snapshot using the ``--ttl`` option, causing the snapshot to be automatically cleaned up when the TTL expires. TTL can be specified in minutes (m), seconds (s), hours (h) and days (d).

The example below shows the creation of a snapshot for all tables in the ``catalogkeyspace`` and ``cqlkeyspace`` keyspaces with a TTL of 3 minutes:

::

[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot
--tag catalog-cql-ks --ttl 3m catalogkeyspace cqlkeyspace
Requested creating snapshot(s) for [catalogkeyspace, cqlkeyspace] with snapshot
name [catalog-cql-ks] and options {skipFlush=false, ttl=3m}
Snapshot directory: catalog-cql-ks

now let's display information about snapshots:

::
[ec2-user@ip-10-0-2-238 ~]$ nodetool listsnapshots
Snapshot Details:
Snapshot name Keyspace name Column family name True size Size on disk Creation time Expiration time
catalog-cql-ks catalogkeyspace magazine 4,94 KiB 5,9 KiB 2021-08-23T20:52:01.344Z 2021-08-23T20:55:01.344Z
catalog-cql-ks catalogkeyspace journal 4,94 KiB 5,9 KiB 2021-08-23T20:52:01.368Z 2021-08-23T20:55:01.368Z
catalog-cql-ks cqlkeyspace t 0 bytes 951 bytes 2021-08-23T20:52:01.370Z 2021-08-23T20:55:01.370Z
catalog-cql-ks cqlkeyspace t2 0 bytes 952 bytes 2021-08-23T20:52:01.373Z 2021-08-23T20:55:01.373Z

Total TrueDiskSpaceUsed: 9,87 KiB

We see creation and expiration time.Let's wait couple of minutes and try again:

::
[ec2-user@ip-10-0-2-238 ~]$ nodetool listsnapshots
Snapshot Details:
There are no snapshots

Finally, these snapshots have expired.

Finding Snapshots Directories
******************************
The ``snapshots`` directories may be listed with ``find –name snapshots`` command:
Expand Down
41 changes: 40 additions & 1 deletion src/doc/4.1/operating/backups.html
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,9 @@ <h2>Snapshots<a class="headerlink" href="#snapshots" title="Permalink to this he
-t &lt;tag&gt;, --tag &lt;tag&gt;
The name of the snapshot

--ttl &lt;ttl in TimeUnit&gt;
Set ttl of snapshot

-u &lt;username&gt;, --username &lt;username&gt;
Remote jmx agent username

Expand Down Expand Up @@ -513,7 +516,6 @@ <h4>Taking Snapshot of Multiple Tables from Different Keyspaces<a class="header
</pre></div>
</div>
</div>
</div>
<div class="section" id="listing-snapshots">
<h3>Listing Snapshots<a class="headerlink" href="#listing-snapshots" title="Permalink to this headline">¶</a></h3>
<p>To list snapshots use the <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">listsnapshots</span></code> command. All the snapshots that we created in the preceding examples get listed:</p>
Expand All @@ -534,6 +536,43 @@ <h3>Listing Snapshots<a class="headerlink" href="#listing-snapshots" title="Perm
</pre></div>
</div>
</div>
<div class="section" id="expiring-snapshots">
<h4>Expiring snapshots<a class="headerlink" href="#providing-ttl-for-created-snapshot" title="Permalink to this headline">¶</a></h4>
<p>It's possible to set a time-to-live (TTL) for created snapshot using the <code class="docutils literal notranslate"><span class="pre">--ttl</span></code> option, causing the snapshot to be automatically cleaned up when the TTL expires. TTL can be specified in minutes (m), seconds (s), hours (h) and days (d). The example below shows the creation of a snapshot for all tables in the <code class="docutils literal notranslate"><span class="pre">catalogkeyspace</span></code> and <code class="docutils literal notranslate"><span class="pre">cqlkeyspace</span></code> keyspaces with a TTL of 3 minutes:
</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot
--tag catalog-cql-ks --ttl 3m catalogkeyspace cqlkeyspace
Requested creating snapshot(s) for [catalogkeyspace, cqlkeyspace] with snapshot
name [catalog-cql-ks] and options {skipFlush=false, ttl=3m}
Snapshot directory: catalog-cql-ks
</pre></div>
</div>
</div>
<p>now let's display information about snapshots:
</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool listsnapshots
Snapshot Details:
Snapshot name Keyspace name Column family name True size Size on disk Creation time Expiration time
catalog-cql-ks catalogkeyspace magazine 4,94 KiB 5,9 KiB 2021-08-23T20:52:01.344Z 2021-08-23T20:55:01.344Z
catalog-cql-ks catalogkeyspace journal 4,94 KiB 5,9 KiB 2021-08-23T20:52:01.368Z 2021-08-23T20:55:01.368Z
catalog-cql-ks cqlkeyspace t 0 bytes 951 bytes 2021-08-23T20:52:01.370Z 2021-08-23T20:55:01.370Z
catalog-cql-ks cqlkeyspace t2 0 bytes 952 bytes 2021-08-23T20:52:01.373Z 2021-08-23T20:55:01.373Z

Total TrueDiskSpaceUsed: 9,87 KiB
</pre></div>
</div>
<p>
We see creation and expiration time.Let's wait couple of minutes and try again:
</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool listsnapshots
Snapshot Details:
There are no snapshots
</pre></div>
</div>
<p>
Finally, these snapshots have expired.
</p>
</div>
<div class="section" id="finding-snapshots-directories">
<h3>Finding Snapshots Directories<a class="headerlink" href="#finding-snapshots-directories" title="Permalink to this headline">¶</a></h3>
<p>The <code class="docutils literal notranslate"><span class="pre">snapshots</span></code> directories may be listed with <code class="docutils literal notranslate"><span class="pre">find</span> <span class="pre">–name</span> <span class="pre">snapshots</span></code> command:</p>
Expand Down