Back up and restore Solr using CSV export and import

This is really easy to do, if you first SSH into the destination machine (assuming the Solr configs exist):

curl -o books.csv "http://:8983/solr/books/select?q=*%3A*&wt=csv&rows=10000000"

curl "http://localhost:8983/solr/admin/cores?action=CREATE&name=books"

 curl "http://localhost:8983/solr/books/update?stream.file=/home/gary/books.csv&stream.contentType=text/csv
;charset=utf-8&skip=_version_&commit=true"

Important notes:

  • If you are upgrading and copied the Solr configs, you need to delete the data directory or the core won’t load (due to Lucene being out of date)
  • If you export/import this way, you get _version_ included, which is an internal field – that’s why it gets skipped on the second step
  • This will obviously only work if you have the field data stored in the source solr

Leave a Reply

Your email address will not be published. Required fields are marked *