yAsH
yAsH

Reputation: 3405

Neo4j Community Edition backup in windows

Currently am using Neo4j Community version 1.8.2 with Windows 8. Is it possible to backup the neo4j community version db in windows?

Upvotes: 7

Views: 2291

Answers (4)

Cookie Monster
Cookie Monster

Reputation: 1791

Hiyo!

They may work, but neo4j is pretty explicit in their guidance:

By contrast, file system copy-and-paste of databases is not supported [1]

So! Your neo4j install path has a bin folder. In it, you have a neo4j.bat and neo4j-admin.bat. You can use these to stop the database, dump the database in a supported way, and start the database back up.

  • Make sure neo4j*.bat files know where your java is. For example, using the default chocolatey install method, you might have this file structure 'C:\tools\neo4j-community\neo4j-community-VERSION\java\jdkVERSION'. Set a JAVA_HOME environment variable as needed. e.g. in PowerShell, $ENV:JAVA_HOME = 'C:\tools\neo4j-community\neo4j-community-VERSION\java\jdkVERSION'
  • Check if it worked! C:\tools\neo4j-community\neo4j-community-3.2.3\bin\neo4j-admin.bat help. If it failed, you'll get an error message saying something like Invoke-Neo4jAdmin : Could not find java at...
  • It worked? Stop the service, back it up, start the service.

Here's a super simple example; you would want to validate paths, add error handling and so forth.

$ENV:JAVA_HOME = 'C:\tools\neo4j-community\neo4j-community-VERSION\java\jdkVERSION'
C:\tools\neo4j-community\neo4j-community-VERSION\bin\neo4j.bat stop
C:\tools\neo4j-community\neo4j-community-VERSION\bin\neo4j-admin.bat dump --database graph.db --to=C:\temp\neo4j.dump
C:\tools\neo4j-community\neo4j-community-VERSION\bin\neo4j.bat start

This code might change if you have spaces in your path, among other environment variances...

Good luck!

Upvotes: 1

fiat
fiat

Reputation: 15981

Here are my Powershell scripts for Community edition

#http://stackoverflow.com/questions/1153126/how-to-create-a-zip-archive-with-powershell
function zipFiles()
{
    param(
        [Parameter(Mandatory=$true,Position=0)]$zipfilename
        ,[Parameter(Mandatory=$true,Position=1)]$sourcedir
    )

   Add-Type -Assembly System.IO.Compression.FileSystem
   $compressionLevel = [System.IO.Compression.CompressionLevel]::Optimal
   [System.IO.Compression.ZipFile]::CreateFromDirectory($sourcedir, $zipfilename, $compressionLevel, $false)
}

#http://stackoverflow.com/questions/18612294
function BackupNeo4jCommunity
{
    param(
        [Parameter(Mandatory=$true,Position=0)]$serviceName
        ,[Parameter(Mandatory=$true,Position=1)]$sourceNeoFolder
        ,[Parameter(Mandatory=$true,Position=2)]$zipFilename
    )

    Stop-Service $serviceName

    zipFiles $zipfilename $sourceNeoFolder

    Start-Service $serviceName
}

BackupNeo4jCommunity -serviceName neoWindowsServiceName -sourceNeoFolder "D:\neo4j\myapp\data\graph.db" -zipFilename "D:\Downloads\neo-data.zip"

Upvotes: 2

Nicholas
Nicholas

Reputation: 7501

As Pangea said, the official backup tool is only available on Enterprise Edition.

His suggestion of using Windows backup tools isn't a good option unless you know other things about Neo4j. Neo4j doesn't flush information immediately, nor does Lucene, so if you use something like Windows Backup, you will not get the database in a stable backup. You need to either use the Neo4j Backup tool, or you need to shutdown the Graph Database so everything flushes/closes, then backup using Windows.

Upvotes: 8

Aravind Yarram
Aravind Yarram

Reputation: 80176

The Backup service is only available in enterprise edition. You can schedule a regular backup of the Neo4j's data files using the tools that come with Windows.

Upvotes: 0

Related Questions