Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*

.idea/
*.iml
*.iws
.DS_Store

dependency-reduced-pom.xml

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Collection of simple tools for Solr.
[![Travis CI Build Status](https://travis-ci.org/cominvent/solr-tools.png)](https://travis-ci.org/cominvent/solr-tools)

## upgradeindex.sh
Bash script to upgrade an entire Solr index from 4.x or 5.x to 6.x so it can be read by Solr6.x or Solr 7.x. See [README](./upgradeindex/README.md)
Bash script to upgrade an entire Solr index from 4.x or 5.x or 6.x or 7.x to 8.x so it can be read by Solr 6.x, Solr 7.x or Solr 8.x. See [README](./upgradeindex/README.md)

## SolrPasswordHash
Simple command line tool to generate a password hash for `security.json`
Expand Down
4 changes: 2 additions & 2 deletions upgradeindex/README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# upgradeindex.sh

Bash script to upgrade an entire Solr index from 3.x -> 4.x -> 5.x -> 6.x so it can be read by Solr6.x or Solr 7.x
Bash script to upgrade an entire Solr index from 3.x -> 4.x -> 5.x -> 6.x -> 7.x -> 8.x so it can be read by Solr6.x, Solr 7.x or Solr 8.x

## Usage:

Script to Upgrade old indices from 3.x -> 4.x -> 5.x -> 6.x format, so it can be used with Solr 6.x or 7.x
Script to Upgrade old indices from 3.x -> 4.x -> 5.x -> 6.x -> 7.x -> 8.x format, so it can be used with Solr 6.x, 7.x or 8.x
Usage: ./upgradeindex.sh [-s] [-t target-ver] <indexdata-root>

Example: ./upgradeindex.sh -t 6 /var/solr
Expand Down
58 changes: 44 additions & 14 deletions upgradeindex/upgradeindex.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,40 @@
VERSION_4=4.10.4
VERSION_5=5.5.4
VERSION_6=6.6.0
VERSION_7=7.6.0
VERSION_8=8.2.0

JAR_CORE_4=lucene-core-$VERSION_4.jar
JAR_CORE_4_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_4/lucene-core-$VERSION_4.jar
JAR_CORE_4_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_4/lucene-core-$VERSION_4.jar
JAR_BACK_4=lucene-backward-codecs-$VERSION_4.jar
JAR_BACK_4_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_4/lucene-backward-codecs-$VERSION_4.jar
JAR_BACK_4_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_4/lucene-backward-codecs-$VERSION_4.jar
JAR_CORE_5=lucene-core-$VERSION_5.jar
JAR_CORE_5_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_5/lucene-core-$VERSION_5.jar
JAR_CORE_5_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_5/lucene-core-$VERSION_5.jar
JAR_BACK_5=lucene-backward-codecs-$VERSION_5.jar
JAR_BACK_5_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_5/lucene-backward-codecs-$VERSION_5.jar
JAR_BACK_5_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_5/lucene-backward-codecs-$VERSION_5.jar
JAR_CORE_6=lucene-core-$VERSION_6.jar
JAR_CORE_6_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_6/lucene-core-$VERSION_6.jar
JAR_CORE_6_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_6/lucene-core-$VERSION_6.jar
JAR_BACK_6=lucene-backward-codecs-$VERSION_6.jar
JAR_BACK_6_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_6/lucene-backward-codecs-$VERSION_6.jar
JAR_BACK_6_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_6/lucene-backward-codecs-$VERSION_6.jar
JAR_CORE_7=lucene-core-$VERSION_7.jar
JAR_CORE_7_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_7/lucene-core-$VERSION_7.jar
JAR_BACK_7=lucene-backward-codecs-$VERSION_7.jar
JAR_BACK_7_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_7/lucene-backward-codecs-$VERSION_7.jar
JAR_CORE_8=lucene-core-$VERSION_8.jar
JAR_CORE_8_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_8/lucene-core-$VERSION_8.jar
JAR_BACK_8=lucene-backward-codecs-$VERSION_8.jar
JAR_BACK_8_URL=https://repo1.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_8/lucene-backward-codecs-$VERSION_8.jar
BASEDIR=$(dirname "$0")
BACKUP=true
TARGET=6
TARGET=8
while getopts ":st:" opt; do
case $opt in
s)
unset BACKUP
;;
t)
TARGET=$OPTARG
if [ $TARGET -ge 4 ] && [ $TARGET -le 6 ] ; then
if [ $TARGET -ge 4 ] && [ $TARGET -le 8 ] ; then
echo "Target version is $TARGET"
else
echo "Invalid target version $TARGET, must be 5 or 6"
Expand All @@ -54,10 +64,10 @@ done
shift $(($OPTIND - 1))

if [ X$1 == X ] ; then
echo "Script to Upgrade old indices from 3.x -> 4.x -> 5.x -> 6.x format, so it can be used with Solr 6.x or 7.x"
echo "Script to Upgrade old indices from 3.x -> 4.x -> 5.x -> 6.x -> 7.x -> 8.x format, so it can be used with Solr 6.x, 7.x, 8.x"
echo "Usage: $0 [-s] [-t target-ver] <indexdata-root>"
echo
echo "Example: $0 -t 6 /var/solr"
echo "Example: $0 -t 8 /var/solr"
echo "Please run the tool only on a cold index (no Solr running)"
echo "The script leaves a backup in <indexdata-root>/<core>/data/index_backup_<version>.tgz. Use -s to skip backup"
echo "Requires wget or curl to download dependencies"
Expand All @@ -77,7 +87,7 @@ if [[ ! -f ./$JAR_CORE_4 ]] ; then
exit 2
fi
fi
for f in $JAR_BACK_4_URL $JAR_BACK_5_URL $JAR_BACK_6_URL $JAR_CORE_4_URL $JAR_CORE_5_URL $JAR_CORE_6_URL ; do
for f in $JAR_BACK_4_URL $JAR_BACK_5_URL $JAR_BACK_6_URL $JAR_BACK_7_URL $JAR_BACK_8_URL $JAR_CORE_4_URL $JAR_CORE_5_URL $JAR_CORE_6_URL $JAR_CORE_7_URL $JAR_CORE_8_URL ; do
echo "Downloading $f"
$tool $f
done
Expand All @@ -89,7 +99,13 @@ CORES=$(for a in `find $DIR -name data`; do dirname $a; done);

function upgrade() {
INDEXDIR=$1
ver=$(java -cp $BASEDIR/$JAR_CORE_6:$BASEDIR/$JAR_BACK_6 org.apache.lucene.index.CheckIndex -fast $INDEXDIR|grep " version="|sed -e 's/.*=//g'|head -1)
ver=$(java -cp $BASEDIR/$JAR_CORE_8:$BASEDIR/$JAR_BACK_8 org.apache.lucene.index.CheckIndex -fast $INDEXDIR|grep " version="|sed -e 's/.*=//g'|head -1)
if [ X$ver == X ] ; then
ver=$(java -cp $BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7 org.apache.lucene.index.CheckIndex -fast $INDEXDIR|grep " version="|sed -e 's/.*=//g'|head -1)
fi
if [ X$ver == X ] ; then
ver=$(java -cp $BASEDIR/$JAR_CORE_6:$BASEDIR/$JAR_BACK_6 org.apache.lucene.index.CheckIndex -fast $INDEXDIR|grep " version="|sed -e 's/.*=//g'|head -1)
fi
if [ X$ver == X ] ; then
ver=$(java -cp $BASEDIR/$JAR_CORE_5:$BASEDIR/$JAR_BACK_5 org.apache.lucene.index.CheckIndex -fast $INDEXDIR|grep " version="|sed -e 's/.*=//g'|head -1)
fi
Expand All @@ -113,8 +129,12 @@ function upgrade() {
CP="$BASEDIR/$JAR_CORE_4:$BASEDIR/$JAR_BACK_4"
elif [ $majorVer -lt 5 ] ; then
CP="$BASEDIR/$JAR_CORE_5:$BASEDIR/$JAR_BACK_5"
else
elif [ $majorVer -lt 6 ] ; then
CP="$BASEDIR/$JAR_CORE_6:$BASEDIR/$JAR_BACK_6"
elif [ $majorVer -lt 7 ] ; then
CP="$BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7"
else
CP="$BASEDIR/$JAR_CORE_8:$BASEDIR/$JAR_BACK_8"
fi
if [ $majorVer -ge $TARGET ] ; then
echo "- Already on version $ver, not upgrading"
Expand All @@ -136,6 +156,16 @@ function upgrade() {
java -cp $BASEDIR/$JAR_CORE_6:$BASEDIR/$JAR_BACK_6 org.apache.lucene.index.IndexUpgrader -delete-prior-commits $INDEXDIR
majorVer=6
fi
if [ $majorVer -lt 7 ] && [ $TARGET -ge 7 ] ; then
echo "- Upgrading 6.x -> 7.x"
java -cp $BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7 org.apache.lucene.index.IndexUpgrader -delete-prior-commits $INDEXDIR
majorVer=7
fi
if [ $majorVer -lt 8 ] && [ $TARGET -ge 8 ] ; then
echo "- Upgrading 7.x -> 8.x"
java -cp $BASEDIR/$JAR_CORE_8:$BASEDIR/$JAR_BACK_8 org.apache.lucene.index.IndexUpgrader -delete-prior-commits $INDEXDIR
majorVer=8
fi
fi
}

Expand All @@ -155,4 +185,4 @@ else
fi
done
echo "DONE"
fi
fi