<?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>backup &#8211; Solr.pl</title>
	<atom:link href="https://solr.pl/en/tag/backup-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>
		<item>
		<title>Backing Up Your Index</title>
		<link>https://solr.pl/en/2012/08/13/backing-up-your-index/</link>
					<comments>https://solr.pl/en/2012/08/13/backing-up-your-index/#respond</comments>
		
		<dc:creator><![CDATA[Rafał Kuć]]></dc:creator>
		<pubDate>Mon, 13 Aug 2012 21:51:12 +0000</pubDate>
				<category><![CDATA[Solr]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[handler]]></category>
		<category><![CDATA[index]]></category>
		<category><![CDATA[replication]]></category>
		<guid isPermaLink="false">http://sematext.solr.pl/?p=472</guid>

					<description><![CDATA[Did you ever wonder if you can create a backup of your index with the tools available in Solr ? For exmaple after every commit or optimize operation ? Or may you would like to create backups with the HTTP]]></description>
										<content:encoded><![CDATA[<p>Did you ever wonder if you can create a backup of your index with the tools available in Solr ? For exmaple after every <em>commit</em> or <em>optimize</em> operation ? Or may you would like to create backups with the HTTP API call ? Lets see what possibilities Solr has to offer.</p>
<p><span id="more-472"></span></p>
<h3>The Beginning</h3>
<p>We decided to write about index backups even though this functionality is fairly simple. We noticed that many people tend to forget about this functionality, not only when it comes to Apache Solr. We hope that this blog entry, will help you remember about backup creation functionality, when you need it. But now, lets start from the beginning &#8211; before we started the tests, we looked at the directory where Solr keeps its indices and this is what we saw:
</p>
<pre class="brush:bash">drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 20:17 index
drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 20:16 spellchecker</pre>
<h3>Manual Backup</h3>
<p>In order to create a backup of your index with the use of HTTP API you have to have replication handler configured. If you have it, then you need to send the <em>command</em> parameter with <em>backup</em> value to the master server replication handler, for example like this:
</p>
<pre class="brush:xml">curl 'http://localhost:8983/solr/replication?command=backup'</pre>
<p>The above will tell Solr to create a new backup of the current index. Lets now look how the directory where indices live looks like after running the above command:
</p>
<pre class="brush:bash">drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 20:18 index
drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 20:19 snapshot.20120812201917
drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 20:16 spellchecker</pre>
<p>As you can see, there is a new directory created &#8211; <em>snapshot.20120812201917</em>. We can assume, that we got what we wanted <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>
<h3>Automatic Backup</h3>
<p>In addition to manual backup creation, you can also configure Solr to create indices after <em>commit</em> or <em>optimize</em> operation. Please remember though, that if your index is changing rapidly it is usually a bad idea to create backup after each&nbsp;commit operation.&nbsp; But lets get back to automatic backups. In order to configure Solr to create backups for us, you need to add the following line to replication handler configuration:
</p>
<pre class="brush:xml">&lt;str name="backupAfter"&gt;commit&lt;/str&gt;</pre>
<p>So, the full replication handler configuration (on the <em>master</em> server) would look like this:
</p>
<pre class="brush:xml">&lt;requestHandler name="/replication" &gt;
 &lt;lst name="master"&gt;
  &lt;str name="replicateAfter"&gt;commit&lt;/str&gt;
  &lt;str name="replicateAfter"&gt;startup&lt;/str&gt;
  &lt;str name="confFiles"&gt;schema.xml,stopwords.txt&lt;/str&gt;
  &lt;str name="backupAfter"&gt;commit&lt;/str&gt;
 &lt;/lst&gt;
&lt;/requestHandler&gt;</pre>
<p>After sending two <em>commit</em> operation our dictionary with indices looks like this:
</p>
<pre class="brush:bash">drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 21:12 index
drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 21:12 snapshot.20120812211203
drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 21:12 snapshot.20120812211216
drwxrwxr-x 2 gr0 gr0 4096 2012-08-12 20:16 spellchecker</pre>
<p>As you can see, Solr did what we wanted to be done.</p>
<h3>Keeping Order</h3>
<p>It is possible to control the maximum amount of backups that should be stored on disk. In order to configure that number you need to add the following line to your replication handler configuration:
</p>
<pre class="brush:xml">&lt;str name="maxNumberOfBackups"&gt;10&lt;/str&gt;</pre>
<p>The above configuration value tells Solr to keep maximum of ten backups of your index. Of course you can delete created backups (manually for example) if you don&#8217;t need them anymore.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://solr.pl/en/2012/08/13/backing-up-your-index/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
