Skip to content

Instantly share code, notes, and snippets.

Last active October 9, 2015 17:28
Show Gist options
  • Save sarmbruster/3011606 to your computer and use it in GitHub Desktop.
Save sarmbruster/3011606 to your computer and use it in GitHub Desktop.
groovy script for upgrading neo4j datastores
// 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
// 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) {
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='')
//@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'])
Copy link

thanks, this was a big help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment