What is the best practice to backup a lucene index without taking the index offline (hot backup)?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You don’t have to stop your IndexWriter in order to take a backup of the index.
Just use the SnapshotDeletionPolicy, which lets you “protect” a given commit point (and all files it includes) from being deleted. Then, copy the files in that commit point to your backup, and finally release the commit.
It’s fine if the backup takes a while to run — as long as you don’t release the commit point with SnapshotDeletionPolicy, the IndexWriter will not delete the files (even if, eg, they have since been merged together).
This gives you a consistent backup which is a point-in-time image of the index without blocking ongoing indexing.
I wrote about this in Lucene in Action (2nd edition), and there’s paper excerpted from the book available (free) from http://www.manning.com/hatcher3, “Hot Backups with Lucene”, that describes this in more detail.