Neo4j数据进行备份、还原
一、neo4j备份方式
neo4j数据库的备份还原分为两种: offline 和 online。
Offline backup
- dump
Dump a database into a single-file archive.
- load
Load a database from an archive created with the dump command.
Online backup
- backup
Perform an online backup from a running Neo4j enterprise server.
- restore
Restore a backed up database.
二、offline backup
在对Neo4j数据进行备份、还原、迁移的操作时,首先要关闭neo4j;
cd %NEO4J_HOME%/bin
./neo4j stop
数据备份到文件
./neo4j-admin dump --database=graph.db --to=/home/2018.dump
之后,进行数据还原,将生成的存储文件拷贝到另一个相同版本的环境中,
(测试中可以进行清空Neo4j库操作:match (n) detach delete n )
还原、迁移之前 ,关闭neo4j服务。操作同上;
数据导入:
./neo4j-admin load --from=/home/2016-10-02.dump --database=graph.db --force
重启服务:
./neo4j start
或者
bin/neo4j console
- 验证数据
load执行完后,需要验证下看是否正确。首先确认规模性统计数字一致。比如节点数、关系数等等。然后再用一些测试样例MATCH回来仔细核查确认。最好是能维护一个测试验证集,自动跑一遍。
如果数据有问题,可以到neo4j.conf文件中,查看
dbms.allow_format_migration=true这行是否生效,使之生效。
三、online backup
1.1. Backup commands
A Neo4j database can be backed up in online mode, using the backup command of neo4j-admin.
Syntax
neo4j-admin backup --backup-dir=<backup-path> --name=<graph.db-backup>
[--from=<address>] [--protocol=<any|catchup|common>]
[--fallback-to-full[=<true|false>]]
[--pagecache=<pagecache>]
[--timeout=<timeout>]
[--check-consistency[=<true|false>]]
[--additional-config=<config-file-path>]
[--cc-graph[=<true|false>]]
[--cc-indexes[=<true|false>]]
[--cc-label-scan-store[=<true|false>]]
[--cc-property-owners[=<true|false>]]
[--cc-report-dir=<directory>]
Options
| Option | Default | Description |
|---|---|---|
|
--backup-dir |
Directory to place backup in. |
|
|
--name |
Name of backup. If a backup with this name already exists an incremental backup will be attempted. |
|
|
--from |
localhost:6362 |
Host and port of Neo4j. |
|
--protocol |
any |
Protocol over which to perform backup. If set to |
|
--fallback-to-full |
true |
If an incremental backup fails backup will move the old backup to <name>.err.<N> and fallback to a full backup instead. |
|
--pagecache |
8M |
The size of the page cache to use for the backup process. |
|
--timeout |
20m |
Timeout in the form <time>[ms|s|m|h], where the default unit is seconds. This is a debugging option that should only be used if instructed to by Neo4j Professional Services. |
|
--check-consistency |
true |
If a consistency check should be made. |
|
--additional-config |
Configuration file to supply additional configuration in. |
|
|
--cc-graph |
true |
Perform checks between nodes, relationships, properties, types and tokens. |
|
--cc-indexes |
true |
Perform checks on indexes. |
|
--cc-label-scan-store |
true |
Perform checks on the label scan store. |
|
--cc-property-owners |
false |
Perform additional checks on property ownership. This check is very expensive in time and memory. |
|
--cc-report-dir |
. |
Directory where consistency report will be written. |
1.2. Full backups
A full backup is performed whenever there is no backup directory specified.
In this example, set environment variables in order to control memory usage.
The page cache is defined by using the command line option --pagecache. Further, the HEAP_SIZE environment variable will specify the maximum heap size allocated to the backup.
Now you can perform a full backup:
$neo4j-home> export HEAP_SIZE=2G
$neo4j-home> mkdir /mnt/backup
$neo4j-home> bin/neo4j-admin backup --from=192.168.1.34 --backup-dir=/mnt/backup --name=graph.db-backup --pagecache=4G
Doing full backup...
2017-02-01 14:09:09.510+0000 INFO [o.n.c.s.StoreCopyClient] Copying neostore.nodestore.db.labels
2017-02-01 14:09:09.537+0000 INFO [o.n.c.s.StoreCopyClient] Copied neostore.nodestore.db.labels 8.00 kB
2017-02-01 14:09:09.538+0000 INFO [o.n.c.s.StoreCopyClient] Copying neostore.nodestore.db
2017-02-01 14:09:09.540+0000 INFO [o.n.c.s.StoreCopyClient] Copied neostore.nodestore.db 16.00 kB
...
...
...
If you do a directory listing of /mnt/backup you will now see that you have a backup of Neo4j called graph-db.backup.
1.3. Incremental backups
An incremental backup is performed whenever an existing backup directory is specified, and the transaction logs are present since the last backup. The backup command will then copy any new transactions from Neo4j and apply them to the backup. The result will be an updated backup that is consistent with the current server state.
The transaction log files should be rotated and pruned based on the provided configuration. For example, setting dbms.tx_log.rotation.retention_policy=3 files will keep backup transaction logs to 3 files. You can use the --additional-config parameter to override this configuration.
This example assumes that you have performed a full backup as per the previous example. In the same way as before, make sure to control the memory usage.
To perform an incremental backup you need to specify the location of your previous backup:
$neo4j-home> export HEAP_SIZE=2G
$neo4j-home> bin/neo4j-admin backup --from=192.168.1.34 --backup-dir=/mnt/backup --name=graph.db-backup --fallback-to-full=true --check-consistency=true --pagecache=4G
Destination is not empty, doing incremental backup...
Backup complete.
The incremental backup will fail if the existing directory does not contain a valid backup and --fallback-to-full=false. It will also fail if the required transaction logs have been removed and --fallback-to-full=false. Setting --fallback-to-full=true is a safeguard which will result in a full backup in case an incremental backup cannot be performed.
It is important to note that --check-consistency is true by default. For a quicker incremental backup we can set this to --check-consistency=false and --fallback-to-full=false.
|
When copying outstanding transactions, the server needs access to the transaction logs. These logs are maintained by Neo4j and are automatically removed after a period of time, based on the parameter When designing your backup strategy it is important to configure |
1.4. Exit codes
neo4j-admin backup will exit with different codes depending on success or error. In the case of error, this includes details of what error was encountered.
| Code | Description |
|---|---|
|
|
Success. |
|
|
Backup failed. |
|
|
Backup succeeded but consistency check failed. |
|
|
Backup succeeded but consistency check found inconsistencies. |
Restore a backup
This section describes how to restore from a backup of a Neo4j database.
This section includes:
2.1. Restore commands
A Neo4j database can be restored using the restore command of neo4j-admin.
Syntax
neo4j-admin restore --from=<backup-directory> [--database=<name>] [--force[=<true|false>]]
Options
| Option | Default | Description |
|---|---|---|
|
--from |
Path to backup to restore from. |
|
|
--database |
graph.db |
Name of database. |
|
--force |
false |
If an existing database should be replaced. |
2.2. Restore a single database
To restore from a backup, follow these steps:
- If the database is running, shut it down.
- Run
neo4j-admin restore. - Start up the database.
Restore the database graph.db from the backup located in /mnt/backup/graph.db-backup. Note that the database to be restored must be shut down.
neo4j-home> bin/neo4j stop
neo4j-home> bin/neo4j-admin restore --from=/mnt/backup/graph.db-backup --database=graph.db --force
neo4j-home> bin/neo4j start
2.3. Restore a Causal Cluster
To restore from a backup in a Causal Cluster, follow these steps:
- Shut down all database instances in the cluster.
- Run the
neo4j-admin unbindcommand on each of the Core Servers. - Restore the backup on each instance, using
neo4j-admin restore. If you are restoring onto new hardware, please review the Causal Clustering settings in neo4j.conf.
In particular, check the settings
causal_clustering.initial_discovery_members,causal_clustering.minimum_core_cluster_size_at_formation, andcausal_clustering.minimum_core_cluster_size_at_runtime, and ensure that they correctly reflect the new setup.- Start the database instances.
转载自:
https://blog.csdn.net/c1052981766/article/details/79530061
https://www.jianshu.com/p/9095e29974a6
https://neo4j.com/docs/operations-manual/current/backup/performing/
Neo4j数据进行备份、还原的更多相关文章
- MS SQL数据批量备份还原(适用于MS SQL 2005+)
原文:MS SQL数据批量备份还原(适用于MS SQL 2005+) 我们知道通过Sql代理,可以实现数据库的定时备份功能:当数据库里的数据库很多时,备份一个数据库需要建立对应的定时作业,相对来说比较 ...
- mysql innobackupex xtrabackup 大数据量 备份 还原
大数据量备份与还原,始终是个难点.当MYSQL超10G,用mysqldump来导出就比较慢了.在这里推荐xtrabackup,这个工具比mysqldump要快很多. 一.Xtrabackup介绍 1, ...
- mysql innobackupex xtrabackup 大数据量 备份 还原(转)
原文:http://blog.51yip.com/mysql/1650.html 作者:海底苍鹰 大数据量备份与还原,始终是个难点.当MYSQL超10G,用mysqldump来导出就比较慢了.在这里推 ...
- MS SQL数据批量备份还原(适用于MS SQL 2005+) 分类: SQL Server 数据库 2015-03-10 14:32 103人阅读 评论(0) 收藏
我们知道通过Sql代理,可以实现数据库的定时备份功能:当数据库里的数据库很多时,备份一个数据库需要建立对应的定时作业,相对来说比较麻烦: 还好,微软自带的osql工具,比较实用,通过在命令行里里输入命 ...
- Docker 学习笔记(持久化数据的备份,还原)
假如我们应用程序需要一台 mssql 数据库来持久化数据,我们将 mssql 数据库运行于 Docker 容器中: docker run -d -p 1433:1433 -e "ACCEPT ...
- Spring Boot + Spring Cloud 实现权限管理系统 后端篇(十三):系统备份还原
系统备份还原 在很多时候,我们需要系统数据进行备份还原.我们这里就使用MySql的备份还原命令实现系统备份还原的功能. 新建工程 新建一个maven项目,并添加相关依赖,可以用Spring boot脚 ...
- Vue + Element UI 实现权限管理系统 前端篇(十六):系统备份还原
系统备份还原 在很多时候,我们需要系统数据进行备份还原.我们这里就使用MySql的备份还原命令实现系统备份还原的功能. 后台接口准备 系统备份还原是对数据库的备份还原,所以必须有后台接口的支持,我们准 ...
- SQL Server 大数据搬迁之文件组备份还原实战
一.本文所涉及的内容(Contents) 本文所涉及的内容(Contents) 背景(Contexts) 解决方案(Solution) 搬迁步骤(Procedure) 搬迁脚本(SQL Codes) ...
- DEDECMS网站数据备份还原教程
备份织梦网站数据 dedecms备份教程 进入DedeCms后台 -> 系统 -> 数据库备份/还原 备份文件在\data\backupdata 下载数据库备份资料\data\backup ...
随机推荐
- 利用Python进行数据分析 第8章 数据规整:聚合、合并和重塑.md
学习时间:2019/11/03 周日晚上23点半开始,计划1110学完 学习目标:Page218-249,共32页:目标6天学完(按每页20min.每天1小时/每天3页,需10天) 实际反馈:实际XX ...
- C++11<functional>深度剖析:背景、原理、接口与实现
自C++11以来,C++标准每3年修订一次.C++14/17都可以说是更完整的C++11:即将到来的C++20也已经特性完整了. C++11已经有好几年了,它的年龄比我接触C++的时间要长10倍不止吧 ...
- adb连接安卓设备的2种方式
一.usb连接 安卓设备打开开发者模式,启用usb调试 CMD窗口输入adb devices,此时可以看到自己的设备 PS:无法看到自己设备时,查看手机USB调试是否打开:PC端是否安装手机驱动. 二 ...
- java使用poi操作word, 支持动态的行(一个占位符插入多条)和表格中动态行, 支持图片
依赖 <dependency> <groupId>org.apache.poi</groupId> <artifactId>poi</artifa ...
- AtCoder Grand Contest 034
A:如果C在D左侧,显然先让B到达终点再让A走即可,否则先判断一下A是否可以在某处超过B.也就是先判断一下起点与终点之间是否有连续的障碍,若有则无解:然后若C在D左侧输出Yes,否则判断B和D之间是否 ...
- C# 阿拉伯数字转换为中文数字/中文数字转换为阿拉伯数字
项目中经常会格式化数据,转换数字的使用情况比较多,记录一下数字转换的方法! 如果需要转换为繁体中文,将数组里的汉字换成繁体中文即可. 1.阿拉伯数字转换为中文数字 /// <summary> ...
- .net core使用CSRedisCore连接哨兵集群,并用作redis使用分布式缓存。
CSRedisCore是国内大佬出品的一个Redis-Cli-SDK. Github地址:https://github.com/2881099/csredis 使用此插件作为分布式缓存也十分简单. 一 ...
- "多层感知器"--MLP神经网络算法
提到人工智能(Artificial Intelligence,AI),大家都不会陌生,在现今行业领起风潮,各行各业无不趋之若鹜,作为技术使用者,到底什么是AI,我们要有自己的理解. 目前,在人工智能中 ...
- JAVA 插入注解处理器
JDK1.5后,Java语言提供了对注解(Annotation)的支持 JDK1.6中提供一组插件式注解处理器的标准API,可以实现API自定义注解处理器,干涉编译器的行为. 在这里,注解处理器可以看 ...
- 一、ribbon如何集成在openfeign中使用
所有文章 https://www.cnblogs.com/lay2017/p/11908715.html 正文 ribbon是springcloud封装的一个基于http客户端负载均衡的组件.spri ...