Skip to content

Commit ea1c606

Browse files
committed
Support upgrades to 8.x
1 parent a3fc1f5 commit ea1c606

File tree

3 files changed

+26
-11
lines changed

3 files changed

+26
-11
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Collection of simple tools for Solr.
77
[![Travis CI Build Status](https://travis-ci.org/cominvent/solr-tools.png)](https://travis-ci.org/cominvent/solr-tools)
88

99
## upgradeindex.sh
10-
Bash script to upgrade an entire Solr index from 4.x or 5.x or 6.x to 7.x so it can be read by Solr 6.x or Solr 7.x. See [README](./upgradeindex/README.md)
10+
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)
1111

1212
## SolrPasswordHash
1313
Simple command line tool to generate a password hash for `security.json`

upgradeindex/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
# upgradeindex.sh
22

3-
Bash script to upgrade an entire Solr index from 3.x -> 4.x -> 5.x -> 6.x -> 7.x so it can be read by Solr6.x or Solr 7.x
3+
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
44

55
## Usage:
66

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

1010
Example: ./upgradeindex.sh -t 6 /var/solr

upgradeindex/upgradeindex.sh

+23-8
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ VERSION_4=4.10.4
1212
VERSION_5=5.5.4
1313
VERSION_6=6.6.0
1414
VERSION_7=7.6.0
15+
VERSION_8=8.2.0
1516

1617
JAR_CORE_4=lucene-core-$VERSION_4.jar
1718
JAR_CORE_4_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_4/lucene-core-$VERSION_4.jar
@@ -29,17 +30,21 @@ JAR_CORE_7=lucene-core-$VERSION_7.jar
2930
JAR_CORE_7_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_7/lucene-core-$VERSION_7.jar
3031
JAR_BACK_7=lucene-backward-codecs-$VERSION_7.jar
3132
JAR_BACK_7_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_7/lucene-backward-codecs-$VERSION_7.jar
33+
JAR_CORE_8=lucene-core-$VERSION_8.jar
34+
JAR_CORE_8_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-core/$VERSION_8/lucene-core-$VERSION_8.jar
35+
JAR_BACK_8=lucene-backward-codecs-$VERSION_8.jar
36+
JAR_BACK_8_URL=http://central.maven.org/maven2/org/apache/lucene/lucene-backward-codecs/$VERSION_8/lucene-backward-codecs-$VERSION_8.jar
3237
BASEDIR=$(dirname "$0")
3338
BACKUP=true
34-
TARGET=6
39+
TARGET=8
3540
while getopts ":st:" opt; do
3641
case $opt in
3742
s)
3843
unset BACKUP
3944
;;
4045
t)
4146
TARGET=$OPTARG
42-
if [ $TARGET -ge 4 ] && [ $TARGET -le 7 ] ; then
47+
if [ $TARGET -ge 4 ] && [ $TARGET -le 8 ] ; then
4348
echo "Target version is $TARGET"
4449
else
4550
echo "Invalid target version $TARGET, must be 5 or 6"
@@ -59,10 +64,10 @@ done
5964
shift $(($OPTIND - 1))
6065

6166
if [ X$1 == X ] ; then
62-
echo "Script to Upgrade old indices from 3.x -> 4.x -> 5.x -> 6.x -> 7.x format, so it can be used with Solr 6.x or 7.x"
67+
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"
6368
echo "Usage: $0 [-s] [-t target-ver] <indexdata-root>"
6469
echo
65-
echo "Example: $0 -t 6 /var/solr"
70+
echo "Example: $0 -t 8 /var/solr"
6671
echo "Please run the tool only on a cold index (no Solr running)"
6772
echo "The script leaves a backup in <indexdata-root>/<core>/data/index_backup_<version>.tgz. Use -s to skip backup"
6873
echo "Requires wget or curl to download dependencies"
@@ -82,7 +87,7 @@ if [[ ! -f ./$JAR_CORE_4 ]] ; then
8287
exit 2
8388
fi
8489
fi
85-
for f in $JAR_BACK_4_URL $JAR_BACK_5_URL $JAR_BACK_6_URL $JAR_BACK_7_URL $JAR_CORE_4_URL $JAR_CORE_5_URL $JAR_CORE_6_URL $JAR_CORE_7_URL ; do
90+
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
8691
echo "Downloading $f"
8792
$tool $f
8893
done
@@ -94,7 +99,10 @@ CORES=$(for a in `find $DIR -name data`; do dirname $a; done);
9499

95100
function upgrade() {
96101
INDEXDIR=$1
97-
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)
102+
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)
103+
if [ X$ver == X ] ; then
104+
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)
105+
fi
98106
if [ X$ver == X ] ; then
99107
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)
100108
fi
@@ -123,8 +131,10 @@ function upgrade() {
123131
CP="$BASEDIR/$JAR_CORE_5:$BASEDIR/$JAR_BACK_5"
124132
elif [ $majorVer -lt 6 ] ; then
125133
CP="$BASEDIR/$JAR_CORE_6:$BASEDIR/$JAR_BACK_6"
126-
else
127-
CP="$BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7"
134+
elif [ $majorVer -lt 7 ] ; then
135+
CP="$BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7"
136+
else
137+
CP="$BASEDIR/$JAR_CORE_8:$BASEDIR/$JAR_BACK_8"
128138
fi
129139
if [ $majorVer -ge $TARGET ] ; then
130140
echo "- Already on version $ver, not upgrading"
@@ -151,6 +161,11 @@ function upgrade() {
151161
java -cp $BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7 org.apache.lucene.index.IndexUpgrader -delete-prior-commits $INDEXDIR
152162
majorVer=7
153163
fi
164+
if [ $majorVer -lt 8 ] && [ $TARGET -ge 8 ] ; then
165+
echo "- Upgrading 7.x -> 8.x"
166+
java -cp $BASEDIR/$JAR_CORE_7:$BASEDIR/$JAR_BACK_7 org.apache.lucene.index.IndexUpgrader -delete-prior-commits $INDEXDIR
167+
majorVer=8
168+
fi
154169
fi
155170
}
156171

0 commit comments

Comments
 (0)