【Docker compose】基于宿主机的Neo4j自动备份

1、开启自动备份

在宿主机执行:

bash #{lakehouse_home}/neo4j_cron.sh  

自动备份开启如下日志:

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、恢复

进入到容器:

docker exec -it neo4j bash 

执行恢复

bash /root/run/neo4j_restore.sh

有如下日志:

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 组件以及自动化备份脚本

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

roman_日积跬步-终至千里

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值