Managing Neo4j Backups and Restores Using NFS ObjectStore

Updated

You can use NFS ObjectStore as a repository for your Neo4j backups.

After you perform the initial NFS ObjectStore configuration, you can mount the NFS ObjectStore on the Neo4j client, and then perform backup and restore operations using the command line interface.

Before You Begin

  1. If you have not already done so, perform the NFS ObjectStore configuration. For more information, see Getting Started with NFS ObjectStore.

  2. Mount the NFS ObjectStore share on the Neo4j client. The Neo4j backup will be stored on this share.

Backups

You can back up a Neo4j database in online or offline mode.

Backups in Online Mode

To back up a Neo4j instance in online mode, you need an Enterprise edition. You can perform full and incremental backups in online mode. For a causal cluster, you can perform a backup on a read replica.

  • On the command line, run the following command:

    neo4j-admin backup --database=dbname --backup-dir=NFSmount --from=host_IP:backup_port

A full backup is performed initially for the first time into a target location. Subsequent backups will attempt to use the incremental mode, where just the delta of the transaction logs since the last backup are transferred and applied onto the target location.

Backups in Offline Mode

You can back up a Neo4j instance, in offline mode, using dump and load commands. You can perform only full backups in offline mode.

  1. Dump the database using the following commands:

    stop database db_name

    neo4j-admin dump --database=dbname --to=/NFSmount/dbname.dump
  2. Load the database using the following commands:

    drop database dbname

    neo4j-admin load --from=/NFSmount/dbname.dump --database=dbname #You must run this command on all the core servers.

    create database dbname
  3. Unbind without dropping a database using the following commands:

    stop database dbname;

    neo4j-admin unbind

    neo4j-admin load --from=/NFSmount/dbname.dump --database=dbname --force

    start database dbname;

Restores

You can restore a standalone server or a causal cluster.

Note:

  • Data can be restored only from recent backups.

  • Point in time recovery can be achieved by keeping backup copies at different stages and then restoring the backup copies.

Standalone Server Restore

You can restore Neo4j data from the NFS mount point.

  1. If the server is running, shut it down using the following command:

    neo4j stop
  2. For each Neo4j database, run the following command:

    neo4j-admin restore --from=/NFSmount/dbname --database=dbname --force
  3. Start the server using the following command:

    neo4j start

Causal Cluster Restore

You can restore a causal cluster from Neo4j backups.

Note: When restoring a backup on a core server where a database of the same name already exists, you must execute DROP DATABASE first. If you are unable to (such as, when Neo4j is not running), you must run neo4j-admin unbind first instead. If you fail to do this, the store files you have (post restore) will be out of sync with the cluster state you have for that database, leading to logical corruption.

  1. Drop the database using the following command:

    Drop database dbname;
  2. Shut down all server instances in the cluster using the following command:

    neo4j stop
  3. On each of the core servers, run the following command:

    neo4j-admin unbind
  4. On each instance, restore the backups using the following command:

    neo4j-admin restore --from=/NFSmount/dbname --database=dbname
  5. Start all the server instances using the following command:

    neo4j start
  6. Create the restored database using the following command:

    Create database dbname