Search code examples
pythonneo4jpy2neo

Py2neo - Rollback to previous state


I need a way to reach a previous state of the graph (i.e undo X number of changes).

Is it possible to store the data, so that later you can replace the graph by that copy? Or is it possible to export the graph to a file and then load a graph from it?


Solution

  • I see three possible ways of doing it, completely independent of py2neo :

    Method 1: Simple copy of the store files :

    cp -R data/graph.db data/backup
    

    Method 2: Run the backup command :

    http://neo4j.com/docs/stable/backup-embedded-and-server.html

    mkdir /mnt/backup/neo4j-backup
    ./bin/neo4j-backup -host 192.168.1.34 -to /mnt/backup/neo4j-backup
    

    Method 3: Run the experimental Cypher dump command :

    Create a dump of your db

    ./bin/neo4j-shell -c 'dump MATCH (n) OPTIONAL MATCH (n)-[r]-() RETURN r,n' > export.cql
    

    For reimporting your graph, drop your db with Cypher, then :

    ./bin/neo4j-shell -file export.cql