Skip to content

Instantly share code, notes, and snippets.

@justintime
Created October 23, 2012 16:15
Show Gist options
  • Save justintime/3939788 to your computer and use it in GitHub Desktop.
Save justintime/3939788 to your computer and use it in GitHub Desktop.
Cleanup data directories for cores no longer served up by Solr
#!/bin/bash
#
SOLR_HOME="/srv/tomcat/rpsolr/solr"
for INDEX_DIR in `/bin/find ${SOLR_HOME} -type d -name index -exec dirname {} \;`; do
CORE=`/bin/basename ${INDEX_DIR}`
/bin/grep "<core name=\"${CORE}\"" ${SOLR_HOME}/solr.xml > /dev/null
if [ $? != 0 ]; then
echo "Removing datadir for non-existent core ${CORE}"
/bin/rm -rf ${SOLR_HOME}/${CORE}
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment