Creating Solr-Index Backups Atomically

2014-07-03 | #solr, #solution, #ubuntu

Backing up a running Solr-index is somewhat complicated, but after some expanded fiddling with the present Solr-tools I came to this medium complexity solution:

1. Create a post-optimize handler in /etc/solr/conf/solrconfig.xml to call the Solr-tool "snapshooter" (I selected optimize since this should only happen from time to time in comparison to commit, but frequently enough for a recent status)


<listener event="postOptimize" class="solr.RunExecutableListener">

<str name="exe">/usr/share/solr/bin/snapshooter</str>

<str name="dir">.</str>

<bool name="wait">true</bool>

<arr name="args"> <str>-d /var/lib/solr/data/</str> </arr>



2. Copy or symlink all scripts from /usr/share/solr/scripts to /usr/share/solr/bin and make them executable, since some versions search the wrong path for the scripts.

3. Correct the rights for /usr/share/solr/logs/*.log to tomcat6:tomcat6 (or whatever server user writes those). Otherwise you might get logging errors all the time, due to missing write rights.

4. If everything went well (and you also used /var/lib/solr/data for your index) you should now find a new snapshot.xxxxxxxxx-folder next to you index on each optimize.

5. Finally you should create a script and a cron job to regularily do something with these snapshots. In our case we created a full backup from the latest snapshot, cleaned the snapshots/old backups and saved the newest backup in a dispatch dir to do something with it like transferring it somewhere safe.

Have a look at the link to an example script on the left.

6. If the "abo"-script throws a syntax error (which happens in some specific versions, due to a programmer fuckup) you'll have to directly edit and correct abo, where, at the very end of the script, a blank is missing before closing if-brackets.

something]] => something ]]