Neo4j Backup: Store copy and consistency check at Mark Needham

One of the lesser known things about the Neo4j online backup tool, which I wrote about last week, is that conceptually there are two parts to it:

  1. Copying the store files to a location of your choice
  2. Verifying that those store files are consistent.

By default both of these run when you run the ‘neo4j-backup’ script but sometimes it’s useful to be able to run them separately.

If we want to just run the copying the store files part of the process we can tell the backup tool to skip the consistency check by using the ‘verify‘ flag:

$ pwd
/Users/markneedham/Downloads/neo4j-enterprise-2.0.0
$ ./bin/neo4j-backup -from single://127.0.0.1 -to /tmp/foo -verify false
Performing full backup from 'single://127.0.0.1'
Files copied
................        done
Done

If we ran that without the ‘verify’ flag we’d see the output of the consistency checker as well:

$ ./bin/neo4j-backup -from single://127.0.0.1 -to /tmp/foo
Performing full backup from 'single://127.0.0.1'
Files copied
................        done
Full consistency check
....................  10%
....................  20%
....................  30%
....................  40%
....................  50%
....................  60%
....................  70%
....................  80%
....................  90%
.................... 100%
Done

If we already have a backup and only want to run the consistency checker we can run the following command:

$ java -cp 'lib/*:system/lib/*' org.neo4j.consistency.ConsistencyCheckTool /tmp/foo
Full consistency check
....................  10%
....................  20%
....................  30%
....................  40%
....................  50%
....................  60%
....................  70%
....................  80%
....................  90%
.................... 100%

The consistency tool itself takes a ‘config‘ flag which gives you some control over what things you want to consistency check.

The various options are defined in org.neo4j.consistency.ConsistencyCheckSettings.

For example, if we want to change the file that the consistency check report is written to we could add the following property to our config file:

$ tail -n 1 conf/neo4j.properties
consistency_check_report_file=/tmp/foo.txt

And then run the consistency tool like so:

$ java -cp 'lib/*:system/lib/*' org.neo4j.consistency.ConsistencyCheckTool -config conf/neo4j.properties /tmp/foo

If there are any inconsistencies they’ll now be written to that file rather than to a file in the store directory.

You can also pass that ‘config’ flag to the backup tool and it will make use of it when it runs the consistency check. e.g.

$ ./bin/neo4j-backup -from single://127.0.0.1 -to /tmp/foo -verify false -config conf/neo4j.properties

Most of the time you don’t need to worry too much about either of these commands but I always forget what the various options are so I thought I’d better write it up while it’s fresh in my mind.
 

Related Whitepaper:

Professional NoSQL

A hands-on guide to leveraging NoSQL databases!

NoSQL databases are an efficient and powerful tool for storing and manipulating vast quantities of data. Most NoSQL databases scale well as data grows. In addition, they are often malleable and flexible enough to accommodate semi-structured and sparse data sets. This comprehensive hands-on guide presents fundamental concepts and practical solutions for getting you ready to use NoSQL databases. Expert author Shashank Tiwari begins with a helpful introduction on the subject of NoSQL, explains its characteristics and typical uses, and looks at where it fits in the application stack. Unique insights help you choose which NoSQL solutions are best for solving your specific data storage needs.

Get it Now!  

Leave a Reply


1 + one =



Java Code Geeks and all content copyright © 2010-2014, Exelixis Media Ltd | Terms of Use | Privacy Policy
All trademarks and registered trademarks appearing on Java Code Geeks are the property of their respective owners.
Java is a trademark or registered trademark of Oracle Corporation in the United States and other countries.
Java Code Geeks is not connected to Oracle Corporation and is not sponsored by Oracle Corporation.

Sign up for our Newsletter

20,709 insiders are already enjoying weekly updates and complimentary whitepapers! Join them now to gain exclusive access to the latest news in the Java world, as well as insights about Android, Scala, Groovy and other related technologies.

As an extra bonus, by joining you will get our brand new e-books, published by Java Code Geeks and their JCG partners for your reading pleasure! Enter your info and stay on top of things,

  • Fresh trends
  • Cases and examples
  • Research and insights
  • Two complimentary e-books