{"id":20318,"date":"2013-05-10T12:51:55","date_gmt":"2013-05-10T07:21:55","guid":{"rendered":"http:\/\/vskills.in\/certification\/tutorial\/?p=20318"},"modified":"2024-04-12T14:16:44","modified_gmt":"2024-04-12T08:46:44","slug":"snapshot-management","status":"publish","type":"page","link":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/","title":{"rendered":"Snapshot management"},"content":{"rendered":"<p><a class=\"vsc\" href=\"http:\/\/www.vskills.in\/certification\/Certified-Cassandra-Professional\"><span class=\"vsc-cn\" style=\"text-align: center;\"><span style=\"color: red;\">Certify and Increase Opportunity.<\/span><br \/>\n<span style=\"color: green;\">Be <\/span><br \/>\nGovt. Certified Apache Cassandra Professional<br \/>\n<\/span><\/a><\/p>\n<p>Snapshot management<\/p>\n<p>Cassandra backs up data by taking a snapshot of all on-disk data files (SSTable files) stored in the data directory. Snapshots are taken per keyspace and while the system is online. However, nodes must be taken offline in order to restore a snapshot.<\/p>\n<p>Using a parallel ssh tool (such as <tt>pssh<\/tt>), you can snapshot an entire cluster. This provides an <em>eventually consistent<\/em> backup. Although no one node is guaranteed to be consistent with its replica nodes at the time a snapshot is taken, a restored snapshot can resume consistency using Cassandra&#8217;s built-in consistency mechanisms.<\/p>\n<p>After a system-wide snapshot has been taken, you can enable incremental backups on each node (disabled by default) to backup data that has changed since the last snapshot was taken. Each time an SSTable is flushed, a hard link is copied into a <tt>\/backups<\/tt> subdirectory of the data directory.<\/p>\n<div id=\"taking-a-snapshot\">\n<h2>Taking a Snapshot<\/h2>\n<p>Snapshots are taken per node using the <em>nodetool snapshot<\/em> command. If you want to take a global snapshot (capture all nodes in the cluster at the same time), run the <tt>nodetool snapshot<\/tt> command using a parallel ssh utility, such as <tt>pssh<\/tt>. A snapshot first flushes all in-memory writes to disk, then makes a hard link of the SSTable files for each keyspace. The snapshot files are stored in the <tt>\/var\/lib\/cassandra\/data<\/tt> (by default) in the <tt>snapshots<\/tt> directory of each keyspace.<\/p>\n<p>You must have enough free disk space on the node to accommodate making snapshots of your data files. A single snapshot requires little disk space. However, snapshots will cause your disk usage to grow more quickly over time because a snapshot prevents old obsolete data files from being deleted. After the snapshot is complete, you can move the backup files off to another location if needed, or you can leave them in place.<\/p>\n<p><strong>To create a snapshot of a node<\/strong><\/p>\n<p>Run the <tt>nodetool snapshot<\/tt> command, specifying the hostname, JMX port and snapshot name. For example:<\/p>\n<div>\n<div>\n<pre>$ nodetool -h localhost -p 7199 snapshot 12022011<\/pre>\n<\/div>\n<\/div>\n<p>The snapshot is created in <tt>&lt;data_directory_location&gt;\/&lt;keyspace_name&gt;\/snapshots\/&lt;snapshot_name&gt;<\/tt>. Each snapshot folder contains numerous <tt>.db<\/tt> files that contain the data at the time of the snapshot.<\/p>\n<\/div>\n<div id=\"clearing-snapshot-files\">\n<h2>Clearing Snapshot Files<\/h2>\n<p>When taking a snapshot, previous snapshot files are not automatically deleted. To maintain the snapshot directories, old snapshots that are no longer needed should be removed.<\/p>\n<p>The <em>nodetool clearsnapshot<\/em> command removes all existing snapshot files from the snapshot directory of each keyspace. You may want to make it part of your back-up process to clear old snapshots before taking a new one.<\/p>\n<p>If you want to clear snapshots on all nodes at once, run the <tt>nodetool clearsnapshot<\/tt> command using a parallel ssh utility, such as <tt>pssh<\/tt>.<\/p>\n<p><strong>To clear all snapshots for a node<\/strong><\/p>\n<p>Run the <tt>nodetool clearsnapshot<\/tt> command. For example:<\/p>\n<div>\n<div>\n<pre>$ nodetool -h localhost -p 7199 clearsnapshot<\/pre>\n<\/div>\n<\/div>\n<\/div>\n<div id=\"enabling-incremental-backups\">\n<h2>Enabling Incremental Backups<\/h2>\n<p>When incremental backups are enabled (disabled by default), Cassandra hard-links each flushed SSTable to a backups directory under the keyspace data directory. This allows you to store backups offsite without transferring entire snapshots. Also, incremental backups combine with snapshots to provide a dependable, up-to-date backup mechanism.<\/p>\n<p>To enable incremental backups, edit the <tt>cassandra.yaml<\/tt> configuration file on each node in the cluster and change the value of <em>incremental_backups<\/em> to <tt>true<\/tt>.<\/p>\n<p>As with snapshots, Cassandra does not automatically clear incremental backup files. DataStax recommends setting up a process to clear incremental backup hard-links each time a new snapshot is created.<\/p>\n<\/div>\n<div id=\"restoring-from-a-snapshot\">\n<h2>Restoring from a Snapshot<\/h2>\n<p>To restore a keyspace from a snapshot, you will need all of the snapshot files for the keyspace, and if using incremental backups, any incremental backup files created after the snapshot was taken.<\/p>\n<p>If restoring a single node, you must first shutdown the node. If restoring an entire cluster, you must shutdown all nodes, restore the snapshot data, and then start all nodes again.<\/p>\n<div>\n<p>Note<\/p>\n<p>Restoring from snapshots and incremental backups temporarily causes intensive CPU and I\/O activity on the node being restored.<\/p>\n<\/div>\n<p><strong>To restore a node from a snapshot and incremental backups:<\/strong><\/p>\n<ol>\n<li>Shut down the node to be restored.<\/li>\n<li>Clear all files the <tt>\/var\/lib\/cassandra\/commitlog<\/tt> (by default).<\/li>\n<li>Clear all <tt>*.db<\/tt> files in <tt>&lt;data_directory_location&gt;\/&lt;keyspace_name&gt;<\/tt>, but <strong>DO NOT<\/strong> delete the <tt>\/snapshots<\/tt> and <tt>\/backups<\/tt> subdirectories.<\/li>\n<li>Locate the most recent snapshot folder in <tt>&lt;data_directory_location&gt;\/&lt;keyspace_name&gt;\/snapshots\/&lt;snapshot_name&gt;<\/tt>, and copy its contents into <tt>&lt;data_directory_location&gt;\/&lt;keyspace_name&gt;<\/tt>.<\/li>\n<li>If using incremental backups as well, copy all contents of <tt>&lt;data_directory_location&gt;\/&lt;keyspace_name&gt;\/backups<\/tt> into <tt>&lt;data_directory_location&gt;\/&lt;keyspace_name&gt;<\/tt>.<\/li>\n<li>Restart the node, keeping in mind that a temporary burst of I\/O activity will consume a large amount of CPU resources.<\/li>\n<\/ol>\n<h6>&nbsp;-Datastax<\/h6>\n<\/div>\n<div class=\"apply\">\n<h3>Apply for Apache Cassandra Certification Now!!<\/h3>\n<p><a href=\"http:\/\/www.vskills.in\/certification\/Certified-Cassandra-Professional\">http:\/\/www.vskills.in\/certification\/Certified-Apache-Cassandra-Professional<\/a><\/p>\n<h5>Go To Tutorial-&nbsp;<a href=\"https:\/\/www.vskills.in\/certification\/tutorial\/apache-cassandra-professional\/\" target=\"_blank\" rel=\"noopener noreferrer\"><strong>Certified Apache Cassandra Professional Tutorial<\/strong><\/a><\/h5>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Certify and Increase Opportunity. Be Govt. Certified Apache Cassandra Professional Snapshot management Cassandra backs up data by taking a snapshot of all on-disk data files (SSTable files) stored in the data directory. Snapshots are taken per keyspace and while the system is online. However, nodes must be taken offline in order to restore a snapshot&#8230;.<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[63],"tags":[],"class_list":["post-20318","page","type-page","status-publish","hentry","category-apache-cassandra"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Snapshot management - Tutorial<\/title>\n<meta name=\"description\" content=\"Snapshot management. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Snapshot management - Tutorial\" \/>\n<meta property=\"og:description\" content=\"Snapshot management. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorial\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/vskills.in\/\" \/>\n<meta property=\"article:modified_time\" content=\"2024-04-12T08:46:44+00:00\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/\",\"name\":\"Snapshot management - Tutorial\",\"isPartOf\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\"},\"datePublished\":\"2013-05-10T07:21:55+00:00\",\"dateModified\":\"2024-04-12T08:46:44+00:00\",\"description\":\"Snapshot management. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Snapshot management\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#website\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"name\":\"Tutorial\",\"description\":\"Vskills - A initiative in elearning and certification\",\"publisher\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#organization\",\"name\":\"Vskills\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"contentUrl\":\"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg\",\"width\":73,\"height\":55,\"caption\":\"Vskills\"},\"image\":{\"@id\":\"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/vskills.in\/\",\"https:\/\/x.com\/vskills_in\",\"https:\/\/www.linkedin.com\/company-beta\/1371554\/\",\"https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Snapshot management - Tutorial","description":"Snapshot management. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/","og_locale":"en_US","og_type":"article","og_title":"Snapshot management - Tutorial","og_description":"Snapshot management. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","og_url":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/","og_site_name":"Tutorial","article_publisher":"https:\/\/www.facebook.com\/vskills.in\/","article_modified_time":"2024-04-12T08:46:44+00:00","twitter_misc":{"Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/","name":"Snapshot management - Tutorial","isPartOf":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website"},"datePublished":"2013-05-10T07:21:55+00:00","dateModified":"2024-04-12T08:46:44+00:00","description":"Snapshot management. Vskills Government Certification in Apache Cassandra is very popular in India amongst developers working in the IT Bid data industry.","breadcrumb":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/snapshot-management\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.vskills.in\/certification\/tutorial\/"},{"@type":"ListItem","position":2,"name":"Snapshot management"}]},{"@type":"WebSite","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#website","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","name":"Tutorial","description":"Vskills - A initiative in elearning and certification","publisher":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.vskills.in\/certification\/tutorial\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#organization","name":"Vskills","url":"https:\/\/www.vskills.in\/certification\/tutorial\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/","url":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","contentUrl":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-content\/uploads\/2017\/07\/vskills-min-logo.jpg","width":73,"height":55,"caption":"Vskills"},"image":{"@id":"https:\/\/www.vskills.in\/certification\/tutorial\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/vskills.in\/","https:\/\/x.com\/vskills_in","https:\/\/www.linkedin.com\/company-beta\/1371554\/","https:\/\/www.youtube.com\/channel\/UCMWnscxPwRF_PqXo9B7q_Tw"]}]}},"_links":{"self":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/comments?post=20318"}],"version-history":[{"count":12,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20318\/revisions"}],"predecessor-version":[{"id":122147,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/pages\/20318\/revisions\/122147"}],"wp:attachment":[{"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/media?parent=20318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/categories?post=20318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vskills.in\/certification\/tutorial\/wp-json\/wp\/v2\/tags?post=20318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}