如果直接进入了neo4j 容器使用命令neo4j -admin 会报错,原因是不允许备份运行中的neo4j 容器
root@c478657c904c:/var/lib/neo4j/bin# neo4j-admin dump --database=neo4j --to=20210712.dump Selecting JVM - Version:11.0.11, Name:OpenJDK 64-Bit Server VM, Vendor:Oracle Corporation The database is in use. Stop database 'neo4j' and try again. org.neo4j.server.startup.BootFailureException: Unexpected process failure. See log for info. ?? ?at org.neo4j.server.startup.ProcessManager.run(ProcessManager.java:185) ?? ?at org.neo4j.server.startup.BootloaderOsAbstraction.admin(BootloaderOsAbstraction.java:84) ?? ?at org.neo4j.server.startup.Bootloader.admin(Bootloader.java:261) ?? ?at org.neo4j.server.startup.Neo4jAdminCommand.call(Neo4jAdminCommand.java:67) ?? ?at org.neo4j.server.startup.Neo4jAdminCommand.call(Neo4jAdminCommand.java:38) ?? ?at picocli.CommandLine.executeUserObject(CommandLine.java:1953) ?? ?at picocli.CommandLine.access$1300(CommandLine.java:145) ?? ?at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2352) ?? ?at picocli.CommandLine$RunLast.handle(CommandLine.java:2346) ?? ?at picocli.CommandLine$RunLast.handle(CommandLine.java:2311) ?? ?at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2179) ?? ?at picocli.CommandLine.execute(CommandLine.java:2078) ?? ?at org.neo4j.server.startup.Neo4jAdminCommand.main(Neo4jAdminCommand.java:72)
1.创建另外一个neo4j的容器(neo4j_copy),并映射同样的数据库
2.停止容器neo4j,进入neo4j_copy容器进行数据导出
3.使用neo4j -admin dump导出数据
neo4j-admin dump --database=neo4j --to=20210712.dump
database = neo4j 这个是我要备份的数据库
--to = 2020.dump 这个是备份的名称
4。复制数据到容器外面docker cp? id:
?5.把数据复制到测试环境
6.和备份的服务器一样,需要重新开一个容器,并使用另外一台容器进行数据的导入
neo4j-admin load --from=/data/20210712.dump --database=neo4j --force
7.启动neo4j 数据库
|