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
neo4jDocker container up and running on the machine where theimaging-viewercomponent 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/databasesfolder withing the neo4j container on disk (use thedu -hsto 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
The path listed above is the default installation path for CAST Imaging v3 and is mounted as a volume within the
neo4j Docker container.
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:
--verbosesets logging output to verbose mode.--compressset this totrueto ensure the backup is compressed to reduce disk space usage.--include-metadataset this toallto ensure that any roles you have defined are also backed up.--pagecachedefaults to 8MB, so use this option to ensure you specify a large amount of RAM (e.g. 4GB) to improve performance.--to-pathspecifies an absolute path to the target folder for the resulting backup. This folder must already exist.--fromdefines the machine on which CAST Imaging is running - set this tolocalhost: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>&1use this to log the output to a date stamped.logfile. The path listed is thelogsfolder in the default installation path for CAST Imaging v3 and is mounted as a volume within theneo4jDocker container.
See also https://neo4j.com/docs/operations-manual/5/backup-restore/online-backup/ for more information.
Step 3 - check results
When the process has finished, check the log and resulting .backup files (one per neo4j database).
The first time you run a backup, a “full” backup is performed which can take significant time depending on your database size. Subsequent backups to the same targer folder will be differential (incremental), only backing up data that has changed since the last backup. Running backups on a daily basis will therefore result in much faster backup operations after the initial full backup.