文章目录
1、开启自动备份
在宿主机执行:
shell
bash #{lakehouse_home}/neo4j_cron.sh
自动备份开启如下日志:
log
Fri Mar 7 01:59:53 UTC 2025 - Checking if cron job already exists.
Fri Mar 7 01:59:53 UTC 2025 - Adding new cron job.
Fri Mar 7 01:59:53 UTC 2025 - Cron job added: 0 23 * * * bash /root/run/neo4j_backup.sh >> /var/lib/neo4j/import/cron_backup.log 2>&1
Fri Mar 7 01:59:53 UTC 2025 - Checking if cron service is running.
Fri Mar 7 01:59:53 UTC 2025 - Cron service is already running.
Fri Mar 7 01:59:53 UTC 2025 - === Cron Job Setup Completed ===
2、恢复
进入到容器:
bash
docker exec -it neo4j bash
执行恢复
bash
bash /root/run/neo4j_restore.sh
有如下日志:
log
Fri Mar 7 01:54:18 UTC 2025 - Restore started.
Fri Mar 7 01:54:18 UTC 2025 - Running apoc.import.graphml to restore the graph.
+-----------------------------------------------------------------------------------------------------------------------------------------+
| file | source | format | nodes | relationships | properties | time | rows | batchSize | batches | done | data |
+-----------------------------------------------------------------------------------------------------------------------------------------+
| "neo4j_backup_last.graphml" | "file" | "graphml" | 138 | 84 | 169 | 31 | 0 | -1 | 0 | TRUE | NULL |
+-----------------------------------------------------------------------------------------------------------------------------------------+
1 row
ready to start consuming query after 1 ms, results consumed after another 32 ms
Fri Mar 7 01:54:20 UTC 2025 - Restore successful: /var/lib/neo4j/import/neo4j_backup_last.graphml
详细脚本见我的github项目:docker-compose-demo:neo4j docker compose 组件以及自动化备份脚本