Its a common requirement that we have to keep backup and restore data/indexes of solr. Although latest versions of solr makes life a lot easier. I will explain how to do it in solr 4.x, taking simplest use case. Follow the below steps:
For Backup
Open browser and type this command in address bar
http://localhost:8983/solr/my_core/replication?command=backup&location=/tmp/backup_1&numberToKeep=1
here "my_core" is name of solr core and location is absolute path to directory where you want to create backup. in this case backup files will be created under /tmp/backup_1
For Restoration
Open Admin UI and unload my_core core from "core admin" tab.
Now manually copy the files backup files created under /tmp/backup_1 to /path-to-solr-data/my_core/data/index.
Remove 'tlog' directory under /path-to-solr-data/my_core/data.
make sure to set proper permissions like user is "solruser" and group is "solr". Following commands can be used:
[root@svc-2-solr index]# chgrp solr *
[root@svc-2-solr index]# chown solruser *
Now, go back to "core admin" tab from admin UI and click "add core". Now fill in following details:
name : my_core
instanceDir : /path-to-solr-config-install/my_core/
dataDir : /path-to-solr-data/my_core/data/index
submit the form. All set, indexes should be right back at desired place.
Add a comment