-
Notifications
You must be signed in to change notification settings - Fork 87
Expand file tree
/
Copy pathbackups.html
More file actions
839 lines (699 loc) · 51.5 KB
/
backups.html
File metadata and controls
839 lines (699 loc) · 51.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Backups — Apache Cassandra Documentation v4.1</title>
<script type="text/javascript" src="../_static/js/modernizr.min.js"></script>
<script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<script type="text/javascript" src="../_static/language_data.js"></script>
<script async="async" type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
<script type="text/javascript" src="../_static/js/theme.js"></script>
<link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="../_static/extra.css" type="text/css" />
<link rel="index" title="Index" href="../genindex.html" />
<link rel="search" title="Search" href="../search.html" />
<link rel="next" title="Bulk Loading" href="bulk_loading.html" />
<link rel="prev" title="Change Data Capture" href="cdc.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="../index.html" class="icon icon-home"> Apache Cassandra
</a>
<div class="version">
4.1
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div>
<div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="../getting_started/index.html">Getting Started</a></li>
<li class="toctree-l1"><a class="reference internal" href="../new/index.html">New Features in Apache Cassandra 4.0</a></li>
<li class="toctree-l1"><a class="reference internal" href="../architecture/index.html">Architecture</a></li>
<li class="toctree-l1"><a class="reference internal" href="../cql/index.html">The Cassandra Query Language (CQL)</a></li>
<li class="toctree-l1"><a class="reference internal" href="../data_modeling/index.html">Data Modeling</a></li>
<li class="toctree-l1"><a class="reference internal" href="../configuration/index.html">Configuring Cassandra</a></li>
<li class="toctree-l1 current"><a class="reference internal" href="index.html">Operating Cassandra</a><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="snitch.html">Snitch</a></li>
<li class="toctree-l2"><a class="reference internal" href="topo_changes.html">Adding, replacing, moving and removing nodes</a></li>
<li class="toctree-l2"><a class="reference internal" href="repair.html">Repair</a></li>
<li class="toctree-l2"><a class="reference internal" href="read_repair.html">Read repair</a></li>
<li class="toctree-l2"><a class="reference internal" href="hints.html">Hints</a></li>
<li class="toctree-l2"><a class="reference internal" href="compaction/index.html">Compaction</a></li>
<li class="toctree-l2"><a class="reference internal" href="bloom_filters.html">Bloom Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="compression.html">Compression</a></li>
<li class="toctree-l2"><a class="reference internal" href="cdc.html">Change Data Capture</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="#">Backups</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#types-of-backups">Types of Backups</a></li>
<li class="toctree-l3"><a class="reference internal" href="#data-directory-structure">Data Directory Structure</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#setting-up-example-tables-for-backups-and-snapshots">Setting Up Example Tables for Backups and Snapshots</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#snapshots">Snapshots</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#configuring-for-snapshots">Configuring for Snapshots</a></li>
<li class="toctree-l4"><a class="reference internal" href="#creating-snapshots">Creating Snapshots</a></li>
<li class="toctree-l4"><a class="reference internal" href="#listing-snapshots">Listing Snapshots</a></li>
<li class="toctree-l4"><a class="reference internal" href="#finding-snapshots-directories">Finding Snapshots Directories</a></li>
<li class="toctree-l4"><a class="reference internal" href="#clearing-snapshots">Clearing Snapshots</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#incremental-backups">Incremental Backups</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#configuring-for-incremental-backups">Configuring for Incremental Backups</a></li>
<li class="toctree-l4"><a class="reference internal" href="#creating-incremental-backups">Creating Incremental Backups</a></li>
<li class="toctree-l4"><a class="reference internal" href="#finding-incremental-backups">Finding Incremental Backups</a></li>
<li class="toctree-l4"><a class="reference internal" href="#creating-an-incremental-backup">Creating an Incremental Backup</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="#restoring-from-incremental-backups-and-snapshots">Restoring from Incremental Backups and Snapshots</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="bulk_loading.html">Bulk Loading</a></li>
<li class="toctree-l2"><a class="reference internal" href="metrics.html">Monitoring</a></li>
<li class="toctree-l2"><a class="reference internal" href="security.html">Security</a></li>
<li class="toctree-l2"><a class="reference internal" href="hardware.html">Hardware Choices</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../tools/index.html">Cassandra Tools</a></li>
<li class="toctree-l1"><a class="reference internal" href="../troubleshooting/index.html">Troubleshooting</a></li>
<li class="toctree-l1"><a class="reference internal" href="../development/index.html">Contributing to Cassandra</a></li>
<li class="toctree-l1"><a class="reference internal" href="../faq/index.html">Frequently Asked Questions</a></li>
<li class="toctree-l1"><a class="reference internal" href="../plugins/index.html">Third-Party Plugins</a></li>
<li class="toctree-l1"><a class="reference internal" href="../bugs.html">Reporting Bugs</a></li>
<li class="toctree-l1"><a class="reference internal" href="../contactus.html">Contact us</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
<nav class="wy-nav-top" aria-label="top navigation">
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../index.html">Apache Cassandra</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="breadcrumbs navigation">
<ul class="wy-breadcrumbs">
<li><a href="../index.html">Docs</a> »</li>
<li><a href="index.html">Operating Cassandra</a> »</li>
<li>Backups</li>
<li class="wy-breadcrumbs-aside">
<a href="../_sources/operating/backups.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<div class="section" id="backups">
<h1>Backups<a class="headerlink" href="#backups" title="Permalink to this headline">¶</a></h1>
<p>Apache Cassandra stores data in immutable SSTable files. Backups in Apache Cassandra database are backup copies of the database data that is stored as SSTable files. Backups are used for several purposes including the following:</p>
<ul class="simple">
<li><p>To store a data copy for durability</p></li>
<li><p>To be able to restore a table if table data is lost due to node/partition/network failure</p></li>
<li><p>To be able to transfer the SSTable files to a different machine; for portability</p></li>
</ul>
<div class="section" id="types-of-backups">
<h2>Types of Backups<a class="headerlink" href="#types-of-backups" title="Permalink to this headline">¶</a></h2>
<p>Apache Cassandra supports two kinds of backup strategies.</p>
<ul class="simple">
<li><p>Snapshots</p></li>
<li><p>Incremental Backups</p></li>
</ul>
<p>A <em>snapshot</em> is a copy of a table’s SSTable files at a given time, created via hard links. The DDL to create the table is stored as well. Snapshots may be created by a user or created automatically.
The setting (<code class="docutils literal notranslate"><span class="pre">snapshot_before_compaction</span></code>) in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code> determines if snapshots are created before each compaction.
By default <code class="docutils literal notranslate"><span class="pre">snapshot_before_compaction</span></code> is set to false.
Snapshots may be created automatically before keyspace truncation or dropping of a table by setting <code class="docutils literal notranslate"><span class="pre">auto_snapshot</span></code> to true (default) in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code>.
Truncates could be delayed due to the auto snapshots and another setting in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code> determines how long the coordinator should wait for truncates to complete.
By default Cassandra waits 60 seconds for auto snapshots to complete.</p>
<p>An <em>incremental backup</em> is a copy of a table’s SSTable files created by a hard link when memtables are flushed to disk as SSTables.
Typically incremental backups are paired with snapshots to reduce the backup time as well as reduce disk space.
Incremental backups are not enabled by default and must be enabled explicitly in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code> (with <code class="docutils literal notranslate"><span class="pre">incremental_backups</span></code> setting) or with the Nodetool.
Once enabled, Cassandra creates a hard link to each SSTable flushed or streamed locally in a <code class="docutils literal notranslate"><span class="pre">backups/</span></code> subdirectory of the keyspace data. Incremental backups of system tables are also created.</p>
</div>
<div class="section" id="data-directory-structure">
<h2>Data Directory Structure<a class="headerlink" href="#data-directory-structure" title="Permalink to this headline">¶</a></h2>
<p>The directory structure of Cassandra data consists of different directories for keyspaces, and tables with the data files within the table directories. Directories backups and snapshots to store backups and snapshots respectively for a particular table are also stored within the table directory. The directory structure for Cassandra is illustrated in Figure 1.</p>
<div class="figure align-default">
<img alt="../_images/Figure_1_backups.jpg" src="../_images/Figure_1_backups.jpg" />
</div>
<p>Figure 1. Directory Structure for Cassandra Data</p>
<div class="section" id="setting-up-example-tables-for-backups-and-snapshots">
<h3>Setting Up Example Tables for Backups and Snapshots<a class="headerlink" href="#setting-up-example-tables-for-backups-and-snapshots" title="Permalink to this headline">¶</a></h3>
<p>In this section we shall create some example data that could be used to demonstrate incremental backups and snapshots. We have used a three node Cassandra cluster.
First, the keyspaces are created. Subsequently tables are created within a keyspace and table data is added. We have used two keyspaces <code class="docutils literal notranslate"><span class="pre">CQLKeyspace</span></code> and <code class="docutils literal notranslate"><span class="pre">CatalogKeyspace</span></code> with two tables within each.
Create <code class="docutils literal notranslate"><span class="pre">CQLKeyspace</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh> CREATE KEYSPACE CQLKeyspace
... WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
</pre></div>
</div>
<p>Create table <code class="docutils literal notranslate"><span class="pre">t</span></code> in the <code class="docutils literal notranslate"><span class="pre">CQLKeyspace</span></code> keyspace.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh> USE CQLKeyspace;
cqlsh:cqlkeyspace> CREATE TABLE t (
... id int,
... k int,
... v text,
... PRIMARY KEY (id)
... );
</pre></div>
</div>
<p>Add data to table <code class="docutils literal notranslate"><span class="pre">t</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace>
cqlsh:cqlkeyspace> INSERT INTO t (id, k, v) VALUES (0, 0, 'val0');
cqlsh:cqlkeyspace> INSERT INTO t (id, k, v) VALUES (1, 1, 'val1');
</pre></div>
</div>
<p>A table query lists the data:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> SELECT * FROM t;
id | k | v
----+---+------
1 | 1 | val1
0 | 0 | val0
(2 rows)
</pre></div>
</div>
<p>Create another table <code class="docutils literal notranslate"><span class="pre">t2</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> CREATE TABLE t2 (
... id int,
... k int,
... v text,
... PRIMARY KEY (id)
... );
</pre></div>
</div>
<p>Add data to table <code class="docutils literal notranslate"><span class="pre">t2</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> INSERT INTO t2 (id, k, v) VALUES (0, 0, 'val0');
cqlsh:cqlkeyspace> INSERT INTO t2 (id, k, v) VALUES (1, 1, 'val1');
cqlsh:cqlkeyspace> INSERT INTO t2 (id, k, v) VALUES (2, 2, 'val2');
</pre></div>
</div>
<p>A table query lists table data:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> SELECT * FROM t2;
id | k | v
----+---+------
1 | 1 | val1
0 | 0 | val0
2 | 2 | val2
(3 rows)
</pre></div>
</div>
<p>Create a second keyspace <code class="docutils literal notranslate"><span class="pre">CatalogKeyspace</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> CREATE KEYSPACE CatalogKeyspace
... WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3};
</pre></div>
</div>
<p>Create a table called <code class="docutils literal notranslate"><span class="pre">journal</span></code> in <code class="docutils literal notranslate"><span class="pre">CatalogKeyspace</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> USE CatalogKeyspace;
cqlsh:catalogkeyspace> CREATE TABLE journal (
... id int,
... name text,
... publisher text,
... PRIMARY KEY (id)
... );
</pre></div>
</div>
<p>Add data to table <code class="docutils literal notranslate"><span class="pre">journal</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:catalogkeyspace> INSERT INTO journal (id, name, publisher) VALUES (0, 'Apache
Cassandra Magazine', 'Apache Cassandra');
cqlsh:catalogkeyspace> INSERT INTO journal (id, name, publisher) VALUES (1, 'Couchbase
Magazine', 'Couchbase');
</pre></div>
</div>
<p>Query table <code class="docutils literal notranslate"><span class="pre">journal</span></code> to list its data:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:catalogkeyspace> SELECT * FROM journal;
id | name | publisher
----+---------------------------+------------------
1 | Couchbase Magazine | Couchbase
0 | Apache Cassandra Magazine | Apache Cassandra
(2 rows)
</pre></div>
</div>
<p>Add another table called <code class="docutils literal notranslate"><span class="pre">magazine</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:catalogkeyspace> CREATE TABLE magazine (
... id int,
... name text,
... publisher text,
... PRIMARY KEY (id)
... );
</pre></div>
</div>
<p>Add table data to <code class="docutils literal notranslate"><span class="pre">magazine</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:catalogkeyspace> INSERT INTO magazine (id, name, publisher) VALUES (0, 'Apache
Cassandra Magazine', 'Apache Cassandra');
cqlsh:catalogkeyspace> INSERT INTO magazine (id, name, publisher) VALUES (1, 'Couchbase
Magazine', 'Couchbase');
</pre></div>
</div>
<p>List table <code class="docutils literal notranslate"><span class="pre">magazine</span></code>’s data:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:catalogkeyspace> SELECT * from magazine;
id | name | publisher
----+---------------------------+------------------
1 | Couchbase Magazine | Couchbase
0 | Apache Cassandra Magazine | Apache Cassandra
(2 rows)
</pre></div>
</div>
</div>
</div>
<div class="section" id="snapshots">
<h2>Snapshots<a class="headerlink" href="#snapshots" title="Permalink to this headline">¶</a></h2>
<p>In this section including sub-sections we shall demonstrate creating snapshots. The command used to create a snapshot is <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">snapshot</span></code> and its usage is as follows:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool help snapshot
NAME
nodetool snapshot - Take a snapshot of specified keyspaces or a snapshot
of the specified table
SYNOPSIS
nodetool [(-h <host> | --host <host>)] [(-p <port> | --port <port>)]
[(-pp | --print-port)] [(-pw <password> | --password <password>)]
[(-pwf <passwordFilePath> | --password-file <passwordFilePath>)]
[(-u <username> | --username <username>)] snapshot
[(-cf <table> | --column-family <table> | --table <table>)]
[(-kt <ktlist> | --kt-list <ktlist> | -kc <ktlist> | --kc.list <ktlist>)]
[(-sf | --skip-flush)] [(-t <tag> | --tag <tag>)] [--] [<keyspaces...>]
OPTIONS
-cf <table>, --column-family <table>, --table <table>
The table name (you must specify one and only one keyspace for using
this option)
-h <host>, --host <host>
Node hostname or ip address
-kt <ktlist>, --kt-list <ktlist>, -kc <ktlist>, --kc.list <ktlist>
The list of Keyspace.table to take snapshot.(you must not specify
only keyspace)
-p <port>, --port <port>
Remote jmx agent port number
-pp, --print-port
Operate in 4.0 mode with hosts disambiguated by port number
-pw <password>, --password <password>
Remote jmx agent password
-pwf <passwordFilePath>, --password-file <passwordFilePath>
Path to the JMX password file
-sf, --skip-flush
Do not flush memtables before snapshotting (snapshot will not
contain unflushed data)
-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
--
This option can be used to separate command-line options from the
list of argument, (useful when arguments might be mistaken for
command-line options
[<keyspaces...>]
List of keyspaces. By default, all keyspaces
</pre></div>
</div>
<div class="section" id="configuring-for-snapshots">
<h3>Configuring for Snapshots<a class="headerlink" href="#configuring-for-snapshots" title="Permalink to this headline">¶</a></h3>
<p>To demonstrate creating snapshots with Nodetool on the commandline we have set
<code class="docutils literal notranslate"><span class="pre">auto_snapshots</span></code> setting to <code class="docutils literal notranslate"><span class="pre">false</span></code> in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>auto_snapshot: false
</pre></div>
</div>
<p>Also set <code class="docutils literal notranslate"><span class="pre">snapshot_before_compaction</span></code> to <code class="docutils literal notranslate"><span class="pre">false</span></code> to disable creating snapshots automatically before compaction:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>snapshot_before_compaction: false
</pre></div>
</div>
</div>
<div class="section" id="creating-snapshots">
<h3>Creating Snapshots<a class="headerlink" href="#creating-snapshots" title="Permalink to this headline">¶</a></h3>
<p>To demonstrate creating snapshots start with no snapshots. Search for snapshots and none get listed:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ find -name snapshots
</pre></div>
</div>
<p>We shall be using the example keyspaces and tables to create snapshots.</p>
<div class="section" id="taking-snapshots-of-all-tables-in-a-keyspace">
<h4>Taking Snapshots of all Tables in a Keyspace<a class="headerlink" href="#taking-snapshots-of-all-tables-in-a-keyspace" title="Permalink to this headline">¶</a></h4>
<p>To take snapshots of all tables in a keyspace and also optionally tag the snapshot the syntax becomes:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool snapshot --tag <tag> --<keyspace>
</pre></div>
</div>
<p>As an example create a snapshot called <code class="docutils literal notranslate"><span class="pre">catalog-ks</span></code> for all the tables in the <code class="docutils literal notranslate"><span class="pre">catalogkeyspace</span></code> keyspace:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot --tag catalog-ks -- catalogkeyspace
Requested creating snapshot(s) for [catalogkeyspace] with snapshot name [catalog-ks] and
options {skipFlush=false}
Snapshot directory: catalog-ks
</pre></div>
</div>
<p>Search for snapshots and <code class="docutils literal notranslate"><span class="pre">snapshots</span></code> directories for the tables <code class="docutils literal notranslate"><span class="pre">journal</span></code> and <code class="docutils literal notranslate"><span class="pre">magazine</span></code>, which are in the <code class="docutils literal notranslate"><span class="pre">catalogkeyspace</span></code> keyspace should get listed:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ find -name snapshots
./cassandra/data/data/catalogkeyspace/journal-296a2d30c22a11e9b1350d927649052c/snapshots
./cassandra/data/data/catalogkeyspace/magazine-446eae30c22a11e9b1350d927649052c/snapshots
</pre></div>
</div>
<p>Snapshots of all tables in multiple keyspaces may be created similarly, as an example:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool snapshot --tag catalog-cql-ks --catalogkeyspace,cqlkeyspace
</pre></div>
</div>
</div>
<div class="section" id="taking-snapshots-of-single-table-in-a-keyspace">
<h4>Taking Snapshots of Single Table in a Keyspace<a class="headerlink" href="#taking-snapshots-of-single-table-in-a-keyspace" title="Permalink to this headline">¶</a></h4>
<p>To take a snapshot of a single table the <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">snapshot</span></code> command syntax becomes as follows:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool snapshot --tag <tag> --table <table> --<keyspace>
</pre></div>
</div>
<p>As an example create a snapshot for table <code class="docutils literal notranslate"><span class="pre">magazine</span></code> in keyspace <code class="docutils literal notranslate"><span class="pre">catalokeyspace</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot --tag magazine --table magazine --
catalogkeyspace
Requested creating snapshot(s) for [catalogkeyspace] with snapshot name [magazine] and
options {skipFlush=false}
Snapshot directory: magazine
</pre></div>
</div>
</div>
<div class="section" id="taking-snapshot-of-multiple-tables-from-same-keyspace">
<h4>Taking Snapshot of Multiple Tables from same Keyspace<a class="headerlink" href="#taking-snapshot-of-multiple-tables-from-same-keyspace" title="Permalink to this headline">¶</a></h4>
<p>To take snapshots of multiple tables in a keyspace the list of <em>Keyspace.table</em> must be specified with option <code class="docutils literal notranslate"><span class="pre">--kt-list</span></code>. As an example create snapshots for tables <code class="docutils literal notranslate"><span class="pre">t</span></code> and <code class="docutils literal notranslate"><span class="pre">t2</span></code> in the <code class="docutils literal notranslate"><span class="pre">cqlkeyspace</span></code> keyspace:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool snapshot --kt-list cqlkeyspace.t,cqlkeyspace.t2 --tag multi-table
[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot --kt-list cqlkeyspace.t,cqlkeyspace.t2 --tag
multi-table
Requested creating snapshot(s) for [cqlkeyspace.t,cqlkeyspace.t2] with snapshot name [multi-
table] and options {skipFlush=false}
Snapshot directory: multi-table
</pre></div>
</div>
<p>Multiple snapshots of the same set of tables may be created and tagged with a different name. As an example, create another snapshot for the same set of tables <code class="docutils literal notranslate"><span class="pre">t</span></code> and <code class="docutils literal notranslate"><span class="pre">t2</span></code> in the <code class="docutils literal notranslate"><span class="pre">cqlkeyspace</span></code> keyspace and tag the snapshots differently:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot --kt-list cqlkeyspace.t,cqlkeyspace.t2 --tag
multi-table-2
Requested creating snapshot(s) for [cqlkeyspace.t,cqlkeyspace.t2] with snapshot name [multi-
table-2] and options {skipFlush=false}
Snapshot directory: multi-table-2
</pre></div>
</div>
</div>
<div class="section" id="taking-snapshot-of-multiple-tables-from-different-keyspaces">
<h4>Taking Snapshot of Multiple Tables from Different Keyspaces<a class="headerlink" href="#taking-snapshot-of-multiple-tables-from-different-keyspaces" title="Permalink to this headline">¶</a></h4>
<p>To take snapshots of multiple tables that are in different keyspaces the command syntax is the same as when multiple tables are in the same keyspace. Each <em>keyspace.table</em> must be specified separately in the <code class="docutils literal notranslate"><span class="pre">--kt-list</span></code> option. As an example, create a snapshot for table <code class="docutils literal notranslate"><span class="pre">t</span></code> in the <code class="docutils literal notranslate"><span class="pre">cqlkeyspace</span></code> and table <code class="docutils literal notranslate"><span class="pre">journal</span></code> in the catalogkeyspace and tag the snapshot <code class="docutils literal notranslate"><span class="pre">multi-ks</span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool snapshot --kt-list
catalogkeyspace.journal,cqlkeyspace.t --tag multi-ks
Requested creating snapshot(s) for [catalogkeyspace.journal,cqlkeyspace.t] with snapshot
name [multi-ks] and options {skipFlush=false}
Snapshot directory: multi-ks
</pre></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>
<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
multi-table cqlkeyspace t2 4.86 KiB 5.67 KiB
multi-table cqlkeyspace t 4.89 KiB 5.7 KiB
multi-ks cqlkeyspace t 4.89 KiB 5.7 KiB
multi-ks catalogkeyspace journal 4.9 KiB 5.73 KiB
magazine catalogkeyspace magazine 4.9 KiB 5.73 KiB
multi-table-2 cqlkeyspace t2 4.86 KiB 5.67 KiB
multi-table-2 cqlkeyspace t 4.89 KiB 5.7 KiB
catalog-ks catalogkeyspace journal 4.9 KiB 5.73 KiB
catalog-ks catalogkeyspace magazine 4.9 KiB 5.73 KiB
Total TrueDiskSpaceUsed: 44.02 KiB
</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>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ find -name snapshots
./cassandra/data/data/cqlkeyspace/t-d132e240c21711e9bbee19821dcea330/snapshots
./cassandra/data/data/cqlkeyspace/t2-d993a390c22911e9b1350d927649052c/snapshots
./cassandra/data/data/catalogkeyspace/journal-296a2d30c22a11e9b1350d927649052c/snapshots
./cassandra/data/data/catalogkeyspace/magazine-446eae30c22a11e9b1350d927649052c/snapshots
[ec2-user@ip-10-0-2-238 ~]$
</pre></div>
</div>
<p>To list the snapshots for a particular table first change directory ( with <code class="docutils literal notranslate"><span class="pre">cd</span></code>) to the <code class="docutils literal notranslate"><span class="pre">snapshots</span></code> directory for the table. As an example, list the snapshots for the <code class="docutils literal notranslate"><span class="pre">catalogkeyspace/journal</span></code> table. Two snapshots get listed:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ cd ./cassandra/data/data/catalogkeyspace/journal-
296a2d30c22a11e9b1350d927649052c/snapshots
[ec2-user@ip-10-0-2-238 snapshots]$ ls -l
total 0
drwxrwxr-x. 2 ec2-user ec2-user 265 Aug 19 02:44 catalog-ks
drwxrwxr-x. 2 ec2-user ec2-user 265 Aug 19 02:52 multi-ks
</pre></div>
</div>
<p>A <code class="docutils literal notranslate"><span class="pre">snapshots</span></code> directory lists the SSTable files in the snapshot. <code class="docutils literal notranslate"><span class="pre">Schema.cql</span></code> file is also created in each snapshot for the schema definition DDL that may be run in CQL to create the table when restoring from a snapshot:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 snapshots]$ cd catalog-ks
[ec2-user@ip-10-0-2-238 catalog-ks]$ ls -l
total 44
-rw-rw-r--. 1 ec2-user ec2-user 31 Aug 19 02:44 manifest.jsonZ
-rw-rw-r--. 4 ec2-user ec2-user 47 Aug 19 02:38 na-1-big-CompressionInfo.db
-rw-rw-r--. 4 ec2-user ec2-user 97 Aug 19 02:38 na-1-big-Data.db
-rw-rw-r--. 4 ec2-user ec2-user 10 Aug 19 02:38 na-1-big-Digest.crc32
-rw-rw-r--. 4 ec2-user ec2-user 16 Aug 19 02:38 na-1-big-Filter.db
-rw-rw-r--. 4 ec2-user ec2-user 16 Aug 19 02:38 na-1-big-Index.db
-rw-rw-r--. 4 ec2-user ec2-user 4687 Aug 19 02:38 na-1-big-Statistics.db
-rw-rw-r--. 4 ec2-user ec2-user 56 Aug 19 02:38 na-1-big-Summary.db
-rw-rw-r--. 4 ec2-user ec2-user 92 Aug 19 02:38 na-1-big-TOC.txt
-rw-rw-r--. 1 ec2-user ec2-user 814 Aug 19 02:44 schema.cql
</pre></div>
</div>
</div>
<div class="section" id="clearing-snapshots">
<h3>Clearing Snapshots<a class="headerlink" href="#clearing-snapshots" title="Permalink to this headline">¶</a></h3>
<p>Snapshots may be cleared or deleted with the <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">clearsnapshot</span></code> command. Either a specific snapshot name must be specified or the <code class="docutils literal notranslate"><span class="pre">–all</span></code> option must be specified.
As an example delete a snapshot called <code class="docutils literal notranslate"><span class="pre">magazine</span></code> from keyspace <code class="docutils literal notranslate"><span class="pre">cqlkeyspace</span></code>:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>nodetool clearsnapshot -t magazine – cqlkeyspace
Delete all snapshots from cqlkeyspace with the –all option.
nodetool clearsnapshot –all -- cqlkeyspace
</pre></div>
</div>
</div>
</div>
<div class="section" id="incremental-backups">
<h2>Incremental Backups<a class="headerlink" href="#incremental-backups" title="Permalink to this headline">¶</a></h2>
<p>In the following sub-sections we shall discuss configuring and creating incremental backups.</p>
<div class="section" id="configuring-for-incremental-backups">
<h3>Configuring for Incremental Backups<a class="headerlink" href="#configuring-for-incremental-backups" title="Permalink to this headline">¶</a></h3>
<p>To create incremental backups set <code class="docutils literal notranslate"><span class="pre">incremental_backups</span></code> to <code class="docutils literal notranslate"><span class="pre">true</span></code> in <code class="docutils literal notranslate"><span class="pre">cassandra.yaml</span></code>.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>incremental_backups: true
</pre></div>
</div>
<p>This is the only setting needed to create incremental backups. By default <code class="docutils literal notranslate"><span class="pre">incremental_backups</span></code> setting is set to <code class="docutils literal notranslate"><span class="pre">false</span></code> because a new set of SSTable files is created for each data flush and if several CQL statements are to be run the <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory could fill up quickly and use up storage that is needed to store table data.
Incremental backups may also be enabled on the command line with the Nodetool command <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">enablebackup</span></code>. Incremental backups may be disabled with <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">disablebackup</span></code> command. Status of incremental backups, whether they are enabled may be found with <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">statusbackup</span></code>.</p>
</div>
<div class="section" id="creating-incremental-backups">
<h3>Creating Incremental Backups<a class="headerlink" href="#creating-incremental-backups" title="Permalink to this headline">¶</a></h3>
<p>After each table is created flush the table data with <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">flush</span></code> command. Incremental backups get created.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool flush cqlkeyspace t
[ec2-user@ip-10-0-2-238 ~]$ nodetool flush cqlkeyspace t2
[ec2-user@ip-10-0-2-238 ~]$ nodetool flush catalogkeyspace journal magazine
</pre></div>
</div>
</div>
<div class="section" id="finding-incremental-backups">
<h3>Finding Incremental Backups<a class="headerlink" href="#finding-incremental-backups" title="Permalink to this headline">¶</a></h3>
<p>Incremental backups are created within the Cassandra’s <code class="docutils literal notranslate"><span class="pre">data</span></code> directory within a table directory. Backups may be found with following command.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ find -name backups
./cassandra/data/data/cqlkeyspace/t-d132e240c21711e9bbee19821dcea330/backups
./cassandra/data/data/cqlkeyspace/t2-d993a390c22911e9b1350d927649052c/backups
./cassandra/data/data/catalogkeyspace/journal-296a2d30c22a11e9b1350d927649052c/backups
./cassandra/data/data/catalogkeyspace/magazine-446eae30c22a11e9b1350d927649052c/backups
</pre></div>
</div>
</div>
<div class="section" id="creating-an-incremental-backup">
<h3>Creating an Incremental Backup<a class="headerlink" href="#creating-an-incremental-backup" title="Permalink to this headline">¶</a></h3>
<p>This section discusses how incremental backups are created in more detail starting with when a new keyspace is created and a table is added. Create a keyspace called <code class="docutils literal notranslate"><span class="pre">CQLKeyspace</span></code> (arbitrary name).</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh> CREATE KEYSPACE CQLKeyspace
... WITH replication = {'class': 'SimpleStrategy', 'replication_factor' : 3}
</pre></div>
</div>
<p>Create a table called <code class="docutils literal notranslate"><span class="pre">t</span></code> within the <code class="docutils literal notranslate"><span class="pre">CQLKeyspace</span></code> keyspace:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh> USE CQLKeyspace;
cqlsh:cqlkeyspace> CREATE TABLE t (
... id int,
... k int,
... v text,
... PRIMARY KEY (id)
... );
</pre></div>
</div>
<p>Flush the keyspace and table:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool flush cqlkeyspace t
</pre></div>
</div>
<p>Search for backups and a <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory should get listed even though we have added no table data yet.</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ find -name backups
./cassandra/data/data/cqlkeyspace/t-d132e240c21711e9bbee19821dcea330/backups
</pre></div>
</div>
<p>Change directory to the <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory and list files and no files get listed as no table data has been added yet:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ cd ./cassandra/data/data/cqlkeyspace/t-
d132e240c21711e9bbee19821dcea330/backups
[ec2-user@ip-10-0-2-238 backups]$ ls -l
total 0
</pre></div>
</div>
<p>Next, add a row of data to table <code class="docutils literal notranslate"><span class="pre">t</span></code> that we created:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> INSERT INTO t (id, k, v) VALUES (0, 0, 'val0');
</pre></div>
</div>
<p>Run the <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">flush</span></code> command to flush table data:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ nodetool flush cqlkeyspace t
</pre></div>
</div>
<p>List the files and directories in the <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory and SSTable files for an incremental backup get listed:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ cd ./cassandra/data/data/cqlkeyspace/t-
d132e240c21711e9bbee19821dcea330/backups
[ec2-user@ip-10-0-2-238 backups]$ ls -l
total 36
-rw-rw-r--. 2 ec2-user ec2-user 47 Aug 19 00:32 na-1-big-CompressionInfo.db
-rw-rw-r--. 2 ec2-user ec2-user 43 Aug 19 00:32 na-1-big-Data.db
-rw-rw-r--. 2 ec2-user ec2-user 10 Aug 19 00:32 na-1-big-Digest.crc32
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 00:32 na-1-big-Filter.db
-rw-rw-r--. 2 ec2-user ec2-user 8 Aug 19 00:32 na-1-big-Index.db
-rw-rw-r--. 2 ec2-user ec2-user 4673 Aug 19 00:32 na-1-big-Statistics.db
-rw-rw-r--. 2 ec2-user ec2-user 56 Aug 19 00:32 na-1-big-Summary.db
-rw-rw-r--. 2 ec2-user ec2-user 92 Aug 19 00:32 na-1-big-TOC.txt
</pre></div>
</div>
<p>Add another row of data:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>cqlsh:cqlkeyspace> INSERT INTO t (id, k, v) VALUES (1, 1, 'val1');
</pre></div>
</div>
<p>Again, run the <code class="docutils literal notranslate"><span class="pre">nodetool</span> <span class="pre">flush</span></code> command:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 backups]$ nodetool flush cqlkeyspace t
</pre></div>
</div>
<p>A new incremental backup gets created for the new data added. List the files in the <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory for table <code class="docutils literal notranslate"><span class="pre">t</span></code> and two sets of SSTable files get listed, one for each incremental backup. The SSTable files are timestamped, which distinguishes the first incremental backup from the second:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 backups]$ ls -l
total 72
-rw-rw-r--. 2 ec2-user ec2-user 47 Aug 19 00:32 na-1-big-CompressionInfo.db
-rw-rw-r--. 2 ec2-user ec2-user 43 Aug 19 00:32 na-1-big-Data.db
-rw-rw-r--. 2 ec2-user ec2-user 10 Aug 19 00:32 na-1-big-Digest.crc32
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 00:32 na-1-big-Filter.db
-rw-rw-r--. 2 ec2-user ec2-user 8 Aug 19 00:32 na-1-big-Index.db
-rw-rw-r--. 2 ec2-user ec2-user 4673 Aug 19 00:32 na-1-big-Statistics.db
-rw-rw-r--. 2 ec2-user ec2-user 56 Aug 19 00:32 na-1-big-Summary.db
-rw-rw-r--. 2 ec2-user ec2-user 92 Aug 19 00:32 na-1-big-TOC.txt
-rw-rw-r--. 2 ec2-user ec2-user 47 Aug 19 00:35 na-2-big-CompressionInfo.db
-rw-rw-r--. 2 ec2-user ec2-user 41 Aug 19 00:35 na-2-big-Data.db
-rw-rw-r--. 2 ec2-user ec2-user 10 Aug 19 00:35 na-2-big-Digest.crc32
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 00:35 na-2-big-Filter.db
-rw-rw-r--. 2 ec2-user ec2-user 8 Aug 19 00:35 na-2-big-Index.db
-rw-rw-r--. 2 ec2-user ec2-user 4673 Aug 19 00:35 na-2-big-Statistics.db
-rw-rw-r--. 2 ec2-user ec2-user 56 Aug 19 00:35 na-2-big-Summary.db
-rw-rw-r--. 2 ec2-user ec2-user 92 Aug 19 00:35 na-2-big-TOC.txt
[ec2-user@ip-10-0-2-238 backups]$
</pre></div>
</div>
<p>The <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory for table <code class="docutils literal notranslate"><span class="pre">cqlkeyspace/t</span></code> is created within the <code class="docutils literal notranslate"><span class="pre">data</span></code> directory for the table:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ cd ./cassandra/data/data/cqlkeyspace/t-
d132e240c21711e9bbee19821dcea330
[ec2-user@ip-10-0-2-238 t-d132e240c21711e9bbee19821dcea330]$ ls -l
total 36
drwxrwxr-x. 2 ec2-user ec2-user 226 Aug 19 02:30 backups
-rw-rw-r--. 2 ec2-user ec2-user 47 Aug 19 02:30 na-1-big-CompressionInfo.db
-rw-rw-r--. 2 ec2-user ec2-user 79 Aug 19 02:30 na-1-big-Data.db
-rw-rw-r--. 2 ec2-user ec2-user 10 Aug 19 02:30 na-1-big-Digest.crc32
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 02:30 na-1-big-Filter.db
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 02:30 na-1-big-Index.db
-rw-rw-r--. 2 ec2-user ec2-user 4696 Aug 19 02:30 na-1-big-Statistics.db
-rw-rw-r--. 2 ec2-user ec2-user 56 Aug 19 02:30 na-1-big-Summary.db
-rw-rw-r--. 2 ec2-user ec2-user 92 Aug 19 02:30 na-1-big-TOC.txt
</pre></div>
</div>
<p>The incremental backups for the other keyspaces/tables get created similarly. As an example the <code class="docutils literal notranslate"><span class="pre">backups</span></code> directory for table <code class="docutils literal notranslate"><span class="pre">catalogkeyspace/magazine</span></code> is created within the data directory:</p>
<div class="highlight-none notranslate"><div class="highlight"><pre><span></span>[ec2-user@ip-10-0-2-238 ~]$ cd ./cassandra/data/data/catalogkeyspace/magazine-
446eae30c22a11e9b1350d927649052c
[ec2-user@ip-10-0-2-238 magazine-446eae30c22a11e9b1350d927649052c]$ ls -l
total 36
drwxrwxr-x. 2 ec2-user ec2-user 226 Aug 19 02:38 backups
-rw-rw-r--. 2 ec2-user ec2-user 47 Aug 19 02:38 na-1-big-CompressionInfo.db
-rw-rw-r--. 2 ec2-user ec2-user 97 Aug 19 02:38 na-1-big-Data.db
-rw-rw-r--. 2 ec2-user ec2-user 10 Aug 19 02:38 na-1-big-Digest.crc32
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 02:38 na-1-big-Filter.db
-rw-rw-r--. 2 ec2-user ec2-user 16 Aug 19 02:38 na-1-big-Index.db
-rw-rw-r--. 2 ec2-user ec2-user 4687 Aug 19 02:38 na-1-big-Statistics.db
-rw-rw-r--. 2 ec2-user ec2-user 56 Aug 19 02:38 na-1-big-Summary.db
-rw-rw-r--. 2 ec2-user ec2-user 92 Aug 19 02:38 na-1-big-TOC.txt
</pre></div>
</div>
</div>
</div>
<div class="section" id="restoring-from-incremental-backups-and-snapshots">
<h2>Restoring from Incremental Backups and Snapshots<a class="headerlink" href="#restoring-from-incremental-backups-and-snapshots" title="Permalink to this headline">¶</a></h2>
<p>The two main tools/commands for restoring a table after it has been dropped are:</p>
<ul class="simple">
<li><p>sstableloader</p></li>
<li><p>nodetool import</p></li>
</ul>
<p>A snapshot contains essentially the same set of SSTable files as an incremental backup does with a few additional files. A snapshot includes a <code class="docutils literal notranslate"><span class="pre">schema.cql</span></code> file for the schema DDL to create a table in CQL. A table backup does not include DDL which must be obtained from a snapshot when restoring from an incremental backup.</p>
</div>
</div>
</div>
</div>
<footer>
<div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
<a href="bulk_loading.html" class="btn btn-neutral float-right" title="Bulk Loading" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right"></span></a>
<a href="cdc.html" class="btn btn-neutral float-left" title="Change Data Capture" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left"></span> Previous</a>
</div>
<hr/>
<div role="contentinfo">
<p>
© Copyright 2020, The Apache Cassandra team
</p>
</div>
Built with <a href="http://sphinx-doc.org/">Sphinx</a> using a <a href="https://github.com/rtfd/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script type="text/javascript">
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>