If you have heard of docker, you will be aware that it provides deployment easy approach. There are other benefits as well. If you want to install neo4j server with ready-made configuration, docker is a candidate choice.
Refer here and follow the instruction step by step
Below commond mount $HOME/ne04j folder in host machine for
Database storage
Logs
Import path
plugins
Also, it opens up host port for bolt and http access. Also it sets up the credential for remote access.
Example command for docker container
neo4jadmin@ranchimall4:~$ sudo docker run --restart=always --name neo4jprod -p7474:7474 -p7687:7687 -d -v $HOME/neo4j/data:/data -v $HOME/neo4j/logs:/logs -v $HOME/neo4j/import:/var/lib/neo4j/import -v $HOME/neo4j/plugins:/plugins --env NEO4J_AUTH=neo4j/test --env NEO4J_dbms_connector_bolt_advertised__address=<HOST IP address>:7687 neo4j:4.0.1
After running docker, check in the same machine if neo4j is accessible locally (Ref: below screenshot). URL is http://localhost:7474
This response indicates that setup is good
Try out setup
root@ranchimall4:~# curl http://localhost:7474
{
"data" : "http://localhost:7474/db/data/",
"management" : "http://localhost:7474/db/manage/",
"bolt" : "bolt://localhost:7687"
}root@ranchimall4:~#
From your PC, access the neo4j page (http://<host machine IP>:7474). You should see the client page as shown in below screenshot
Default password is test. After login, use :server change-password for setting new password (Refer: below screenshot)
Note: There are other approaches as well. But, since you are running neo4j as docker container, it is better to use web UI shown below to change the password.
Any configuration value (see Section A.1, “Configuration settings”) can be passed using the following naming scheme:
Prefix with NEO4J_.
Underscores must be written twice: _ is written as __.
Periods are converted to underscores: . is written as _.
As an example, dbms.tx_log.rotation.size could be set by specifying the following argument to Docker:
--env NEO4J_dbms_tx__log_rotation_size
Ref: https://neo4j.com/docs/operations-manual/current/docker/configuration/ and https://neo4j.com/developer/docker-run-neo4j/
Need domain name
Refer LetSEncrypt for generation of certificate based on the domain name
Create folder structure for certificate
Copy certificates from lets encrypt and create below example folder
cert.pem -> public.crt
privkey.pem -> private.key
cert.pem -> trusted/cert.pem
Run server
Example docker config for HTTPS
neo4jadmin@ranchimall4:~/neo4jrepo/serverconfig$ cat prod_http_server.sh
sudo docker run -dt --name prod_neo4j \
-p 7473:7473 -p 7474:7474 -p 7687:7687 \
-v $HOME/prodneo4j/certificates:/certificates \
-v $HOME/prodneo4j/data:/data \
-v $HOME/prodneo4j/logs:/logs \
-v $HOME/prodneo4j/import:/import \
-v $HOME/prodneo4j/plugins:/plugins \
-e NEO4J_dbms_connector_https_enabled=true \
-e NEO4J_dbms_ssl_policy_https_enabled=true \
-e NEO4J_AUTH=neo4j/test \
-e NEO4J_dbms_connector_bolt_advertised__address=sarvat.com:8687 \
-e NEO4J_dbms_connector_https_advertised__address=sarvat.com:8473 \
-e NEO4J_transaction_security_ssl_enabled=true \
-e NEO4J_dbms_connector_https_listen__address=:7473 \
-e NEO4J_https_ssl__policy=default \
-e NEO4J_bolt_ssl__policy=default \
-e NEO4J_dbms_connector_bolt_tls__level=REQUIRED \
-e NEO4J_dbms_ssl_policy_default_base__directory=/certificates \
-e NEO4J_dbms_ssl_policy_bolt_base__directory=/certificates \
-e NEO4J_dbms_ssl_policy_https_base__directory=/certificates/https \
-e NEO4J_dbms_ssl_policy_default_private__key=/certificates/https/private.key \
-e NEO4J_dbms_ssl_policy_default_public__certificate=/certificates/https/public.crt \
-e NEO4J_dbms_ssl_policy_default_client__auth=none \
--user="$(id -u):$(id -g)" \
neo4j:4.0.1
Testing if the server is working
Use "curl -k https://localhost:7473"
Refer below screenshot
This feature is available in free version. It is used for backup/restore at here
Dump database from the source machine. Refer below command for the neo4j terminal (Ref: screenshot below)
bin/neo4j-admin dump --database=neo4j --to=<distination absolute path with dump file name>
Refer here for the restore script
To load database to docker container based Neo4j, refer https://serverfault.com/questions/935016/loading-neo4j-dump-in-docker-container
Please refer below example screenshot
Refer https://github.com/krdpk17/neo4j-docker
Dump docker script example
#!/usr/bin/env bash
BASEDIR="/home/neo4jadmin"
BACKUP_NEO4J_SVR_NAME="neo4jtest"
BACKUP_NEO4J_SVR_NAME_TEMP="neo4jtestdump"
BACKUP_NEO4J_DIR_PATH=${BACKUP_NEO4J_DIR_PATH:-"/backup/neo4j_dump.dump"}
BACKUP_NEO4J_DIR_HOSTPATH="$BASEDIR/neo4jtest/backup/neo4j_dump.dump"
BACKUP_NEO4J_DIR_HOSTPATH_BKP="$BASEDIR/neo4jtest/backup/neo4j_dump.dump_bkp"
echo running script $PWD/$0
echo "starting backup at" `date`
mv ${BACKUP_NEO4J_DIR_HOSTPATH} ${BACKUP_NEO4J_DIR_HOSTPATH_BKP}
docker stop ${BACKUP_NEO4J_SVR_NAME}
echo "stopped server for backup at" `date`
docker run --rm -i --name ${BACKUP_NEO4J_SVR_NAME_TEMP} -v $BASEDIR/neo4jtest/data:/data -v $BASEDIR/neo4jtest/backup:/backup neo4j:4.0.1 /bin/bash -c "bin/neo4j-admin dump --database=neo4j --to=${BACKUP_NEO4J_DIR_PATH}"
echo "finished backup at" `date`
#Restore the folder user and group ownership
chown -R neo4jadmin ~/neo4jtest/data
chgrp -R neo4jadmin ~/neo4jtest/data
sleep 2
docker start ${BACKUP_NEO4J_SVR_NAME}
echo "restarted server at" `date`
export VISUAL=vim;crontab -u ${USER} -e -> For editing crontab file
Ensure that you are editing root user crontab(Ref:below example). It is needed since docker run command needs root privilege. This example does every one second. In reality it should be at night time once every day only.
Note that this feature needs enterprise version docker container which is paid version.
Go to the docker container shell and then user neo4j-admin guide for performing backup (Ref: below screenshot)
First time backup and subsequent backup
neo4jadmin@ranchimall4:~/backup$ sudo docker exec -it neo4jtest bash -> Goto neo4jtest shell
root@b50eb2110ccf:/var/lib/neo4j# bin/neo4j-admin --help
Usage: neo4j-admin [-hV] [COMMAND]
Neo4j database administration tool.
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
Commands:
help Displays help information about the specified command
backup Perform an online backup from a running Neo4j enterprise server.
store-info Print information about a Neo4j database store.
report Produces a zip/tar of the most common information needed for remote assessments.
set-default-admin Sets the default admin user.
This user will be granted the admin role on startup if the system has no roles.
set-initial-password Sets the initial password of the initial admin user ('neo4j'). And removes the requirement to
change password on first login.
memrec Print Neo4j heap and pagecache memory settings recommendations.
dump Dump a database into a single-file archive.
copy Copy a database and optionally apply filters.
load Load a database from an archive created with the dump command.
check-consistency Check the consistency of a database.
import Import a collection of CSV files.
restore Restore a backed up database.
unbind Removes cluster state data for the specified database.
root@b50eb2110ccf:/var/lib/neo4j# cat conf/
jmx.access jmx.password neo4j.conf
root@b50eb2110ccf:/var/lib/neo4j# cat conf/
jmx.access jmx.password neo4j.conf
root@b50eb2110ccf:/var/lib/neo4j# cat conf/neo4j.conf | grep backup
# Enable online backups to be taken from this database.
#dbms.backup.enabled=true
# By default the backup service will only listen on localhost.
# To enable remote backups you will have to bind to an external
#dbms.backup.listen_address=0.0.0.0:6362
# <scope> can be any of 'bolt', 'https', 'cluster' or 'backup'
# Allowable values are 'bolt', 'https', 'cluster' or 'backup'.
#dbms.ssl.policy.backup.enabled=true
#dbms.ssl.policy.backup.base_directory=certificates/backup
#dbms.ssl.policy.backup.private_key=private.key
#dbms.ssl.policy.backup.public_certificate=public.crt
# Please note that it is also possible to run the backup client against this port so always limit access to it via the
# Retention policy for transaction logs needed to perform recovery and backups.
dbms.backup.listen_address=0.0.0.0:6362
dbms.backup.enabled=true
First time backup run below
root@b50eb2110ccf:/var/lib/neo4j# mkdir neo4j-backups
root@b50eb2110ccf:/var/lib/neo4j# bin/neo4j-admin backup --backup-dir=neo4j-backups --pagecache=4G
2020-05-04 23:54:03.371+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store files
2020-05-04 23:54:03.376+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.nodestore.db.labels
2020-05-04 23:54:03.436+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.nodestore.db.labels
2020-05-04 23:54:03.436+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.nodestore.db
2020-05-04 23:54:03.446+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.nodestore.db
2020-05-04 23:54:03.446+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.index.keys
2020-05-04 23:54:03.456+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.index.keys
2020-05-04 23:54:03.456+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.index
2020-05-04 23:54:03.470+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.index
2020-05-04 23:54:03.470+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.strings
2020-05-04 23:54:03.481+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.strings
2020-05-04 23:54:03.489+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.arrays
2020-05-04 23:54:03.501+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db.arrays
2020-05-04 23:54:03.501+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db
2020-05-04 23:54:03.521+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.propertystore.db
2020-05-04 23:54:03.521+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshipstore.db
2020-05-04 23:54:03.530+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshipstore.db
2020-05-04 23:54:03.531+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshiptypestore.db.names
2020-05-04 23:54:03.539+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshiptypestore.db.names
2020-05-04 23:54:03.540+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshiptypestore.db
2020-05-04 23:54:03.548+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshiptypestore.db
2020-05-04 23:54:03.549+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.labeltokenstore.db.names
2020-05-04 23:54:03.560+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.labeltokenstore.db.names
2020-05-04 23:54:03.560+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.labeltokenstore.db
2020-05-04 23:54:03.568+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.labeltokenstore.db
2020-05-04 23:54:03.568+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.schemastore.db
2020-05-04 23:54:03.577+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.schemastore.db
2020-05-04 23:54:03.577+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshipgroupstore.db
2020-05-04 23:54:03.659+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore.relationshipgroupstore.db
2020-05-04 23:54:03.660+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore
2020-05-04 23:54:03.672+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /var/lib/neo4j/neo4j-backups/neo4j/neostore
2020-05-04 23:54:03.677+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store files, took 296ms
2020-05-04 23:54:03.680+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving transactions from 5
2020-05-04 23:54:04.311+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving transactions at 6, took 630ms
Index structure consistency check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Full Consistency Check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
............Checking node and relationship counts
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Backup complete.
root@b50eb2110ccf:/var/lib/neo4j# ls neo4j-backups/neo4j/
neostore neostore.propertystore.db.index.id
neostore.counts.db neostore.propertystore.db.index.keys
neostore.id neostore.propertystore.db.index.keys.id
neostore.indexstats.db neostore.propertystore.db.strings
neostore.labelscanstore.db neostore.propertystore.db.strings.id
neostore.labeltokenstore.db neostore.relationshipgroupstore.db
neostore.labeltokenstore.db.id neostore.relationshipgroupstore.db.id
neostore.labeltokenstore.db.names neostore.relationshipstore.db
neostore.labeltokenstore.db.names.id neostore.relationshipstore.db.id
neostore.nodestore.db neostore.relationshiptypestore.db
neostore.nodestore.db.id neostore.relationshiptypestore.db.id
neostore.nodestore.db.labels neostore.relationshiptypestore.db.names
neostore.nodestore.db.labels.id neostore.relationshiptypestore.db.names.id
neostore.propertystore.db neostore.schemastore.db
neostore.propertystore.db.arrays neostore.schemastore.db.id
neostore.propertystore.db.arrays.id neostore.transaction.db.0
neostore.propertystore.db.id profiles/
neostore.propertystore.db.index
Second time run is only incremental as shown below
root@b50eb2110ccf:/var/lib/neo4j# bin/neo4j-admin backup --backup-dir=neo4j-backups --pagecache=4G
2020-05-04 23:56:57.893+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving transactions from 6
2020-05-04 23:56:58.211+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving transactions at -1, took 307ms
Index structure consistency check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Full Consistency Check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
............Checking node and relationship counts
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Backup complete.
root@b50eb2110ccf:/var/lib/neo4j#
Copy the backup files in the data folder
Start a new container for the restore and use neo4j-admin restore command
Text Box
neo4jadmin@ranchimall4:~/neo4jtest$ sudo mv backups data/
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker run -it --name neo4jtestbackup -v $HOME/neo4jtest/data:/data -v $HOME/neo4jtest/logs:/logs -v $HOME/neo4jtest/import:/var/lib/neo4jtest/import -v $HOME/neo4jtest/plugins:/plugins --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes neo4j:4.0.4-enterprise /bin/bash
neo4j@5312a8c03589:~$ cd data
neo4j@5312a8c03589:~/data$ ls
backups databases dbms transactions
neo4j@5312a8c03589:~/data$ cd ..
neo4j@5312a8c03589:~$ bin/neo4j-admin restore --from=/data/backups/neo4j-backups/neo4j/ --database=neo4j --force
The database is in use. Stop database 'neo4j' and try again.
neo4j@5312a8c03589:~$ exit
exit
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker rm neo4jtestbackup
neo4jtestbackup
Stop docker using the database
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker stop neo4jtest
neo4jtest
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker run -it --name neo4jtestbackup -v $HOME/neo4jtest/data:/data -v $HOME/neo4jtest/logs:/logs -v $HOME/neo4jtest/import:/var/lib/neo4jtest/import -v $HOME/neo4jtest/plugins:/plugins --env=NEO4J_ACCEPT_LICENSE_AGREEMENT=yes neo4j:4.0.4-enterprise /bin/bash
Perform restore operation here
neo4j@d9ccf0ec00ff:~$ bin/neo4j-admin restore --from=/data/backups/neo4j-backups/neo4j/ --database=neo4j --force
neo4j@d9ccf0ec00ff:~$ exit
exit
Start the server again
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker start neo4jtest
neo4jtest
Below screenshot shows that after restore, test3 node is removed as expected. Note that backup was taken before test3 node addition.
Backup and restore via host machine
neo4jadmin@ranchimall4:~/neo4jtest$ mkdir -p data/backups/neo4j-backups
mkdir: cannot create directory ‘data/backups’: Permission denied
neo4jadmin@ranchimall4:~/neo4jtest$ sudo chown -R ${USER} data
First time backup
neo4jadmin@ranchimall4:~/neo4jtest$ mkdir -p data/backups/neo4j-backups
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker exec -it neo4jtest /bin/bash -c "bin/neo4j-admin backup --backup-dir=data/backups/neo4j-backups --pagecache=4G"
2020-05-05 01:04:28.223+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store files
2020-05-05 01:04:28.228+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.nodestore.db.labels
2020-05-05 01:04:28.255+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.nodestore.db.labels
2020-05-05 01:04:28.255+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.nodestore.db
2020-05-05 01:04:28.327+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.nodestore.db
2020-05-05 01:04:28.328+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.index.keys
2020-05-05 01:04:28.335+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.index.keys
2020-05-05 01:04:28.335+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.index
2020-05-05 01:04:28.342+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.index
2020-05-05 01:04:28.342+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.strings
2020-05-05 01:04:28.350+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.strings
2020-05-05 01:04:28.350+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.arrays
2020-05-05 01:04:28.361+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db.arrays
2020-05-05 01:04:28.361+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db
2020-05-05 01:04:28.370+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.propertystore.db
2020-05-05 01:04:28.370+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshipstore.db
2020-05-05 01:04:28.380+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshipstore.db
2020-05-05 01:04:28.381+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshiptypestore.db.names
2020-05-05 01:04:28.388+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshiptypestore.db.names
2020-05-05 01:04:28.391+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshiptypestore.db
2020-05-05 01:04:28.404+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshiptypestore.db
2020-05-05 01:04:28.405+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.labeltokenstore.db.names
2020-05-05 01:04:28.413+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.labeltokenstore.db.names
2020-05-05 01:04:28.413+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.labeltokenstore.db
2020-05-05 01:04:28.421+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.labeltokenstore.db
2020-05-05 01:04:28.421+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.schemastore.db
2020-05-05 01:04:28.430+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.schemastore.db
2020-05-05 01:04:28.431+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshipgroupstore.db
2020-05-05 01:04:28.438+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore.relationshipgroupstore.db
2020-05-05 01:04:28.439+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving store file /data/backups/neo4j-backups/neo4j/neostore
2020-05-05 01:04:28.449+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store file /data/backups/neo4j-backups/neo4j/neostore
2020-05-05 01:04:28.455+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving store files, took 222ms
2020-05-05 01:04:28.456+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving transactions from 8
2020-05-05 01:04:28.964+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving transactions at 9, took 507ms
Index structure consistency check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Full Consistency Check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
............Checking node and relationship counts
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Backup complete.
Second time backup
neo4jadmin@ranchimall4:~/neo4jtest$ sudo docker exec -it neo4jtest /bin/bash -c "bin/neo4j-admin backup --backup-dir=data/backups/neo4j-backups --pagecache=4G"
2020-05-05 01:04:47.749+0000 INFO [c.n.b.i.BackupOutputMonitor] Start receiving transactions from 9
2020-05-05 01:04:48.065+0000 INFO [c.n.b.i.BackupOutputMonitor] Finish receiving transactions at -1, took 307ms
Index structure consistency check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Full Consistency Check
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
............Checking node and relationship counts
.................... 10%
.................... 20%
.................... 30%
.................... 40%
.................... 50%
.................... 60%
.................... 70%
.................... 80%
.................... 90%
.................... 100%
Backup complete.
neo4jadmin@ranchimall4:~/neo4jtest$
Example shell script
Shell script for performing backup
root@ranchimall4:/home/neo4jadmin/neo4jrepo/backups# cat perform_backup.sh
#!/usr/bin/env bash
BACKUP_NEO4J_SVR_NAME="neo4jtest"
BACKUP_NEO4J_DIR_PATH=${BACKUP_NEO4J_DIR_PATH:-"data/backups/neo4j-backups"}
docker exec -i ${BACKUP_NEO4J_SVR_NAME} /bin/bash -c "bin/neo4j-admin backup --backup-dir=${BACKUP_NEO4J_DIR_PATH} --pagecache=4G" >>/home/neo4jadmin/perform_backup.log 2>&1
root@ranchimall4:/home/neo4jadmin/neo4jrepo/backups#
export VISUAL=vim;crontab -u ${USER} -e -> For editing crontab file
Ensure that you are editing root user crontab(Ref:below example). It is needed since docker run command needs root privilege
Ref: https://neo4j.com/docs/operations-manual/current/backup/restoring/
Neo4j enterprise (paid version) provides query logging, security logging (Refer here) and metrics (Refer here)
Refer here for alternate approach for syslog configuration
Example output via my.papertrailapp.com is as below
May 17 05:39:13 ranchimall4 ProdNeo4J 2020-05-17 00:09:11.376+0000 WARN [o.n.k.i.c.VmPauseMonitorComponent] Detected VM stop-the-world pause: {pauseTime=137, gcTime=0, gcCount=0}
Any system impact: Query was not hanged for minutes
Solution: Constraint on few nodes were not applied. After applying , logs stop coming in 5 mins
Refer: https://community.neo4j.com/t/vm-stop-the-world-pause-for-simple-load-csv-query-for-creating-a-graph/9611
Any system impact: Not yet seen any impact
Error text
May 17 05:49:56 ranchimall4 ProdNeo4J 2020-05-17 00:19:49.003+0000 ERROR [o.n.b.t.p.HouseKeeper] Fatal error occurred when handling a client connection: [id: 0xf02e4590, L:/172.17.0.2:7687 - R:/49.205.223.164:42174] readAddress(..) failed: Connection timed out
notice May 17 05:49:56 ranchimall4 ProdNeo4J io.netty.channel.unix.Errors$NativeIoException: readAddress(..) failed: Connection timed out
Solution: TB found
Refer https://neo4j.com/docs/cypher-manual/current/administration/constraints/
https://docs.docker.com/engine/install/ubuntu/
https://neo4j.com/developer/docker-run-neo4j/
https://hub.docker.com/_/neo4j/
https://www.garron.me/en/bits/specify-editor-crontab-file.html
https://adamcowley.co.uk/neo4j/neo4j-docker-seed-backup/