Ben Mordue
Ben Mordue

Reputation: 477

How to recover Neo4J 3.0 database from transaction log?

After an accidental MATCH (n) DETACH DELETE (n), is it possible to restore the database using the transaction log? I believe my graph.db/neostore.transaction.db.0 represents the complete transaction history of the database.

Upvotes: 0

Views: 1006

Answers (2)

tNewhomes
tNewhomes

Reputation: 33

To partially apply transaction logs you can use the DatabaseRebuildTool as mentioned above until version 3.4. The tools were made private in commit f2ceb1a5.
To use the RebuildTool you can follow the steps below (tested on Windows for 3.3.9).
A fork with the changes in version 3.3 can be found here.

  • clone neo4j
  • checkout the required version
  • modify tools\pom.xml to include an execution for DatabaseRebuildTool (copy one and change class to org.neo4j.tools.applytx.DatabaseRebuildTool, replace id and fileName with dbrebuild)
  • build neo4j according to the instructions given in the Readme for your version
  • cd to tools
  • duplicate checkTxLogs.bat and rename to dbrebuild.bat
  • Change class in dbrebuild.bat to match DatabaseRebuildTool to org.neo4j.tools.applytx.DatabaseRebuildTool
  • Run dbrebuild.bat with required args, or no args to print help (may take some seconds)

    dbrebuild.bat --from path\to\graph.db --to path\to\new.db -i --overwrite-to

  • apply transactions up to desired transaction id or latest (help, exit)

    apply last

Note: before starting neo4j with the new database you have to exit the dbrebuild process as only one process may access the database at a time.

Upvotes: 3

Related Questions