<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>5.2 &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/5-2-2/feed/" rel="self" type="application/rss+xml" />
	<link>https://solr.pl/en/</link>
	<description>All things to be found - Blog related to Apache Solr &#38; Lucene projects - https://solr.apache.org</description>
	<lastBuildDate>Sat, 14 Nov 2020 13:54:18 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9</generator>
	<item>
		<title>Solr 5.2: quick look on Solr backup functionality</title>
		<link>https://solr.pl/en/2015/06/22/solr-5-2-quick-look-on-solr-backup-functionality/</link>
					<comments>https://solr.pl/en/2015/06/22/solr-5-2-quick-look-on-solr-backup-functionality/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 22 Jun 2015 12:53:50 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[5.2]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[solr]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=867</guid>

					<description><![CDATA[With the lastest release of Solr &#8211; the 5.2 and 5.2.1 we were given the new API &#8211; the backup API based on the replication handler. Because this functionality has been anticipated by some users, we decided to give it]]></description>
										<content:encoded><![CDATA[<p>With the lastest release of Solr &#8211; the <a href="http://solr.pl/en/2015/06/07/lucene-solr-5-2/">5.2</a> and <a href="http://solr.pl/en/2015/06/15/lucene-and-solr-5-2-1/">5.2.1</a> we were given the new API &#8211; the backup API based on the replication handler. Because this functionality has been anticipated by some users, we decided to give it a quick look.</p>
<p><span id="more-867"></span></p>
<p>In order to test the new functionality we will do a very simple test:</p>
<ol>
<li>We will launch Solr in the SolrCloud mode,</li>
<li>We will index a few documents,</li>
<li>We will make the backup using the new API,</li>
<li>We will index another few documents,</li>
<li>Finally we will try to restore the backup done in step 3</li>
</ol>
<p>Let&#8217;s start.</p>
<h3>Starting Solr</h3>
<p>To start Solr in SolrCloud mode, we&#8217;ve used the <em>bin/solr</em> script and we&#8217;ve used the following command:
</p>
<pre class="brush:xml">bin/solr -e cloud
</pre>
<p>For the purpose of the tests we need a single SolrCloud instance, with a single, empty collection (we will use the <em>gettingstarted</em> one provided with Solr) and a single shard.</p>
<p>Our cluster topology looked as follows:</p>
<p><a href="http://solr.pl/wp-content/uploads/2015/06/Zrzut-ekranu-2015-06-21-o-11.13.31.png"><img decoding="async" class="aligncenter  wp-image-3617" src="http://solr.pl/wp-content/uploads/2015/06/Zrzut-ekranu-2015-06-21-o-11.13.31.png" alt="Zrzut ekranu 2015-06-21 o 11.13.31" width="683" height="36"></a></p>
<h3>Data indexation</h3>
<p>Indexing data is as simple as starting Solr. Because we are using the example <em>gettingstarted</em> collection we can send documents without defined structure and Solr will adjust the <em>schema.xml</em> to what we need. So, for the purpose of the tests we will index two documents using the following command:
</p>
<pre class="brush:xml">curl 'localhost:8983/solr/gettingstarted/update?commit=true' -H 'Content-type:application/xml' --data-binary '
&lt;add&gt;
 &lt;doc&gt;
  &lt;field name="id"&gt;1&lt;/field&gt;
  &lt;field name="name"&gt;Test document 1&lt;/field&gt;
 &lt;/doc&gt;
 &lt;doc&gt;
  &lt;field name="id"&gt;2&lt;/field&gt;
  &lt;field name="name"&gt;Test document 2&lt;/field&gt;
 &lt;/doc&gt;
&lt;/add&gt;'
</pre>
<h3>Backup</h3>
<p>Making a backup is again very simple. We just need to run the following command:
</p>
<pre class="brush:xml">curl 'http://localhost:8983/solr/gettingstarted/replication?command=backup&amp;name=test&amp;location=/Users/gro/backup/'
</pre>
<p>The above command tells Solr, that we want to make a backup of our collection called <em>snapshot.test</em> (Solr will add the value of the <em>name</em> parameter to the <em>snapshot.</em> prefix). The backup itself, will be created in the collection data directory by default &#8211; this is when we will not provide the desired directory using the <em>location</em> parameter. In our example, we&#8217;ve provided that parameter and use an absolute path to tell Solr where the backup should be placed.</p>
<p>The response from Solr should be fast and look similar to the following one:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;0&lt;/int&gt;&lt;int name="QTime"&gt;2&lt;/int&gt;&lt;/lst&gt;&lt;str name="status"&gt;OK&lt;/str&gt;
&lt;/response&gt;
</pre>
<p>Of course, if our collection is large, the time needed to create backup will be significantly larger. We can check the status our the backup creation by running the following command:
</p>
<pre class="brush:xml">curl 'http://localhost:8983/solr/gettingstarted/replication?command=details'
</pre>
<h3>Next indexation</h3>
<p>The next step of our simple test is another indexation &#8211; this time adding two new documents using the following command:
</p>
<pre class="brush:xml">curl 'localhost:8983/solr/gettingstarted/update?commit=true' -H 'Content-type:application/xml' --data-binary '
&lt;add&gt;
 &lt;doc&gt;
  &lt;field name="id"&gt;3&lt;/field&gt;
  &lt;field name="name"&gt;Test document 3&lt;/field&gt;
 &lt;/doc&gt;
 &lt;doc&gt;
  &lt;field name="id"&gt;4&lt;/field&gt;
  &lt;field name="name"&gt;Test document 4&lt;/field&gt;
 &lt;/doc&gt;
&lt;/add&gt;'
</pre>
<p>After the above command, if we would run a simple query like the following one:
</p>
<pre class="brush:xml">curl 'localhost:8983/solr/gettingstarted/select?q=*:*&amp;rows=0&amp;indent=true'
</pre>
<p>Solr should respond and inform us that we have four documents in total:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;
  &lt;int name="status"&gt;0&lt;/int&gt;
  &lt;int name="QTime"&gt;6&lt;/int&gt;
  &lt;lst name="params"&gt;
   &lt;str name="q"&gt;*:*&lt;/str&gt;
   &lt;str name="indent"&gt;true&lt;/str&gt;
   &lt;str name="rows"&gt;0&lt;/str&gt;
  &lt;/lst&gt;
 &lt;/lst&gt;
 &lt;result name="response" numFound="4" start="0" maxScore="1.0"&gt;
 &lt;/result&gt;
&lt;/response&gt;
</pre>
<h3>Restoring our backup</h3>
<p>Now let&#8217;s try restoring our backup and see how many documents we will have after that operation. To restore the bacup we&#8217;ve created we run the following command:
</p>
<pre class="brush:xml">curl 'http://localhost:8983/solr/gettingstarted/replication?command=restore&amp;name=test&amp;location=/Users/gro/backup/'
</pre>
<p>If everything went well, Solr response should be similar to the following one:
</p>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;&lt;int name="status"&gt;0&lt;/int&gt;&lt;int name="QTime"&gt;2&lt;/int&gt;&lt;/lst&gt;&lt;str name="status"&gt;OK&lt;/str&gt;
&lt;/response&gt;
</pre>
<p>So let&#8217;s now check how many documents are present in our collection by running the following command:
</p>
<pre class="brush:xml">curl 'localhost:8983/solr/gettingstarted/select?q=*:*&amp;rows=0&amp;indent=true'
</pre>
<pre class="brush:xml">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;response&gt;
 &lt;lst name="responseHeader"&gt;
  &lt;int name="status"&gt;0&lt;/int&gt;
  &lt;int name="QTime"&gt;0&lt;/int&gt;
  &lt;lst name="params"&gt;
   &lt;str name="q"&gt;*:*&lt;/str&gt;
   &lt;str name="indent"&gt;true&lt;/str&gt;
   &lt;str name="rows"&gt;0&lt;/str&gt;
  &lt;/lst&gt;
 &lt;/lst&gt;
 &lt;result name="response" numFound="2" start="0"&gt;
 &lt;/result&gt;
&lt;/response&gt;
</pre>
<p>As we can see, the number of documents in the collection is 2, which mean that our backup has been properly restored.</p>
<h3>Short summary</h3>
<p>As we can see, Solr backup mechanism works flawlessly, however we should remember about few things. When running a few Solr instances on the same physical machine, we should avoid doing backups using absolute paths &#8211; we can end up with shards data being overwritten. Apart from that, its good to finally have fully working and easy to use backup functionality <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2015/06/22/solr-5-2-quick-look-on-solr-backup-functionality/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
