Platform backup - neo4j - Linux via Docker


Overview

neo4j is the native graph database management system (GDBMS) that stores and manages data generated by CAST Imaging and which is installed as part of the CAST Imaging installation process. On Linux via Docker, the database is installed as a Docker container.

Since this database contains valuable application result data, you may wish to consider periodically backing it up. This document explains how to do so.

Prerequisites

  • neo4j Docker container up and running on the machine where the imaging-viewer component is installed.
  • sufficient free disk space for backup - this depends on the size of your neo4j database(s). You can determine this by calcuating the size of the /var/lib/neo4j/neo4j5_data/databases folder withing the neo4j container on disk (use the du -hs to do so): you will need an equivalent amount of free disk space to store the backup.

Step 1 - create backup folder

On the machine where the imaging-viewer component is installed, create a new folder on disk to store the backup alongside the database storage:

mkdir -p /opt/cast/installation/imaging-viewer/neo4j/neo4j5_data/data_backup

Step 2 - run the backup

Run the Neo4j backup tool from within the Docker container as follows:

docker exec -it neo4j bash
bin/neo4j-admin database backup --verbose --compress=true --include-metadata=all --pagecache=4G --to-path=/var/lib/neo4j/neo4j5_data/data_backup --from=localhost:6362 "*" > /opt/cast/installation/imaging-viewer/logs/backup_$(date +%Y%m%d_%H%M%S).log 2>&1

Where:

  • --verbose sets logging output to verbose mode.
  • --compress set this to true to ensure the backup is compressed to reduce disk space usage.
  • --include-metadata set this to all to ensure that any roles you have defined are also backed up.
  • --pagecache defaults to 8MB, so use this option to ensure you specify a large amount of RAM (e.g. 4GB) to improve performance.
  • --to-path specifies an absolute path to the target folder for the resulting backup. This folder must already exist.
  • --from defines the machine on which CAST Imaging is running - set this to localhost:6362. “6362” is the default listening port for neo4j backup operations in CAST Imaging v3 installed on Linux via Docker.
  • "*" this option will backup all databases
  • > /opt/cast/installation/imaging-viewer/logs/backup_$(date +%Y%m%d_%H%M%S).log 2>&1 use this to log the output to a date stamped .log file. The path listed is the logs folder in the default installation path for CAST Imaging v3 and is mounted as a volume within the neo4j Docker container.

Step 3 - check results

When the process has finished, check the log and resulting .backup files (one per neo4j database).