Skip to content

Instantly share code, notes, and snippets.

@djtfmartin
Created November 16, 2017 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djtfmartin/5064a77eeb7533e2d23d26c446ca51a0 to your computer and use it in GitHub Desktop.
Save djtfmartin/5064a77eeb7533e2d23d26c446ca51a0 to your computer and use it in GitHub Desktop.
Index sync script
import groovy.json.JsonSlurper
statusUrl = new URL("http://XXXXXXXX:8983/solr/admin/collections?action=clusterstatus&wt=json")
slurper = new JsonSlurper()
json = slurper.parseText(statusUrl.text)
collectionName = "biocache"
println("Parsing")
json.cluster.collections.biocache.shards.each { shard ->
shardID = shard.key.replaceAll("shard", "")
println("############# shard ${shardID}")
shard.getValue().replicas.each { replica ->
address = replica.getValue().node_name.replaceAll(":8983_solr","")
coreName = replica.getValue().core
println("""ssh -o StrictHostKeyChecking=no ${address} "rm -Rf /data/solr-backup/${coreName}" \\""")
println("""&& ssh -o StrictHostKeyChecking=no ${address} "mkdir /data/solr-backup/${coreName}" \\""")
println("""&& ssh -o StrictHostKeyChecking=no ${address} "mv /data/solr/${coreName}/* /data/solr-backup/${coreName}/" """)
println("""\n\nscp -o StrictHostKeyChecking=no -r /data/solr/biocache/* ${address}:/data/solr/${coreName}""")
println()
println()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment