Skip to main content

Solr backup script

#!/bin/bash
solr_home="/app/solr"
solr_backup_folder="/solr_backup"
solr_user_name="solr"

cd $solr_home

cat $solr_home"/solr.xml" | while read line
do
indtag1="corename=\""
indtag2="\"instanceDir"
instag1="instanceDir=\""
instag2="\"/>"
line=$(echo $line|sed 's/ //g');
indprefix=${line%$indtag1*}
indsuffix=${line#*$indtag2}
indnoprefix=${line#$indprefix$indtag1}
insprefix=${line%$instag1*}
inssuffix=${line#*$instag2}
insnoprefix=${line#$insprefix$instag1}

if [ ! "$indnoprefix" == "$line" ]
then
index_name=${indnoprefix%$indtag2$indsuffix}
instance_dir=${insnoprefix%$instag2$inssuffix}
sh bin/backup -d $index_name/data -u $solr_user_name -v
sh bin/backupcleaner -N 1 -d $index_name/data -u $solr_user_name -v
cp -frp $instance_dir"data/backup.*" $solr_backup_folder/$index_name/
cp -frp $instance_dir"conf" $solr_backup_folder/$index_name/"conf."$today
fi

done

echo ""
echo "Backup process is completed. Please check log files."

Comments

Popular posts from this blog