groovy script for upgrading neo4j datastores
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// hackish script for upgrading a neo4j datastore | |
// uncomment one of Grab annotations below to match the desired target version of neo4j | |
def cli = new CliBuilder(usage: 'upgrade_neo4j.groovy -[h] [graphdb-directory]', | |
header: ''' | |
upgrades a Neo4j database to any desired versions. Notes: | |
* take backup before running this | |
* upgrades must be done step-by-step, e.g. 1.5 -> 1.6, 1.6 -> 1.7 | |
* to specify the upgrade for a step, enable the @Grab line in the script | |
Options:''') | |
// Create the list of options. | |
cli.with { | |
h longOpt: 'help', 'Show usage information' | |
//c longOpt: 'format-custom', args: 1, argName: 'format', 'Format date with custom format defined by "format"' | |
//f longOpt: 'format-full', 'Use DateFormat#FULL format' | |
//l longOpt: 'format-long', 'Use DateFormat#LONG format' | |
//m longOpt: 'format-medium', 'Use DateFormat#MEDIUM format (default)' | |
//s longOpt: 'format-short', 'Use DateFormat#SHORT format' | |
} | |
def options = cli.parse(args) | |
def extraArguments = options.arguments() | |
if (!options || options.h || extraArguments.size()!=1) { | |
cli.usage() | |
return | |
} | |
def dataStore = extraArguments[0] | |
// up to 1.3 Neo4j artifacts are not found in the central maven repos, so adding the Neo4j repo here | |
@GrabResolver(name='neo4j', root='http://m2.neo4j.org/content/repositories/releases/') | |
//@Grab(group='org.neo4j', module='neo4j-apoc', version='1.1') | |
//@Grab(group='org.neo4j', module='neo4j-kernel', version='1.2-1.2') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.3') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.4.2') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.5.3') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.6.3') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.7.2') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.8.3') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='1.9.8') | |
//@Grab(group='org.neo4j', module='neo4j-community', version='2.0.4') | |
@Grab(group='org.neo4j', module='neo4j-community', version='2.1.2') | |
def db = new org.neo4j.kernel.EmbeddedGraphDatabase(dataStore, [allow_store_upgrade: 'true']) | |
db.shutdown() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thanks, this was a big help