Neo4j数据库备份与恢复
先上官方文档:Backup and restore - Operations Manual (neo4j.com)
企业版可以在线备份,可以同时备份多个数据库,可以进行一致性检验等等。
社区版的话,没有太多选择,只能冷备份:先停止数据库,备份(或者恢复备份),再重启数据库。
备份(社区版)
Back up an offline database - Operations Manual (neo4j.com)
命令如下:
bin/neo4j-admin dump --database=neo4j --to=/dumps/neo4j/neo4j-<timestamp>.dump
Option参数 | Default默认值 | Description描述 |
---|---|---|
--database | neo4j | Name of the database to dump.(要转储的数据库的名称) |
--to | Destination (file or folder) of database dump.(数据库转储的目标(文件或文件夹)。) | |
--verbose | Enable verbose output.(启用详细输出。) |
操作示例:
-
停止Neo4j.
-
打开终端,备份指定数据库
react2.db
PS C:\Users\w> neo4j-admin dump --database=react2.db --to=D:\Installed\neo4j-community-4.0.11\backup\react2-20220202-1150.dump Done: 34 files, 976.3KiB processed. PS C:\Users\w>
备份完成.
恢复备份(社区版)
Restore a database dump - Operations Manual (neo4j.com)
命令如下:
bin/neo4j-admin load --from=/dumps/neo4j/neo4j-<timestamp>.dump --database=neo4j --force
Option参数 | Default默认值 | Description |
---|---|---|
--verbose | Enable verbose output.(启用详细输出) | |
--from | Path to archive created with the neo4j-admin dump command.(dump文件路径) | |
--database | neo4j | Name for the loaded database.(准备恢复的数据库的名称。) |
--force | Replace an existing database.(替换现有数据库。) | |
info | Print meta-data information about the archive file, such as, file count, byte count, and format of the load file.(打印有关存档文件的元数据信息,例如文件计数、字节计数和加载文件的格式。) |
操作示例:参考“备份”。
(未完待续~)